Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15163 > unrolled thread

printf builtin retains timezone from un-set TZ environment variable

Started byTravis Everett <travis.a.everett@gmail.com>
First post2019-07-13 12:31 -0500
Last post2019-07-13 12:31 -0500
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  printf builtin retains timezone from un-set TZ environment variable Travis Everett <travis.a.everett@gmail.com> - 2019-07-13 12:31 -0500

#15163 — printf builtin retains timezone from un-set TZ environment variable

FromTravis Everett <travis.a.everett@gmail.com>
Date2019-07-13 12:31 -0500
Subjectprintf builtin retains timezone from un-set TZ environment variable
Message-ID<mailman.1214.1563051807.2688.bug-bash@gnu.org>
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: darwin17.7.0
Compiler: clang
Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security
uname output: Darwin f638f97d 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr
25 23:16:27 PD$
Machine Type: x86_64-apple-darwin17.7.0

Bash Version: 5.0
Patch Level: 7
Release Status: release

*Description:*
I've noticed that a timezone explicitly set in the TZ environment variable
can get cached (if any date-using command/builtin is run) and then show up
(at least) in dates produced by the printf builtin's "%(...)T" formats even
after the TZ variable is unset.

I played around with this for a bit and identified two ways to get the
timezone to re-set:

   - Run an external command. I have yet to find an external command that
   didn't correct it, so I suspect this behavior is intrinsic to the API calls
   made when running an external command. It's also possible I'm too
   unimaginative to find an external command that *doesn't* invoke date APIs
   :).
   - Set the TZ variable inline and run any builtin (i.e.,
   `TZ=:/etc/localtime :`).


*Repeat-By:*
---- tzcache.sh ----
echo $BASH_VERSION
export TZ=Antarctica/South_Pole
printf "TZ: $TZ\n\t%(%+)T\n"
unset TZ

# still prints the now-unset timezone
printf "TZ: $TZ\n\t%(%+)T\n"

# to reset it
# run any external command
# or any builtin with an inline TZ setting
TZ=:/etc/localtime :
printf "TZ: $TZ\n\t%(%+)T\n"
--------------------

$ env -i $(which bash) --norc --noprofile tzcache.sh
5.0.7(1)-release
TZ: Antarctica/South_Pole
Sun Jul 14 05:21:49 NZST 2019
TZ:
Sun Jul 14 05:21:49 NZST 2019
TZ:
Sat Jul 13 12:21:49 CDT 2019


Cheers,
Travis

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web