Repository navigation
fix(executor): seed compound stdin procsub diagnostics with the ambient line (Refs #3299) - #3482
Conversation
…nt line (Refs #3299) GNU: procsub child parse_and_execute has no SEVAL_RESETLINE, so line_number-- (builtins/evalstring.c:346) and the body diagnostic line is the parent line_number at fork (subst.c:6412 make_child). For compounds, do_redirections (execute_cmd.c:854) runs before the dispatch switch stamps anything, so the parent line is the ambient line; only cm_simple (:936) and cm_subshell (:696) stamp first. Seed compound procsubs from the executor ambient_line cell, falling back to the command end_line then start line (same chain as set_current_line). Simple commands keep the first-element end line (#3210); subshells keep their own line.
|
【WIN-AGENT-AUDIT】 机制核查:
腿(逐项):
F 点:
续作记录:无。 未跑/VOID 的腿:无(CI 未跑钉 stem 一点存疑,已用本地双侧实跑替代)。 |
… with their end line (Refs #3299)
【WIN-AGENT-REWORK】Round 2Both F-points landed and verified at head F1 — group as pipeline element: ambient end-line = last-segment end-line
F2 —
|
fix(executor): re-derive POSIX mode on POSIXLY_CORRECT bind (Refs #3661) GNU `sv_strict_posix` (variables.c:5820, 6257-6266) fires on every bind/unbind of POSIXLY_CORRECT, not only on `set -o posix`. rubash split the two directions: `apply_posix_mode_transition` keeps the `set -o` path's variable binding; new `sync_posix_mode_from_variable` only re-derives the mode and never writes the variable. Hooks sit at every bind/unbind funnel. Written-text keying (expr.c:352, printf.def:112-113): arithmetic-element and printf-element spellings do NOT flip the mode; statement-element and declare/local-element operands DO. Refs #3661 (the #2902 §2 gate: modernish dies rc=128 in capability detection because a runtime `POSIXLY_CORRECT=1` assignment never armed posix mode). #3661 stays open until the captain hand-closes it on this merge; the #2902 re-run is dispatchable after that. ## 本 PR 删除了什么 No product code or files are deleted. The fix commit is +194/−3 across 12 source files (the −3 is the refactored transition body in `options.rs`). The nail-correction commit rewrites the expectations of 4 existing nail cells and the file header's probe summary, per GNU-oracle evidence; no nail cell was removed (one was added: `temp_prefix_special_builtin_persists`). ## Captain verification (merge round R4, head 5e816ac, base 35437c4) - Pin `issue3661_posixly_correct_runtime_hook_regressions`: 21/21 green on the merged shape (fail-first banked at delivery: 17 red / 3 green on base; GNU oracle matrix 25/25 SAME; neighbors 20 stems / 55 cells banked). - `RUSTFLAGS="-D warnings" cargo check --locked --lib --bins`: rc=0, zero warnings. `rustfmt --check` on all 13 changed .rs files: rc=0. - Full lib bilateral banked at delivery: 1249/0/4 both sides, failure name-set diff empty. - CI on the R4 head (run 43723537799, head == 5e816ac): 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 6894681605 stands. - Intersection (merge-base 2e02e90..35437c4 vs the PR's 13 files): exactly the 3 captain-released files — command_prepare.rs (tip #3482, ~3,900 lines apart), temporary_assignments.rs (tip #3683 @@ -827 vs PR @@ -1460, ~600 lines, different functions), variable_state.rs (tip #3667 pure insertions in different functions). Rebase clean, zero conflicts. - Zero-intersection exception for the tip move after R4: the tip moved 35437c4 -> fc1b848 (user merged #3682, Refs #3189) while R4's legs were banked; the increment touches exactly one file, `src/executor/conditional/extglob.rs`, which is not among the PR's 13 files (programmatic intersection: 0). The merged tree is therefore the R4-verified shape plus #3682's file only; no update-branch re-verify round is required. #3682's own CI was captain-named baseline-only (run 43721665167).
根因
procsub 子进程
parse_and_execute不带SEVAL_RESETLINE,故line_number--(builtins/evalstring.c:346),体诊断行 = fork 时父进程的line_number(subst.c:6412make_child)。父进程侧execute_cmd.c:854 do_redirections在 dispatch switch 之前,只有 cm_simple(:936SET_LINE_NUMBER (Simple->line))与 cm_subshell(:696SET_LINE_NUMBER (Subshell->line))在 redirect 展开前自置行号;for/select/case/arith/cond 的自置行都在各自执行函数体内、redirect 之后,对自家 redirect 无效。旧逻辑对非简单命令一律返 start 行(#3297 时明言复合形是另案残差)。关键区分(oracle 实测):ambient ≠ 命令自家 end_line——while 体内 group → 6(while 止行)、if 体内 group → 5、pipeline 内 group → 3、函数体内 group → 1(定义行);一行形 group/while/if/for/select/case/arith/cond/time/
!/coproc → 2,exec/echo→ 1,subshell → 1。GNU 锚点
make_child(fork 继承父line_number)line_number--(无SEVAL_RESETLINE)do_redirections(在 dispatch 之前)、:936 cm_simple、:696 cm_subshell改动
src/executor/command_text.rs:procsub_body_seed_line(cmd)→procsub_body_seed_line(cmd, ambient);简单命令 → 首元素止行(不变,procsub body 内报错行差一行:body 文本行来源面(#1184 族相邻) #3210),subshell →cmd.line(不变),其余 →ambient.or(cmd.end_line).or(cmd.line)(与set_current_line的 ambient 链同式);simple谓词抽为command_is_plain_simple(行为不变)。self.ambient_line.get():command_input_scope.rs:955,1482、read_redirected_fd.rs:40,80、read_io.rs:881、trap_exec.rs:5642、external_setup.rs:1277;另订正read_redirected_fd.rs两处 procsub body 内报错行差一行:body 文本行来源面(#1184 族相邻) #3210 旧注释。tests/issue3299_compound_procsub_body_seed_line.rs(16 格,沿用 procsub body 内报错行差一行:body 文本行来源面(#1184 族相邻) #3210 harness)。本 PR 删除了什么
无删除。仅重构
simple_command_first_word_end_line内的simple谓词为共享函数command_is_plain_simple(同谓词、同语义),其余为新增参数与新增测试文件。UNVERIFIED-BY-CAPTAIN
构建/测试腿尚未跑:
RUSTFLAGS="-D warnings" cargo check --locked --lib --bins、hygiene、cargo fmt、钉 stem(fail-first 与修绿)与 base 全量 lib 对齐均待复核轮(X299)。重点看函数体格(依赖with_ambient_line(body_open_line))与 pipeline 格。已知残差(不在本单修):inline 收集回退process_substitution_output_bytes_timed无种子,仅 spawn 失败时触发;coproc stdin 通路是否经此 7 点待确认;>(...)输出形、select、time前缀有意未入钉。