I wonder how to export arrays in bash. I wrote code like this,
but it didn't work:
declare -ax y[100]
y[3]="thisisatest"
#start a new bash
bash
echo ${y[3]}
#string "thisisatest" expected, but nothing printed
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
man bash:
BUGS
.....
Array variables may not (yet) be exported.
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2003, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
Well, you can use
array=(whatever foo bar)
export x_array=$(printf '%q ' "${array[@]}")
And in the child shell:
eval "array=( ${x_array[*]} )"
But why the hell would one need to do this?
--
Stéphane