I want to return an array from the function on bash and use this array in another function. But I get a string, not an array, can you please help me about how can I return an array from bash function, I am new in bash scripting, thanks.
array(){
local words=("a a" "b b" "c c")
echo ${words[@]}
}
getWord(){
words=$(array)
for word in "${words[@]}"; do
echo "$word"
done
}
getWord
It returns string of a a b b c c
but my expected result should be an array.