Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Exporting arrays
- X-seq: zsh-users 1219
- From: Andrew Main <zefram@xxxxxxxxx>
- To: adam.spiers@xxxxxxxxxxxx
- Subject: Re: Exporting arrays
- Date: Mon, 12 Jan 1998 10:45:06 +0000 (GMT)
- Cc: zsh-users@xxxxxxxxxxxxxxx
- In-reply-to: <19980111181603.60292@xxxxxxxxxxxxxxxxxxxxxxx> from "Adam Spiers" at Jan 11, 98 06:16:03 pm
Adam Spiers wrote:
>% foo=(a b c)
>% typeset | grep zzz
>array foo=(a b c)
>% export foo=(a b c)
>% typeset | grep zzz
>array exported foo=(a b c)
>
>However,
>
>% unset foo
>% export foo=(a b c)
>% typeset | grep zzz
>exported foo='(a b c)'
This sort of thing has cropped up before, and it has always been due to
human error. </hal>
In the case of "export foo=(a b c)", the parens do not actually delimit
an array. They are treated as globbing metacharacters. This command runs
the builtin "export", with argument "foo=(a b c)", which it interprets as
a request to export the variable "foo" and set its value to the scalar
"(a b c)". In the second of your dialogues, that's precisely what
happens. In the first dialogue, you first set foo to be an array,
and the export command refused to change it to a scalar.
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author