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

Re: print builtin preceded by parameter assignment



On 2019-04-10 10:25:18 -0700, Bart Schaefer wrote:
> For what it's worth, Bash seems to (mostly) agree with the zsh
> interpretation.  If I set HISTTIMEFORMAT to something containing %Z
> and then run "TZ=UTC history" I get timestamps in the local timezone,
> not in UTC.  If I first export TZ=UTC and then run history, I get
> timestamps in UTC.

Your test seems incorrect.

$ HISTTIMEFORMAT=%Z
$ history
    1  CESTps
[...]
$ TZ=UTC history
    1  UTCps
[...]

This is with:

GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.

Ditto with:

GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.

Adding the --posix option doesn't change the behavior related to
the output timezone.

> *However*, if I run "HISTTIMEFORMAT='%r ' history" the change takes
> place for the builtin and I get the different format.

Ditto here.

> So it seems to matter whether the variable itself is "known" to
> Bash, or something.

At least I get a consistent behavior. This suggests something
wrong with your test of TZ.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



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