From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29221 invoked by alias); 28 Oct 2016 21:18:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39752 Received: (qmail 8224 invoked from network); 28 Oct 2016 21:18:35 -0000 X-Qmail-Scanner-Diagnostics: from kahlil.inlv.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(37.59.109.123):SA:0(-1.4/5.0):. Processed in 0.477129 secs); 28 Oct 2016 21:18:35 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: martijn@inlv.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at inlv.org does not designate permitted sender hosts) Subject: exported unset variables [was: 'export -p' lacks POSIX output] To: Zsh hackers list References: From: Martijn Dekker Message-ID: <9a5b08ae-f45b-d1df-9b3b-dd47a0f62412@inlv.org> Date: Fri, 28 Oct 2016 22:00:10 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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", , > | > | if name is set, and: > | > | "export %s\n", > | > | 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.