Skip to content

test: wave-2 pins I2 (Refs #2773 #2774 #2791 #2824) - #3172

Merged
caomengxuan666 merged 1 commit into
masterfrom
test/wave2-pins-i2
Nov 15, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
test/wave2-pins-i2

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

波二「钉先行」车道 I2:四单的回归钉先行落盘,根因与修法设计见车道 REPORT(~/workspace/fix-I2/REPORT.md)。本组修法面被在飞 PR #3110(#3051)占着,现在动修法必撞车;钉是新文件、与产品面零冲突,门一开修法车道按 REPORT 设计当天能动。本 PR 不含任何产品代码。

逐单:

fail-first:全部钉在真基底 f17644d7 上跑,逐格结果记于车道 REPORT。

本 PR 删除了什么:无(纯测试新增)。

caomengxuan666 added a commit that referenced this pull request Nov 11, 2026
…rp (W-I2) (#3239)

driver: read-time set -v echo; job-control diagnostics print shell_pgrp (W-I2)

Fixes #2773
Refs #2774

Wave-2 pin-to-fix lane W-I2 (driver / interactive face). The two pin files are carried verbatim from pin PR #3172 (branch `test/wave2-pins-i2`, head `64209f64`) as the first commit of this branch; that pin PR itself is left for the captain to dispose of.

## Mechanism

Verbose echo (`set -v`): GNU echoes each input line to stderr as it is READ, under the flag state then in effect (flags.c:284 `echo_input_at_read = verbose_flag`; parse.y:2712 prints `shell_input_line`; heredoc secondary lines echo via make_cmd.c:584 `read_secondary_line`). The engine echoed the rendered command at execution time from `Executor::set_current_command`, which split `;`-joined lines per command, dropped comments, re-rendered compound bodies per stage and per iteration, and never echoed comment, blank, or continuation lines.

- New single echo point `script_driver::echo_verbose_input_lines`, called at every real read point: the grouped reader's per-line consumption (`read_next_source_group`), the stdin script reader's per-line read (`run_stdin_script`), and the whole-string read boundaries (the `-c` and Session fast paths, and parse_and_execute strings via `execute_eval_source`).
- New over-admitting routing scan `script_driver::script_may_toggle_verbose` (same family shape as `script_may_set_onecmd`): a text that may toggle verbose mid-read takes the grouped reader on the script-file, `-c`, and Session routes; a script file entered with verbose already on takes it too. The fast paths keep a single boundary echo, which is the same answer when the scan shows the entry state holds for every line. The scan only routes; it decides no semantics.
- The execution-time echo arm in `set_current_command` is deleted (see the deletion section below).

Job-control diagnostics: GNU prints `shell_pgrp` — jobs.c:4737 `shell_pgrp = getpgid (0)` at `initialize_job_control` entry, reported by jobs.c:4844/4853. Both establishment print sites printed the shell's pid instead; they now share `script_driver::shell_process_group_id()`. The monitor-mode establishment itself was already correct (the second pin is a regression lock, green before and after).

## GNU anchors

- flags.c:284; parse.y:2712; make_cmd.c:584
- jobs.c:4731-4869 (4737, 4844, 4853, 4858, 4869); shell.c:1969
- All behavioral claims probed against GNU bash 5.3.20 (vendored oracle): `-c` strings read line by line like files (mid-string toggles start/stop the echo), heredoc body and delimiter lines echo, sourced-file lines echo with the toggle persisting after return, stdin scripts echo per line read, and the job-control diagnostic names the inherited process group when pid != pgid.

## Verification (captain review, local re-runs of the lane's box numbers)

- Fail-first on the true merge-base `e1afd25d` with the two pin files topped up: verbose stem **1 passed / 7 failed**, the seven reds exactly the registered defect cells (sole green = the toggle cell); job-control stem 4 passed / 0 failed (regression lock).
- Head `b613ba41`: verbose stem **8 passed / 0 failed**; job-control stem **4 passed / 0 failed** (scrubbed and plain-cargo routes agree).
- Neighbor stems all green, 40 tests: case_command_head_bash_command_regressions 4, heredoc_regressions 3, issue1016_1072_1073_1254_1255_history_interactive_regressions 7, issue1040_ps4_xtrace_regressions 2, issue1102_exec_stdin_regressions 1, issue1252_interactive_defaults_regressions 3, issue1476_lastpipe_monitor_regressions 1, issue1494_jobs_refresh_regressions 2 (+1 pre-existing ignored residual cell), issue1563_eval_source_errexit_frame_regressions 13, issue1573_stdin_conditional_group_regressions 4.
- Lib tests bilateral: head 1243 passed / 0 failed / 4 ignored; base 1243 passed / 0 failed / 4 ignored; failure-name sets empty on both sides, diff ∅.
- `RUSTFLAGS="-D warnings"` on product code (`--lib --bins`, flag loading proven by touch + `-v`, 40 flagged rustc invocations): rc=0. The `--all-targets` form fails only on pre-existing dead-code cells in test files this branch does not touch (issue2634 on the head tree, issue2702 on the base tree — cargo stops at the first failing test target per tree, so the two runs surface different members of the same pre-existing family).
- `cargo fmt --check` full tree: rc=0. UTF-8 boundary hygiene: clean. Marker-lint: OK (marker face untouched).
- Cross-target: `cargo check --tests --target armv7-linux-androideabi` (NDK r26d recipe) rc=0; the head's pushed CI is fully green including the darwin and android cross-target legs (11 check-runs: 10 success, 1 skipped, 0 red).
- Binary probe on the head build with pid != pgid (inner shell pid 49842, its process group 49841): the diagnostic prints **49841**, the process-group number, not the pid.

## Collision notes for sequencing

This branch and PR #3238 (still open) both touch `src/executor/trap_exec.rs` in the same function (`execute_eval_source`): this branch adds the read-boundary echo at the function head (base lines ~1091-1097); #3238 wraps the inner call further down (base lines ~1116-1134). The hunks share no line, but a three-way merge after a master advance must be hand-read, and whichever of the two PRs merges second must, after its update-branch, re-run the other PR's pin stem on the merged tree in addition to its own (issue2824 stem if #3238 lands second; issue2773/issue2774 stems if this branch lands second).

## 本 PR 删除了什么

- The execution-time verbose echo arm in `Executor::set_current_command` (`src/executor/public_accessors.rs`): the `if shell_option_enabled(..., "verbose")` block that wrote the rendered `bash_command_source_text(cmd)` to stderr, together with its comment block (14 lines). The `$BASH_COMMAND` bookkeeping that shares the preamble is kept; only the echo is gone, replaced by a comment pointing at the read points.
- Nothing else is deleted. The two job-control print sites keep their lines; only the printed value expression changes from the pid to the shared process-group helper.
caomengxuan666 added a commit that referenced this pull request Nov 11, 2026
…2824) (#3238)

Fixes #2824
Refs #3093

## 本 PR 的内容

三颗提交:先钉、再修、队长复核返工一颗。

- `95eb566f` test: W-HIST regression pins for the script history / DEBUG trap order faces
- `e7c24ca2` the engine change described below
- `dbc04a12` history -p: restore the ungated delete (captain-review rework)

## 机制与 GNU 依据

GNU 的两个历史删除并不对称:

- `push_history`(`history -s`)的删除只在 `remember_on_history` 为真时
  才发生(builtins/history.def:435-439,删除条件活支;删除成功返 1 ——
  bashhist.c:361 `bash_delete_histent` —— `== 0` 只是删除失败时的
  bail-out,成功后照常走追加)。
- `expand_and_print_history`(`history -p`)的删除在其函数头部
  (builtins/history.def:462),条件只有
  `hist_last_line_pushed == 0 && hist_last_line_added`,
  **不带 `remember_on_history` 门**。

trap 动作经 `parse_and_execute` 以 `SEVAL_NOHIST` 运行
(trap.c:494 / trap.c:1069 / trap.c:1195),PROMPT_COMMAND 同样以 NOHIST 运行
(eval.c:305);`SEVAL_NOHIST` 在单元期间落为 `bash_history_disable()`
(builtins/evalstring.c:291-292;bashhist.c:297-302),由 unwind-protect 恢复。
因此在任何 trap 动作或 eval 单元内:`-s` 只追加、永不弹出;
`-p` 则照常弹出外层记录行(其删除本就无门)。

rubash 原先只以 `set -o history` 选项作为 `-s` 的弹出门:脚本最后一行被
记录后,EXIT trap 里的 `-s` 把 `trap ... EXIT` 那一行本身弹掉了;同一
错误弹出还可从 DEBUG/ERR/RETURN/信号 trap 动作、eval 族单元与
PROMPT_COMMAND 到达。

修法(按机制,不按个案):

- `history_exec` 的 Save(`-s`)臂弹出门为 `history_remembering()`:
  选项开启 **且** 当前无 SEVAL_NOHIST 窗口——任一 `*_trap_running` 标志、
  PROMPT_COMMAND 的 nohist env 标记、或新的 eval 单元深度计数,任一存在即不弹。
- Print(`-p`)臂维持基底的纯选项门:其删除在 GNU 侧本就无
  remember 门(history.def:462),并门会使 `eval 'history -p …'`
  不再弹出 eval 行——那正是基底做对、初版做错的一格(返工提交
  `dbc04a12` 恢复,并订正了初版关于「-p 同门(:462-463)」的引文误植)。
- `Executor::nohist_parse_depth` 在 `execute_eval_source` 期间递增
  (evalstring 单元的 rubash 漏斗);fork 副本从 0 起,如同新的 GNU 镜像。
- reader 层的同行合法弹出不变:那里没有 NOHIST 窗口打开,
  钉中的同行锁测试保持绿(见验证)。

返工新增三格钉(issue2824 茎内):eval 内 `-p` 弹出 eval 行(列表面)、
eval 内 `-s` 追加且 eval 行保留(列表面)、EXIT trap 内 `-p` 弹出
trap 定义行(保存文件面)。三格期望均以 GNU bash 5.3.20 脚本文件形实测
定版。

## 关于第二颗钉(独立二进制面)

该钉在基底 `beab07dc` 上实测全绿(PTY 三格 + 脚本形一格,4/4),
与 wave-2 MANIFEST 预登记口径相符:独立二进制面无此缺陷,
缺陷面在宿主/API 层(niubash REPL 驱动 Session 契约的顺序)。
本 PR 对该面不做引擎改动,钉子作为独立二进制的回归锁随 PR 落地;
宿主层的后续工作已回报队长另行派发。

## 钉子重复说明(合并前必读)

本 PR 的两个钉文件与在飞的钉 PR 存在同名副本:

- `tests/issue2824_script_history_records_trap_line.rs` 亦在 PR #3172
- `tests/issue3093_debug_trap_history_order.rs` 亦在 PR #3166

返工提交 `dbc04a12` 在 issue2824 钉文件上追加三格,该文件与上述两 PR
所携版本自此分岔(issue3093 钉未动、仍逐字节相同)。合入处置以队长
卷宗 §12 第 5 条为准:钉 PR 先合则本 PR 丢弃钉提交 `95eb566f` 后重放
返工增量、合并后核 2824 茎为 8 格;本 PR 先合则 #3172/#3166 侧在各自
合入轮丢弃自带副本。

## 验证(逐茎 test result 行)

基底 `beab07dc` fail-first(Simular box,plain cargo test;新钉 top-up):

- issue2824 stem(8 格版):4 passed / 4 failed —— 红名恰原三缺陷格
  (EXIT trap 内 `-s` 吃 trap 行、吃后续 source 行、history 启用前定义
  的 trap 被记录/被弹)+ eval-`-s` 格(基底把 eval 行弹掉)
- issue3093 stem:4 passed / 0 failed(基底即绿,回归锁)

返工前头 `e7c24ca2`(同钉):6 passed / 2 failed —— 红名恰 eval-`-p` 格
与 EXIT-trap-`-p` 格(初版把 `-p` 也并入 NOHIST 门的过门缺陷,
队长复核 §5 坐实为对基底的回归)。

返工头 `dbc04a12`:

- issue2824 stem:8 passed / 0 failed;issue3093 stem:4 passed / 0 failed;
  issue1627 邻茎 1 passed / 0 failed
- lib 双边(两树均先建 `--bin rubash`):双边 1207 passed / 0 failed /
  4 ignored,失败名集差 ∅
- 邻茎 23 茎(初版复核):22 茎全绿;issue2352 一茎 5 passed / 3 failed
  但基底同名三红(基底既存信号时序格,非本 PR 回归)
- fmt `--check` / `RUSTFLAGS="-D warnings"` check(带旗 rustc 调用计数
  已验、warning 0)/ `cargo check --tests` / UTF-8 全树 / marker-lint:
  全 rc=0
- 三方探针(GNU oracle 5.3.20 / 基底 / 返工头,脚本文件同形):
  G1(保存文件面)/ G2 / G3 / G4 + lg1 / lg2 / lg3 + w3 / w5 九形,
  返工头与 GNU 逐字一致;其中 G3 经小集复核以同一构造五种调用形
  (脚本文件 / stdin / -i / PTY / 变体)定谳:GNU 在全部形中保留
  eval 行,返工头逐形一致
- 新头 CI:11 个 check-runs = 10 success + 1 skipped,零红

GNU oracle 注记:本沙箱内 oracle 的 `history -w` 写文件面异常
(rc=1、0 字节文件),故 GNU 侧核对以会话内 `history` 列表面与
EXIT 保存文件面为准;语义依据以上述 C 源码为准。

## 本 PR 删除了什么

- 无文件删除、无测试删除(返工只在 issue2824 钉文件追加三格)。
- 初版删除的是 `history_exec` 中 Save/Print 两臂各自内联的旧弹出判定,
  由 `history_remembering()` 辅助判定取代;返工后 Print 臂恢复为与基底
  相同的纯选项门判定(内联),Save 臂保留 `history_remembering()`;
  净行数以最终 diff 为准。
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3172 第1轮 — 建议:PASS
head: 64209f6 base(merge-base): f17644d 文件: 4 个 +679/-0
关联 issue: #2773(CLOSED)、#2774(CLOSED)、#2791(CLOSED)、#2824(CLOSED,我核过的时间:2026-11-15 本地)

机制核查:

腿(逐项给数字与名字):

  • 钉自跑(PR head = merge-base f17644d 产品代码,Windows):issue2773_set_v_read_time_echo 1 passed / 7 failed(仅 verbose_state_toggles_feed_the_next_lines_read 过——单命令/行形状下逐命令回显与逐行回显巧合一致,非平凡锁);issue2824_script_history_records_trap_line 2 passed / 3 failed(lock、control 过);issue2774_interactive_no_tty_job_control 与 issue2791_diagnostic_prefix_argv0 均 #![cfg(target_os="linux")]/#![cfg(unix)],Windows 上 running 0 tests——本机不可执行,期望值已用 WSL oracle 核(见下),Linux 侧执行留队长/CI 复核。
  • 红因核实:2773 = rubash 在 -c 串内 set -v 后仍对 echo post 逐命令回显(GNU 整串预读零回显);2824 = trap 的 history -s 把 trap 定义行吃掉(saved hist 缺 trap 'history -s …' EXIT 行,GNU 保留)。
  • fail-first:钉先行 PR,base 上红因与 issue 语义一致;即绿格为对照/回归锁。
  • master 现状复核(origin/master @61712935,四钉文件检入实跑):2773 stem 8/8 全绿(fix 401407e driver: read-time set -v echo; job-control diagnostics print shell_pgrp (W-I2) #3239);2824 stem 5/5 全绿(fix 6888e14 history -s inside a SEVAL_NOHIST unit appends without popping (Refs #2824) #3238);2774/2791 仍 0 tests(平台门控)。四 issue 均已 CLOSED,修复均不在本 PR merge-base 内——与 test: wave-2 pins V1 (Refs #2655 #2657) #3168 同型「钉先行被抢跑」,rebase 后可跑格全绿。
  • lib 双边:diff 仅 tests/(已核 git diff --name-only 无 src//Cargo.*),lib 与 merge-base 等同;沿用同机同代码 lib 实测(1297p/12f 全为环境/基线,见 test: wave-2 pins V1 (Refs #2655 #2657) #3168 报告),本 PR 账 = 0。
  • -D warnings:RUSTFLAGS="-D warnings" cargo check --test <四stem> 干净(0 警告)。
  • 卫生:rustfmt --check 四文件 rc=0;marker-lint OK;utf8-hygiene clean(同树)。
  • CI:gh pr checks 全绿。新 stem 均不在 CI lane(--lib + 列名 target),无门禁——钉批共性。
  • GNU 对照:WSL bash = GNU bash 5.3.20(1)-release。2773 八格脚本全部落盘实测(target/probe-pr3172/probe2773.sh + gnu2773/ 结果),stdout/stderr/rc 与钉期望逐字节全符(含 -c 零回显、-vc 整串一次、续行逐物理行、注释/空行回显、toggle 链);2824 五格落盘实测(probe-pr3172/run2824.sh + gnu2824/),hist 行集与钉期望逐条符(HISTFILE 路径为动态值,行集一致);2774 四格以 setsid bash -i(脚本 probe2774.sh,无 ctty + 管道 stdin)实测:hiBHs(含 hiBH、无 m)、cannot set terminal process group (-1): Inappropriate ioctl for device + no job control in this shell、-i -m 同形、非交互 hBs 静默——与钉断言一致(pgrp 数归一化、末位 s/c 字母钉已声明只核 hiBH 核心);2791 抽查 5 形(exec -a zimsh 强制 argv[0]):pwd -z/alias/exit abc/readonly PWD/脚本形 probe.sh: 前缀与钉期望逐字符。平台注记:2774/2791 的期望核自 WSL Linux oracle,机制(tcsetpgrp ENOTTY、argv[0] 前缀解析)平台无关,但最终执行验证待 Linux 侧(本机 Windows 跑不了 cfg 门控)。

F 点:无。

续作记录:本轮未动代码(纯审核)。

未跑/VOID 的腿:2774/2791 两 stem 的实际执行(cfg 平台门控,本机 Windows 无法运行;期望已 oracle 核,执行面留 Linux/队长复核);lib base 侧单独重跑(空 src diff 等价论证)。

补充给队长的裁量点:同 #3168——base 早于修复落地,合入前建议 rebase;rebase 后可跑钉全绿,cfg 门控两 stem 需 Linux 侧首跑确认。

@caomengxuan666
caomengxuan666 merged commit 10c61c3 into master Nov 15, 2026
8 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant