zsh-workers
 help / color / mirror / code / Atom feed
From: Martijn Dekker <martijn@inlv.org>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: exported unset variables [was: 'export -p' lacks POSIX output]
Date: Fri, 28 Oct 2016 22:00:10 +0100	[thread overview]
Message-ID: <9a5b08ae-f45b-d1df-9b3b-dd47a0f62412@inlv.org> (raw)
In-Reply-To: <ca368ae0-3c79-0245-6905-09a5fc563c28@inlv.org>

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:

bf258a1c07a9cf1119f83d1d15310b02b94f4d67
60c6bcdeae6d132c0ab770cc8491055b24f7670e
f855801fb9ed82d2596f52f5b64dd66c42255c5f

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

Thanks,

- M.



  parent reply	other threads:[~2016-10-28 21:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-22  3:02 'export -p' lacks POSIX output Martijn Dekker
2016-10-22 18:24 ` Bart Schaefer
2016-10-23 12:00   ` Martijn Dekker
2016-10-23 16:47     ` Bart Schaefer
2016-10-24  8:33   ` Peter Stephenson
2016-10-28 21:00 ` Martijn Dekker [this message]
2016-10-28 21:31   ` exported unset variables [was: 'export -p' lacks POSIX output] Bart Schaefer
2016-10-28 21:48     ` Martijn Dekker
2016-10-29  0:18       ` Bart Schaefer
2016-10-29  8:11         ` Martijn Dekker
2016-10-29 18:09           ` Bart Schaefer
2016-10-29 18:43             ` Peter Stephenson
2016-10-29 19:05           ` Bart Schaefer
2016-10-29 20:20             ` interactive comments [was: exported unset variables] Martijn Dekker
2016-10-30  1:25               ` Bart Schaefer

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=9a5b08ae-f45b-d1df-9b3b-dd47a0f62412@inlv.org \
    --to=martijn@inlv.org \
    --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).