I am using the bash version 4.2.37 at ubuntu 12.10. But since ubuntu 12.04 I am unable to export arrays in bash...
This is an example (type these lines in the command line, it is not a script):
export astr=(a "b c" d)
declare -p |grep astr
bash
echo ${astr[@]}
declare -p |grep astr
echo
outputs nothing...
declare -p |grep astr
outputs nothing either...
What I am looking for is an workaround, because as far I know that is considered an known bash bug.
EDIT: btw, if possible, the workaround could avoid creating temporary storage files for the array as I may run the same script simultaneously on different shells.
It's not a bug with bash, there's just not any safe way to put a bash array in the environment.
As for workarounds, that depends on what you're trying to achieve with exporting arrays in the first place.
One possible workaround, for some cases, is to dump the array to a file and source that file where you need it.
Another workaround could be to pass the array on as arguments to the next shell.
Wait wait wait... I know that I'm a little late here, but this question is still relevant when we are looking for exporting arrays on google so, my workaround was:
It will return c once arrays first position is 0. I hope that helps someone looking for it.
Regards