On Mon, May 12, 2014 at 03:33:34PM +0200, Geir Hauge wrote: > Oddly, the quotes seem to matter; changing array='(x)' to array=(x) > makes it work... > > $ f() { source <(printf "declare -a array=(x); declare -p array\n"); }; f > declare -a array='([0]="x")'
OK, this also happens on my system. In fact this is the first time I've ever seen array='(...)' instead of array=(...) and I had no idea the quoted version works outside of a function. It seems like an incredibly strange syntax; without the explicit "declare -a" it would be initializing a string variable. But this doesn't change the fact that the original poster is making a local variable inside the function, which won't be visible outside it.