From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: More nits on var=value command
Date: Mon, 14 Dec 2009 08:06:34 -0800 [thread overview]
Message-ID: <091214080634.ZM8254@torch.brasslantern.com> (raw)
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
reply other threads:[~2009-12-14 16:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=091214080634.ZM8254@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/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).