
10-06-2008
|
|
Shell programmer, author
|
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
|
|
You cannot export arrays.
The easiest way to pass an array is to convert it to a scalar variable, with the elements separated by a character not used in any of the elements. For example, this uses a newline:
Code:
array_separator='
' ## adjust as needed
array=( a b c )
array_contents=$( printf "%s$array_separator" "${array[@]}" )
export array_separator array_contents
To convert it back to an array:
Code:
oIFS=$IFS
IFS=$array_separator
array=( $array_contents )
IFS=$oIFS
|