Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Two esoteric zsh questions
- X-seq: zsh-users 3413
- From: Zefram <zefram@xxxxxxxx>
- To: Jerry Peek <jpeek@xxxxxxxxx>
- Subject: Re: Two esoteric zsh questions
- Date: Fri, 8 Sep 2000 21:19:42 +0100 (BST)
- Cc: zsh-users@xxxxxxxxxxxxxx
- In-reply-to: <24818.968185312@xxxxxxxxx> from Jerry Peek at "Sep 5, 2000 01:21:52 pm"
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
Jerry Peek wrote:
>1) Can anyone explain the difference in the following two cases? The
>first sets a shell variable; the second sets an environment variable.
>In the second, I have to quote the `who`:
>
> % whoson=`who`
> % export WHOSON=`who`
>
>I looked through the FAQ and scanned through a change list... but
>didn't spot changes in more recent versions, so I'm asking the list.
>Is the difference a bug, side effect, or feature?
Side effect of the way `export' is defined. These two commands use
completely different bits of shell grammar. The first is a variable
assignment, in which field splitting is not performed -- everything
in the word on the RHS of the = is assigned to the variable named.
The second is a simple command; the first word is `export' and the
second is `WHOSON=`who`'. In the expansion of that second word, the
backquoted section is subjected to field splitting (I think `` and
$() are the only places where zsh does field splitting by default),
which results in a simple command with more than just the two words.
The `export' command looks at each argument in turn and tries to make
an assignment out of it; its second and subsequent arguments in this
case are part of the output of who.
-zefram
Messages sorted by:
Reverse Date,
Date,
Thread,
Author