Skip to content

fix7 history-eng: history -p rc (#1627), HISTFILE unset text/rc (#1633), untimestamped entries read-time (#1628), stdin non-recording (#1629) - #1670

Merged
caomengxuan666 merged 4 commits into
masterfrom
fix7/slice-history-eng
Oct 26, 2026
Merged

caomengxuan666 merged 4 commits into
masterfrom
fix7/slice-history-eng

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

fix7 history-eng 片:history 内建四条 GNU 对齐修复

基线 master 6bedad97(含 perf-arrays #1615),cherry-pick 簇分支 fix7/history-eng 的 4 个提交,零冲突。

Fixes #1627
Fixes #1628
Fixes #1629
Fixes #1633

逐条

全部期望先经 GNU bash 5.3.20 oracle 脚本复现、再对照修复前二进制确认 bug 在位后才动手。

簇侧验证(基线 d15a02d)

  • 新回归 6 例 + 相邻历史套件 11 例(issue1289/issue1288/issue1071/issue1016 系列/script_driver_history_in),9 个 harness 全绿。
  • lib --skip login_posix_env 与 pristine d15a02d 同集(770/1/1,唯一失败为允许项 ownership_unary_operators_check_existing_file)。
  • 改动文件 rustfmt 干净、CR 0、src/lexer/continuation.rs 未碰。

集成验证(待回填)

集成树(master 6bedad9 + 本片 4 提交)验证进行中,结果将以评论回填:① 9 个历史 harness 定向;② lib 全量与当前 master 基线同集判据;③ diffcorpus 306 差分(本树不含 #1609 修复,期望稳定失败集 {gl08, ms10});④ rustfmt/CR/continuation.rs 复核。

已知残留(已另行立案 #1668/#1669,不在本片范围):损坏时间戳显示回退、stdin 模式 set -o history 后仍不记录后续行。

GNU builtins/history.def:457 expand_and_print_history() processes
every operand in order, prints the successful expansions, and turns
the overall result into EXECUTION_FAILURE when any history_expand
call returns < 0. The Print arm printed the diagnostic and continued,
then fell through to Ok(0), so `history -p '!999'` exited 0.
Track any failure and return Ok(1) after the loop.

Verified against GNU bash 5.3.20 (script file): mixed good/bad
operands print the good ones and exit 1; `!999` and `^a^b^` failures
exit 1; all-good and no-operand forms exit 0.

Regression: tests/issue1627_history_print_rc_regressions.rs

Fixes rubash#1627
GNU builtins/history.def:273 takes the -a/-n/-r/-w filename from the
operand or $HISTFILE; :280-282 reports a null filename by source —
"HISTFILE: parameter null or not set" when it came from $HISTFILE
(unset or empty), "empty filename" for an explicitly empty operand —
with EXECUTION_FAILURE in a non-interactive shell. The shared file
branch printed "filename not specified" and returned 2 for the unset
case, and the host-provider path in execute_history had the same
wrong wording. Both now follow GNU; the explicitly empty operand
gets its own diagnostic.

Verified against GNU bash 5.3.20 (script file): all four modes x
{unset, set-but-empty, empty operand}.

Regression: tests/issue1633_history_histfile_unset_regressions.rs

Fixes rubash#1633
Entries read from a history file without a `#<epoch>` line got an
empty stamp, which the HISTTIMEFORMAT display rendered as epoch 0
(1970-01-01). GNU's histfile read path adds entries through
add_history, and lib/readline/history.c:322 hist_inittime() stamps
every added entry with the current time; a `#<epoch>` line overrides
it for the following entry via histfile.c add_history_time().

load_file and read_new_file now push Self::now_stamp() when no saved
timestamp precedes the line (record() uses the same helper). Verified
against GNU bash 5.3.20: untimestamped lines display the read time,
a `#1700000000` line still wins for its entry.

Regression: tests/issue1628_history_read_timestamp_regressions.rs

Fixes rubash#1628
run_stdin_script recorded every completed input group into the
session history unconditionally. GNU gates recording on
remember_on_history (bashhist.c:91, default 0; applied at
bashhist.c:642-643 in pre_process_line) — the `history` set option,
off by default in a non-interactive shell. Lines read from stdin now
record only when __RUBASH_SETOPT_history is "1", the same gate the
grouped reader and the exit-time save already use, so `history -s`
entries still appear but input lines no longer enter the list.

Verified against GNU bash 5.3.20 (piped stdin): the seed form lists
only the -s entry; lines after a first history builtin stay
unrecorded; `set -o history` mid-stream records only later lines.

Regression: tests/issue1629_stdin_history_recording_regressions.rs

Fixes rubash#1629
@caomengxuan666

Copy link
Copy Markdown
Member Author

集成验证结果(master 6bedad9 + 本片 4 提交,树 tip a3c55bf)

全部 cargo 经构建槽位、JOBS=1/debuginfo=0/净化环境。cargo build --locked 先行通过(rc=0)。

门 结果
① 历史 harness 定向(10 文件) ✅ 28/28 全过 — 新回归:issue1627(1)、issue1628(1)、issue1629(3)、issue1633(1);相邻:issue1289(1)、issue1288(1)、issue1071(2)、issue1016 系列(5+1)、script_driver_history_in(12)
② lib 全量 --skip login_posix_env ✅ 771 passed / 1 failed / 1 ignored,唯一失败 ownership_unary_operators_check_existing_file = master 基线允许项,与 6bedad9 纯净基线同集
③ diffcorpus 306 差分 ✅ 303 PASS;失败 = 稳定集 {gl08, ms10}(本树不含 #1609 修复,符合预期)+ bi08(隔离复跑 3 次 2 过,分歧为 read -t 0 就绪竞态,计时 flake 裁定)→ 有效失败集 {gl08, ms10}
④ rustfmt / CR / continuation.rs ✅ 新增 4 个测试文件 rustfmt 全干净;4 个 src 文件的整文件 --check diff 与 pristine 基线的要求重写行集完全一致(存量漂移),本片新增行被要求重写者 = 0;CR = 0;src/lexer/continuation.rs 零 diff

四门全绿,可合并。合并时请留意:四条 issue 各有独立 Fixes # 行(正文已按逐条书写)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment