From: Andrew Main <zefram@tao.co.uk>
To: adam.spiers@new.ox.ac.uk
Cc: zsh-users@math.gatech.edu
Subject: Re: Exporting arrays
Date: Mon, 12 Jan 1998 10:45:06 +0000 (GMT) [thread overview]
Message-ID: <199801121045.KAA05850@taos.demon.co.uk> (raw)
In-Reply-To: <19980111181603.60292@thelonious.new.ox.ac.uk> 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
next prev parent reply other threads:[~1998-01-12 11:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-01-11 18:16 Adam Spiers
1998-01-12 3:51 ` Geoff Wing
1998-01-12 9:01 ` Peter Stephenson
1998-01-12 10:45 ` Andrew Main [this message]
1998-01-12 13:48 ` Bernd Eggink
1998-01-12 15:15 ` Andrew Main
1998-01-12 21:24 ` Bernd Eggink
1998-01-12 22:12 ` Adam Spiers
1998-01-12 23:15 ` Mirar
1998-01-13 1:39 ` Adam Spiers
1998-01-13 14:12 ` Mirar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199801121045.KAA05850@taos.demon.co.uk \
--to=zefram@tao.co.uk \
--cc=adam.spiers@new.ox.ac.uk \
--cc=zsh-users@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).