Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
More nits on var=value command
- X-seq: zsh-workers 27515
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: More nits on var=value command
- Date: Mon, 14 Dec 2009 08:06:34 -0800
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
The "var=value command" syntax is supposed to set var to value in the
environment of command.
schaefer<529> outer=INNER printenv outer
INNER
"typeset +x" removes a variable from the environment:
schaefer<530> outer=INNER eval 'printenv outer; typeset +x outer; printenv outer'
INNER
But assignment to "outer" in this case automatically exports it again:
schaefer<531> outer=INNER eval 'printenv outer; typeset +x outer=$outer; printenv outer'
INNER
INNER
schaefer<532> outer=INNER eval 'printenv outer; typeset +x outer; outer=$outer; printenv outer'
INNER
INNER
schaefer<533> outer=INNER eval 'printenv outer; typeset +x outer; outer=$outer; printenv outer; typeset +x outer; printenv outer'
INNER
INNER
Finally, the variable is unset at the end whether or not it's still in
the environment:
schaefer<534> echo X $outer X
X X
Bash differs from zsh on the "automatically exported" part but not on the
unset-it-anyway part:
[schaefer@torch ~]$ outer=INNER eval 'printenv outer; typeset +x outer; outer=$outer; printenv outer; typeset +x outer; printenv outer'
INNER
[schaefer@torch ~]$ echo X $outer X
X X
Messages sorted by:
Reverse Date,
Date,
Thread,
Author