From: Joke de Buhr <joke@seiken.de>
To: zsh-users@zsh.org
Subject: environment variables
Date: Tue, 31 Aug 2010 17:54:25 +0200 [thread overview]
Message-ID: <201008311754.27361.joke@seiken.de> (raw)
[-- Attachment #1: Type: Text/Plain, Size: 1138 bytes --]
I'm not sure but I think the following behavior is kind of inconsistent.
Setting the environment works different on functions and program.
Case 1 and 2 export a variable before calling the env program. In case 2
copying the assignment of HELLO works as expected. Case 3 and 4 export a
variable before calling a function which calls the env program. In case 4
copying the the assignment of HELLO doesn't work because HELLO is assigned to
$HELLO but assigning HELLO to $WORLD (case 3) works.
Any reason why zsh behaves this way? Bash doesn't have this strange behavior.
## 1: export to command (different variable)
$ WORLD=world
$ HELLO=$WORLD env | grep '^HELLO'
HELLO=world
## 2: export to command (same variable)
$ HELLO=world
$ HELLO=$HELLO env | grep '^HELLO'
HELLO=world
## 3: HELLO exported to shell function, same behavior as 1
$ call() { env | grep '^HELLO' }
$ WORLD=world
$ HELLO=$WORLD call
HELLO=world
## 4: HELLO not exported to shell function, different from 2 and 3
$ call() { env | grep '^HELLO' }
$ HELLO=world
$ HELLO=$HELLO call
HELLO= ## <-- empty
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 706 bytes --]
reply other threads:[~2010-08-31 16:25 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=201008311754.27361.joke@seiken.de \
--to=joke@seiken.de \
--cc=zsh-users@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).