fix(printf): %(fmt)T timezone, empty/invalid/nested formats, LC_TIME - #689
Merged
Conversation
The %(DATEFMT)T branch diverged from bash in six ways (issue #688), the entire remaining printf.tests diff: - TZ: bash's sv_tz hands the shell's EXPORTED TZ to libc (setenv + tzset) before every localtime, so `export TZ=EST5EDT' -- or `unset TZ' -- mid-script takes effect. An unexported TZ assignment deliberately does NOT (verified against bash). - an empty DATEFMT formats with %X, the locale's time - a spec that is not `)T' warns ``C': invalid time format specification' (a NUL byte when the format ran out), prints the `%' literally and rescans the rest as text, status unchanged - the closing paren is found by BALANCED scan: `%((%Y))T' -> `(1969)' - the seconds argument is validated like %d's (getintmax): `foo' diagnoses `invalid number' and formats 0, status 1; a missing argument still means -1 (current time); '/" char-codes work - apply_ctype_locale gains LC_TIME, so `LC_ALL=C' makes %(%x)T print 05/30/10 rather than the startup locale's date format printf.tests scoreboard 19 -> 0: gnash's printf output is now byte-identical to bash 5.3.15 across the entire suite (verified with the diff -a scoreboard; the earlier "0" was the binary-diff false zero). builtins/errors/varenv/quote/new-exp/heredoc/redir/intl all hold at 0. Closes #688
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #688 — the
%(DATEFMT)Tbranch's six divergences, which were the entire remaining printf.tests diff:sv_tzhands the shell's exported TZ to libc (setenv+tzset) before everylocaltime, soexport TZ=EST5EDTorunset TZmid-script takes effect; an unexported TZ assignment deliberately does not (matches bash, verified).DATEFMT→%X(locale time))TwarnsC': invalid time format specification(NUL byte when the format ran out), prints%literally and rescans the rest as text, exit status unchanged%((%Y))T→(1969)%d's (foo→invalid number, formats 0, exit 1; missing argument still means −1/current time; char-codes work)apply_ctype_localegains LC_TIME, soLC_ALL=Cmakes%(%x)Tprint05/30/10Verification
14-case matrix byte-identical vs reference bash 5.3.15 (all TZ scenarios incl. temp-env and unexported, warnings, nested parens, width, validation, format reuse). printf.tests scoreboard 19 → 0 — gnash printf output is now byte-identical to bash across the whole suite (real
diff -azero, unlike the earlier false zero). builtins/errors/varenv/quote/new-exp/heredoc/redir/intl all hold at 0; smoke passes.Closes #688
🤖 Generated with Claude Code