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

exported unset variables [was: 'export -p' lacks POSIX output]

Op 22-10-16 om 04:02 schreef Martijn Dekker:
> The command 'export -p' always outputs 'typeset' commands. If
> POSIXBUILTINS is active, it should output 'export' commands.
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_22_03
> | When -p is specified, export shall write to the standard output the
> | names and values of all exported variables, in the following format:
> |
> | "export %s=%s\n", <name>, <value>
> |
> | if name is set, and:
> |
> | "export %s\n", <name>
> |
> | if name is unset.

That reminds me that, in POSIX, there is such a thing as a variable that
is both exported and unset; the variable name gets the 'exported' flag
and will retain it if/when it is set later. Ref. as above.

In zsh, however, variables are automatically set to the empty value upon
being exported.

Back in April 2015, in zsh-workers/34991, I reported a similar issue for
readonly variables, which Peter fixed in the following three commits:


zsh needs a similar fix for exported unset variables, presumably also
subject to the POSIXBUILTINS option.


- M.

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