Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: exporting arrays

> "ar" shows up in the list, but in the following 'zsh'-invocation it is
> unset. Is this intentional? I didn't find any  restrictions mentioned in
> the manual.

The restriction is in Unix.  The contents of an environment variable is
always a plain null-terminated string on Unix.  It is possible to hack
something as a workaround, but there is no prefect solution as far as I
know.  Neither bash not ksh exports arrays.  More precisely ksh93 does
export arrays but only the first array element gets into the enviromnet
(which is consistent since without subscritps a ksh array behaves like a
variable with the first array element as its value).

Exported functions has similar problems (just try foo='() {' bash to
see what I meen).  Probably that's why ksh93 does not have exported
functions and POSIX does not require it.

The foo()=... encoding to put functions into the environment seems to be
more reasonable and does not have the problem mentioned above.  It was even
included in some early POSIX drafts.  I wonder why doesn't bash use that
method instead of this ambiguous foo='() { ...' encoding.


Messages sorted by: Reverse Date, Date, Thread, Author