I have a function that creates an array and I want to return the array to the caller:
create_array() {
local my_list=(\"a\", \"b\", \"c\")
echo \"${my_li
You can try this
my_algorithm() {
create_array list
for element in "${list[@]}"
do
echo "${element}"
done
}
create_array() {
local my_list=("1st one" "2nd two" "3rd three")
eval "${1}=()"
for element in "${my_list[@]}"
do
eval "${1}+=(\"${element}\")"
done
}
my_algorithm
The output is
1st one
2nd two
3rd three