I set the a array as an environment variable in this manner
eg. script test.sh
in test.sh
#!/bin/bash
export STRING=( \"str1\" \"str2\"
Read the fine manual, "bugs" section.
Array variables may not (yet) be exported.
Though, I don't know that many consider this an actual bug. Other shells that support ksh-style arrays don't allow exporting them either.
You may pass around array definitions rather easily, through parameters or variables or the environment. It isn't usually very useful though.
function f {
unset -v "$2"
typeset "$2"
eval "${!1}"
typeset -p "$2"
}
typeset -a a=(a b c)
myArr=$(typeset -p a) f myArr a