Repository navigation
fix(history): entries added before HISTTIMEFORMAT carry no stamp (rubash#3392) - #3757
Merged
Merged
Conversation
…ash#3392) GNU stamps an entry at creation from history_comment_char (lib/readline/history.c hist_inittime): the stamp's first char IS the comment char, '\0' while no HISTTIMEFORMAT bind has armed it, so an unarmed entry renders '??' and history -a/-w write no '#<epoch>' line for it. SessionHistory::record() stamped every add with the wall clock unconditionally; it now takes the live comment-char latch (sticky arming, or HISTTIMEFORMAT existing right now) from its callers - history -s, the reader recording paths, and fc re-execution - and stores the empty stamp while unarmed.
Member
|
Thanks for the PR, @arookieofc-ai — and for the GNU-oracle notes (readline First pass from intake (not a merge review):
|
Member
|
【WIN-AGENT-AUDIT】s2 PR #3757 第1轮 — 建议:PASS(已合并 109ab51) 机制核查:
腿:
F 点:无 合并:109ab513b0f273f8711900514d258c46b636cea3(squash,未删分支) |
This was referenced Nov 16, 2026
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.
Root cause
GNU stamps an entry at creation from
history_comment_char(lib/readline/history.chist_inittime): the stamp's first char IS the comment char,'\\0'while no HISTTIMEFORMAT bind has armed it.SessionHistory::record()stamped every add with the wall clock unconditionally, so entries created before HISTTIMEFORMAT was set rendered a real date instead of??, andhistory -a/-wwrote spurious#<epoch>lines for them.Fix
record()takes the live comment-char latch (sticky arming from the first HISTTIMEFORMAT bind, or HISTTIMEFORMAT existing right now —variables.csv_histtimefmt:history_write_timestamps = (v != 0), latch never disarmed) and stores the empty stamp while unarmed. Callers updated:history -s, the reader recording paths (run_history_group,record_stdin_group_if_armed), and fc re-execution. Display (??) and the-a/-wwrite gates already skipped empty stamps.No new API items; the provider-plane stamp ledger is untouched.
Verification (GNU bash 5.2.21 oracle, script files)
history -s 'echo new'; HISTTIMEFORMAT='%F '; history→??echo new(was a real date)-a/-wfor an unarmed entry → 1 line, 0#lines (was 2/1)??, armed dated;-awrites the stamp line only for the armed one (3 lines / 1 hash)unset HISTTIMEFORMAT(once armed) still stamps;-aafter unset writes no stamp lines; emptyHISTTIMEFORMAT=''bind armstests/issue3392_history_unarmed_entries_have_no_stamp.rs: 9/9 green (5 fail-first on baseline)cargo test --lib: 1249 passed, 0 failed; 16 neighbouring history suites (91 tests): all greenFixes #3392.