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

"export FOO" twice behaves differently than "export FOO" once



Hi, zsh workers--

First of all, zsh is fantastic, so thanks for maintaining it.

I wanted to report some unusual behavior with the export command.  This is
for the usage where a variable is exported without being given a value.
Exporting a variable twice seems to add it to the environment, but
exporting it once does not.  See shell output below.

 % echo $ZSH_VERSION
5.3.1
 % unset FOO
 % export FOO
 % /usr/bin/env | grep FOO
 % export FOO
 % /usr/bin/env | grep FOO
FOO=

Is this an expected behavior?  I can see an argument for either behavior
(either adding FOO to the environment or not adding it) when no value is
given.  But it seems like the behavior should be consistent whether
exporting once or twice.

Note that the same behavior is not true in bash, for example:

bash-4.3$ echo $BASH_VERSION
4.3.0(1)-release
bash-4.3$ unset FOO
bash-4.3$ export FOO
bash-4.3$ /usr/bin/env | grep FOO
bash-4.3$ export FOO
bash-4.3$ /usr/bin/env | grep FOO

Let me know if you need any additional information.  Thanks--
Shane


Messages sorted by: Reverse Date, Date, Thread, Author