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=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,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 18dc7089 for ; Thu, 11 Apr 2019 21:43:09 +0000 (UTC) Received: (qmail 14556 invoked by alias); 11 Apr 2019 21:42:56 -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: 23931 Received: (qmail 22962 invoked by uid 1010); 11 Apr 2019 21:42:56 -0000 X-Qmail-Scanner-Diagnostics: from mail-it1-f172.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.1/25412. spamassassin: 3.4.2. Clear:RC:0(209.85.166.172):SA:0(-1.9/5.0):. Processed in 3.186014 secs); 11 Apr 2019 21:42:56 -0000 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.172 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=qmfmHaXlDWR6jCO66PZDbwElqYxqLK0IOG9BZPuxXw4=; b=g39+W7Y7qujxJeJ9APFCJOF/X/CtHRXfNjaoGySlkY0J5vlGjj/MfajfMwAOAAddmf lgQntTyJEmyJcRiKH+MKZO4qWa0E8cbuWIfE9E27futc+s05IWgQjfWTuTGsC///RQ67 5G9M6auV4YP5VDQJMHhn324yLNG1h8SzcuYfViQQKQquCLPmOrKdGdcm4MLHElGBUK+g zkkZTXuSdRTiKA8vxPt8HYEEfpl/DEWucRULwEUl8CVbZ8Qn7HcdM0M7fUqa2hYj0UF1 mx+raOqyXQltrg23aVzBpNwRofJM74ZtScvVp69Q31iV3FH6S1LQhEufyiTNOOZTJbnG myjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=qmfmHaXlDWR6jCO66PZDbwElqYxqLK0IOG9BZPuxXw4=; b=GFmIYuAE/RDiEWSQZjAC3z7GJhqYrsGoUrvBe6eEsqpo6oC4zjYLsV0S/YMezPfA2C R8zKyUt4wK2xq8iYorpmBRH4kd3iOjdvMdtZctUafo2/6yjSqv7BHTGKApnRQkLijAwN apGCRTwHJZ7BoYa0KSX4BqSui1dZS73BrwXIpJx8DCPhQwH+0uVCAXtCrpEq+sEtg/jx i5L/czy6tzcpmoN0LCNv1myYGkC4sofFlvhJe/OgtW6bZj8MBmf/BCaNWlMaF1FDHnhx XB0n3R8Lt6BMnQOwhNMaho8aifL08c2xZWQwKfGHaDa2OxRHQPBkuD0u18k18M0gYek/ NCOQ== X-Gm-Message-State: APjAAAVBrHoEhxHg4aaDH6oJhdez5yS3hTSnLJw03zUZyBfWBXLJY27A PDIq8g/xhdAV6axaA6/PdQNBZYwzxC7Vr7w1HKXHH8t737AAAQ== X-Google-Smtp-Source: APXvYqxNNEQ0zSyA7XZa6sxLfYClevK94Cp3bdIv+e6WFoURcjuvahlDm3rtpnFaSYdv1xvFXuKwCJo25th+7CBeEIc= X-Received: by 2002:a02:bb81:: with SMTP id g1mr37619732jan.49.1555018939881; Thu, 11 Apr 2019 14:42:19 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Bart Schaefer Date: Thu, 11 Apr 2019 14:42:08 -0700 Message-ID: Subject: Re: print builtin preceded by parameter assignment To: Zsh Users Content-Type: text/plain; charset="UTF-8" On Thu, Apr 11, 2019 at 1:58 PM Bart Schaefer wrote: > > The actual takeaway here is that TZ has to be pushed into the actual > environ strings, not just set temporarily as a local to the shell, in > order for the system time libraries to apply it to strftime et al. 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 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(). Explicitly resetting TZ fixes it: % export TZ=PST8PDT % date Thu Apr 11 14:29:25 PDT 2019 Also, once TZ is both marked for export and has a valid value, everything works the way Vincent expects: % TZ=UTC print -P "%D{%c %Z}" Thu Apr 11 21:29:36 2019 UTC % date Thu Apr 11 14:29:43 PDT 2019 % 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. As an aside, TZ is explicitly referenced and manipulated when using zsh/datetime strftime builtin, so it might not suffer from any of these problems. I haven't tested it