Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Exporting arrays
- X-seq: zsh-users 1220
- From: Bernd Eggink <eggink@xxxxxxxxxxxxxxxxxx>
- To: Andrew Main <zefram@xxxxxxxxx>
- Subject: Re: Exporting arrays
- Date: Mon, 12 Jan 1998 14:48:45 +0100
- Cc: adam.spiers@xxxxxxxxxxxx, zsh-users@xxxxxxxxxxxxxxx
- Organization: RRZ Uni Hamburg
- References: <199801121045.KAA05850@xxxxxxxxxxxxxxxx>
- Sender: rz2a022@xxxxxxxxxxxxxxxxxx
Andrew Main wrote:
[ snip ]
> Btw, it's impossible to export an array. Unix environment variables are
> only strings. There are ways an array could be encoded as a string,
> but some other shells get very unhappy about apparently malformed
> environment entries.
>
> -zefram
As a workaround, you could convert the array into a word list, using a
suited delimiter:
a=(one two three four)
export aex=${(j(:))a}
Then, in the subshell, convert the list back into an array:
a=(${(s(:))aex})
Unfortunately this doesn't work if an array element is empty! Example:
a=(one '' three four)
export aex=${(j(:))a} # aex=one::three:four
# ...
a=(${(s(:))aex}) # a=(one three four), $#a == 3
I reported this (IMHO) bug already some weeks ago. Has anybody tried to
fix it? I wasn't able yet to localize it in the sources.
Bernd
--
Bernd Eggink
Regionales Rechenzentrum der Uni Hamburg
eggink@xxxxxxxxxxxxxxxxxx
http://www.rrz.uni-hamburg.de/eggink/BEggink.html
Messages sorted by:
Reverse Date,
Date,
Thread,
Author