A data point, obtained from a build of the time zone package as distributed: Script started on 2024-12-08 22:23:57+00:00 [TERM="xterm-256color" TTY="/dev/tty1" COLUMNS="82" LINES="30"] $ export TZ=America/New_York $ ./date Sun Dec 8 17:24:32 EST 2024 $ export TZ=Etc/Unknown $ ./date Sun Dec 8 22:24:55 UTC 2024 $ exit exit Script done on 2024-12-08 22:24:57+00:00 [COMMAND_EXIT_CODE="0"] I could make an argument for: with TZ set to Etc/Unknown (or any other unfathomable value), some obnoxiously wrong results are best seen; a time zone abbreviation of ERR has been suggested as a possibility in the past. Side note, brought to mind by /etc/tty and /dev/tty: if TZ is "-", should the time zone information be read from the standard input? :-) @dashdashado On Sun, Dec 8, 2024 at 5:07 PM Brian Inglis via tz <tz@iana.org> wrote:
On 2024-12-08 14:41, Paul Eggert via tz wrote:
On 2024-12-08 13:21, Guy Harris wrote:
(And, unfortunately, there's also no way to indicate "well, we*do* have a file for that tzid, but it's not a valid file" - e.g., tzh_timecnt specifies more transition times than are in the file - in a way that it can be distinguished from "we don't have a file for that tzid.)
Although POSIX provides no way to do that, tzcode does because tzalloc sets errno on failure and zdump uses strerror to tell the user. For example:
$ zdump No/Such/Zone zdump: unknown timezone 'No/Such/Zone': No such file or directory $ zdump zone.tab zdump: unknown timezone 'zone.tab': Invalid argument $ zdump . zdump: unknown timezone '.': Is a directory
(For extra credit, try 'zdump /etc/tty'. Maybe we should disallow that sort of thing....)
Disallowing these would also likely disallow variations on:
$ zdump /usr/share/zoneinfo/.../...
$ zdump <(...)
unless you just check the magic cookie?
-- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada
La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut -- Antoine de Saint-Exupéry