I'm working with this:
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
I have a script like below:
#!/bin/bash
map2=()
result=""
f() {
tmpA=(12 34 7844);
map2=("${tmpA[@]}");
echo true;
return;
}
result=$(f)
echo result=$result : array=${map2[@]}
Which returns:
result=true : array=
if I replace result=$(f)
simply by f
it returns:
result= : array=12 34 7844
I could not find the way to modify the global array but also get the return value. Any idea on how to achieve this?