Repository navigation
fix(history): gate history -r multi-line regrouping on read-time HISTTIMEFORMAT (Refs #3393) - #3537
Merged
Merged
Conversation
…TIMEFORMAT (Refs #3393) GNU lib/readline/histfile.c:384 read_history_range arms history_multiline_entries only when the file starts with a timestamp line AND history_write_timestamps is set (variables.c:6177 sv_histtimefmt: HISTTIMEFORMAT exists). The counter is never reset. rubash regrouped whenever the file had timestamps. Model the sticky counter on SessionHistory and feed it the read-time variable state; the interactive startup load takes the same state instead of a hard-wired armed read. The issue1669 pin chained unarmed reads after an armed one in one process, which only matched the old non-sticky model; GNU 5.3.20 regroups there. Split the unarmed phases into fresh processes. Also rustfmt the d11 stem (master drift from #3511) so the fmt hook passes. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
caomengxuan666
marked this pull request as ready for review
November 14, 2026 04:55
caomengxuan666
marked this pull request as draft
November 14, 2026 05:09
Member
Author
|
【WIN-AGENT-AUDIT】 PR #3537 第1轮 — 建议:PASS 机制核查:
腿:
F 点:无 未跑/VOID 的腿:无(lib base 集复用同 merge-base 实跑结果)。 |
caomengxuan666
marked this pull request as ready for review
November 15, 2026 02:04
caomengxuan666
added a commit
that referenced
this pull request
Nov 15, 2026
…after unset HISTTIMEFORMAT stay armed Refs #3535 ## 根因 GNU 的 `history_comment_char` 武装是粘性的:`variables.c:6168-6177 sv_histtimefmt` 在 HISTTIMEFORMAT 存在时把 `history_comment_char` 置 `'#'`(仅当其为 0),unset 时只清 `history_write_timestamps`,从不复位注释符。rubash 把武装建模为「HISTTIMEFORMAT 当前存在」(各 history 读取面采样 `get_env("HISTTIMEFORMAT").is_some()` 同时充当 write-timestamps 与 comment-char 武装),于是置过又撤掉之后,`history -r` 把 `#<epoch>` 行当普通条目读入、条目带空戳,列表渲染为 `??` 三行,与 GNU 的两行带戳不符。 已合入的 #3537(#3393)只建模了同样粘性的 `history_multiline_entries`,未动注释符武装——本 PR 补这一面。 ## 修法(机制,非个案) - `ShellState` 新增粘性闩 `history_comment_char_armed`(readline `history_comment_char` 进程全局的移植,随 Clone fork 边界传递);`Executor::new` 以进程环境导入的 HISTTIMEFORMAT 播种(GNU 对环境导入变量同样跑 sv_histtimefmt)。 - 赋值面闩定:`execute_command` 每命令边界在 HISTTIMEFORMAT 存在时闩定;临时(前缀)绑定在 `apply_temporary_assignments` 内闩定(其恢复先于命令边界,GNU 探针证实 `HISTTIMEFORMAT='[%Y] ' true` 同样粘性武装)。 - `SessionHistory` 读取面把两个 GNU 状态拆开传参:`comment_char_armed`(粘性,管 `#<digit>` 识别与读时戳,histfile.c:375-383 + history.c hist_inittime)与 `timestamps_armed`(现值 = history_write_timestamps,仅继续管 multiline 重组门,histfile.c:384——粘性不放宽该门,钉 multigate 格守此界)。 ## GNU 锚点 - `variables.c:6168-6177` sv_histtimefmt(武装粘性本体) - `lib/readline/histfile.c:375-383` + `:466`(文件首行戳仅借用本读、读毕复位——不闩定) - `lib/readline/history.c:322-333` hist_inittime(条目戳首字 = 当前 comment char) - `lib/readline/histfile.c:384`(multiline 门 = history_write_timestamps 现值) 期望值全部以 GNU bash 5.3.20 脚本文件实测(repro / 从未武装对照 / 前缀绑定 / 空值绑定 / `history -n` 面 / multiline 门,共 6 形)。 ## 回归钉 `tests/issue3535_history_comment_char_sticky.rs`(6 格):武装后撤除的 `-r` 形、从未武装对照组、前缀绑定、空值绑定、`-n` 面、multiline 门不放宽。 ## 本 PR 删除了什么 无删除。纯增性改动:新增一个 ShellState 布尔闩与其播种/闩定点、读取面签名增加一个参数(仓内 5 个调用点同步更新)、新增钉文件。`src/script_driver.rs`、`src/executor/init.rs` 的改动仅为上述闩的播种与调用点传参。 ## Captain verification (merge round R5, head 84a58c5, base 78060e4) - Pin `issue3535_history_comment_char_sticky`: 6/6 green on the merged shape (fail-first banked at delivery: 4 red / 2 green on base). - Neighbors: issue3393 8/8, issue1669 2/2, both aligned with base. - `RUSTFLAGS="-D warnings" cargo check --locked --lib --bins`: rc=0, zero warnings. `rustfmt --check` on all 9 changed files: rc=0. - Full lib bilateral (head vs base 78060e4, bin-first): 1249/0/4 both sides, failure name-set diff empty. - CI on the R5 head (run 43729056059, head == 84a58c5): 3 failing jobs (Rust tests, Rust tests (macOS), GNU regression goldens and canaries), each failing ONLY on the issue2875 baseline cell (`api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell`); niu-canary success. PASS comment 6894417642 stands. - Intersection (merge-base eaa357f..78060e4 vs the PR's 9 files): exactly 2 files, both released by the captain after personally reading both sides' hunks — `src/executor/command_execute.rs` (tip #3686 @@ -468 and #3690 @@ -600, both in `execute_command_with_procsub_scope`, vs PR @@ -30 in `execute_command`; ~438 / ~570 lines apart, different functions, no text overlap) and `src/executor/temporary_assignments.rs` (tip #3669 @@ -1482 in `apply_shell_assignment` vs PR @@ -186 in `apply_temporary_assignments`; ~1296 lines apart, different functions, no text overlap). Rebase onto 78060e4 was clean, zero conflicts; the rebased diff is byte-identical to the R4 shape except the two base-blob index lines. Tip unmoved after all legs. Refs #3535 (the issue stays open until the captain hand-closes it on this merge).
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.
修了什么
history -r(以及交互启动时的 HISTFILE 载入)读带时间戳的历史文件时,rubash 无条件把无戳行并入上一条目(多行重组)并保留空行。GNU 只在history_multiline_entries已武装时这么做,而一次读只在「文件首行是#<digit>戳行」且「读时 HISTTIMEFORMAT 存在」时才武装它;该计数此后永不复位(history -c、unset HISTTIMEFORMAT 都不清)。SessionHistory新增multiline_entries(粘性),load_file_with_arming以has_timestamps && timestamps_armed(调用方传入的就是 HISTTIMEFORMAT 是否存在)累积它,重组与default_skipblanks都改读它。script_driver.rs的 load_history 面)原来硬编码 armed=true,改为与history -r相同的读时 HISTTIMEFORMAT 状态。删了什么
has_multiline = has_timestamps这一「有戳即重组」的假设。GNU 依据
lib/readline/histfile.c:384read_history_range:history_multiline_entries += has_timestamps && history_write_timestamps;histfile.c:387default_skipblanks = history_multiline_entries == 0;;histfile.c:436-437并入上一条目的分支以history_multiline_entries为条件。histfile.c:126是该变量唯一的其它出现(初始化),无复位点 → 粘性。variables.c:6177sv_histtimefmt:history_write_timestamps = (v != 0)(设为空串也武装)。WSL GNU 5.3.20 实测(脚本文件):格式后设 → 3 条目;无格式 → 3;反斜杠行 → 3;两孤行 → 4;空行无格式 → 跳过;格式先行 → 2(重组,空行保留);先武装再 unset +
history -c后再读 → 仍重组。验证
tests/issue3393_history_read_multiline_gate.rs(8 例,期望取自 GNU 5.3.20):未修树 2 passed / 6 failed(两例对照组「格式先行」「粘性」本就重组),修后 8/8。issue1669_history_timestamp_display_regressions:原钉在同一进程里先做武装读再做「未武装读」,只在旧的非粘性模型下成立;GNU 5.3.20 同一脚本实测 plain.txt 会被重组且带读时戳(注释符武装同样粘性,见 history: comment-char arming is sticky in GNU — reads after unset HISTTIMEFORMAT are still armed #3535)。把两段未武装相拆到独立进程(GNU 独立进程实测正是原期望??形),期望值未改。修后 2/2。common::issue2197_wait_bounded_*两例、interactive_histfile_null_rc_and_append_diag_match_gnu、issue1852_session_path_read_failures_are_silent、history_s_empty_entry_is_written_by_w)在未修树上同样失败(本机环境:交互 pty / 相对路径按进程 cwd 解析 bind -f / history 文件面的相对文件名不锚定会话 cwd(进程 cwd 解析,平名复现) #3090),与本改动无关。tests/d11_pipeline_squote_carrier_regressions.rs仅 rustfmt(master 上 fix(executor): restore DATA_SQUOTE carrier on pipeline child-argv boundaries #3511 遗留的格式漂移,fmt hook 需要)。Owed
history -n(read_new_file)路径未接入多行重组模型(原本就不重组),未做 GNU 对照。Fixes #3393