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

More nits on var=value command



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