zsh-workers
 help / color / mirror / code / Atom feed
* More nits on var=value command
@ 2009-12-14 16:06 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2009-12-14 16:06 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-12-14 16:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-14 16:06 More nits on var=value command Bart Schaefer

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).