From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 5d1fe345 for ; Wed, 24 Apr 2019 12:32:43 +0000 (UTC) Received: (qmail 375 invoked by alias); 24 Apr 2019 12:32:26 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23934 Received: (qmail 16948 invoked by uid 1010); 24 Apr 2019 12:32:26 -0000 X-Qmail-Scanner-Diagnostics: from joooj.vinc17.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.1/25426. spamassassin: 3.4.2. Clear:RC:0(155.133.131.76):SA:0(-1.9/5.0):. Processed in 2.879455 secs); 24 Apr 2019 12:32:26 -0000 X-Envelope-From: vincent@vinc17.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at vinc17.net does not designate permitted sender hosts) Date: Wed, 24 Apr 2019 14:31:44 +0200 From: Vincent Lefevre To: zsh-users@zsh.org Subject: Re: print builtin preceded by parameter assignment Message-ID: <20190424123144.GA21402@zira.vinc17.org> Mail-Followup-To: zsh-users@zsh.org References: <20190410125557.GA19114@cventin.lip.ens-lyon.fr> <1554902053.6252.6.camel@samsung.com> <20190410141113.GD15169@cventin.lip.ens-lyon.fr> <1554907186.6252.12.camel@samsung.com> <20190411104040.GA29775@cventin.lip.ens-lyon.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/1.11.4+184 (e1bc4339) vl-117499 (2019-04-23) On 2019-04-11 14:42:08 -0700, Bart Schaefer wrote: > The trick is to mark TZ exported before you try to use it as a prefix > assignment. > > % echo $+TZ > 0 > % export TZ > % echo $+TZ > 1 > % print -P "%D{%c %Z}" > Thu Apr 11 14:27:39 2019 PDT > % TZ=UTC print -P "%D{%c %Z}" > Thu Apr 11 21:27:58 2019 UTC This is even more confusing: the "export" status should not have an effect in a variable assignment before a command (in particular, a builtin). Actually there is another inconsistency without the "export": zira% echo $+TZ $+LC_ALL 0 0 zira% print -P "%D{%c %Z}" Wed Apr 24 14:19:39 2019 CEST zira% TZ=UTC0 LC_ALL=fr_FR.utf8 print -P "%D{%c %Z}" mer. 24 avril 2019 14:19:50 CEST CEST Following the (IMHO, invalid) justification for TZ not being taken into account with a builtin, the LC_ALL assignment should have also been ignored. But this is not the case. Ditto for CDPATH: zira% printenv CDPATH zira% cd home cd: no such file or directory: home zira% CDPATH=/ cd home /home > Here's a semi-related oddity -- once the timezone is changed, it does > not change back, even though the TZ variable is not set: > > % echo $TZ > > % date > Thu Apr 11 21:28:18 UTC 2019 > > Oops, the timezone remains UTC even though the variable is no longer > set. This has to be a side-effect of calling localtime() in > promptexpand(). This is even worse. [...] > So the "bug" if there is one is that variables that aren't marked for > export don't magically become exported when used before a builtin in a > prefix assignment. There are several bugs (perhaps all related): 1. The fact that TZ remains exported with a value different from $TZ. 2. The fact that TZ and other variables (at least LC_ALL and CDPATH) are handled differently with a variable assignment before a builtin, when not exported. 3. The fact that for TZ, the "export" status has an effect on the value taken into account in a builtin. IMHO, for (2), the best solution would be to fix (2) to follow the behavior of LC_ALL/CDPATH/... (which would correspond to my original request). And this would make (3) pointless. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)