Repository navigation
fix(script_driver): EOF consumed by a compound array assignment exits 1, not 2 (Refs #3899, Refs #3900) - #3903
Merged
Merged
Conversation
… 1, not 2 (Refs #3899, Refs #3900) #3897 split the unmatched-delimiter EOF status by construct and made the generic arm return 2 unconditionally. That is right for word-internal matched pairs, but wrong whenever the failed word read is consumed by parse_compound_assignment's token loop: GNU runs set_exit_status (EXECUTION_FAILURE) after the diagnostic there, so the status stays 1. GNU anchors (bash 5.3 source): - parse.y:7104 parse_compound_assignment token loop; yacc_EOF at parse.y:7151-7152 (parser_error at orig_line_number) - parse.y:7167-7169 set_exit_status (EXECUTION_FAILURE) - parse.y:484-493 `error yacc_EOF' forces EX_BADUSAGE=2 only on a still-zero status - parse.y:6891 report_syntax_error (nested-parse EOF diagnostic at the EOF line, the procsub-element face of #3900) - error.c:324-327 parser_error tail: exit 2 under live errexit The fix consults the delimiter stack's array_list bit (an array-list frame open anywhere in the stack) in the three arms of the unclosed route that returned 2 unconditionally: the generic close-char arm, the `$[` hunt arm, and the extglob arm. With an array list open the status is 1 (2 under live errexit); otherwise the #3897 behavior is unchanged. The diagnostic (closer and line) still belongs to the innermost failed scan in every shape. Oracle matrix (GNU bash 5.3.20, 43 shapes x file/stdin modes): the whole compound-assignment family exits 1 (plain list, declare/list variants, quote/dquote/backquote/comsub/procsub/$[/subscript/${/arith elements, extglob element), errexit variants exit 2, and every non-array word-pair shape keeps 2. Verification (server legs, per-stem test result lines): - fail-first on tip bb27eb2: compat_issue78 filter 6 passed/1 failed; issue551 c6 filter 0 passed/1 failed - fixed: compat_issue78 7/7, issue551 c6 1/1, full issue551 stem 9/9 - #3897 faces unchanged: issue3605_eof_exit_status_word_pairs 4/4, issue1184_f6_backquote_eof_regressions 26/26, plus the adjacent EOF family stems all green - full cli_tests: tip 460 passed/11 failed -> fixed 461 passed/10 failed; the failure-name set difference is exactly the compat_issue78 pin (the remaining 10 are identical environment-bound cells on both trees) - RUSTFLAGS="-D warnings" build clean; rustfmt --check clean What this PR does not change: no lexer edits (continuation.rs untouched), no parser edits, no test edits. The keeps_comsub_case_ subject expectation #3897 aligned was verified GNU-correct by observable behavior (see lane REPORT) and is not touched here.
This was referenced Nov 18, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
…ly exec (Refs #3893) fix(executor): bind {var} heredoc at its list position in redirect-only exec (Refs #3893) Root cause: in `execute_stdio_only_exec_redirect` (src/executor/trap_exec.rs), the walk consumed a `{var}<<` / `{var}<<<` heredoc twin and then called `execute_dynamic_fd_var_redirect`, which has no HereDoc/HereString arm — a pure no-op apart from the readonly check. The real bind happened in the tail loop, after every later entry's undo-save had already claimed its slot (`exec 14<<X {v}<<A 14<<B` gave `v=11`, GNU gives `v=10`). The walk now binds the heredoc at its list position via `execute_dynamic_fd_var_heredoc` and the tail loop binds only twins the walk did not consume. GNU anchors (bash 5.3, redir.c): :237 `do_redirections` single ordered walk; :1065 heredoc/here-string arm, `here_document_to_fd` at :1072; :1082/:1113 REDIR_VARASSIGN F_DUPFD + bind; :1091 later undo-save lands after the var's allocation. Oracle matrix (6 shapes, vendored 5.3.20) all match. Verification (captain-adjudicated, REPORT ~/workspace/fix-3893/REPORT.md): - Pins tests/issue3893_exec_var_heredoc_fd_allocation.rs (6 pins): fail-first 3 red / 3 green on base bb27eb2 (`v=11` vs expected `v=10`), 6/6 green after the fix — on server legs AND on this head's CI census (6/6 PASS). - Adjacent stems green: issue3578 14/14, issue3578-dual 6/6, issue1313 2/2, issue3195 19/19; lib 1280/0; RUSTFLAGS="-D warnings" rc=0; rustfmt clean; marker-literals + utf8-boundary hygiene clean. - Head census total 82 (era band 79–88), net −3 vs tip (85). New cells vs tip: 2× issue3640 (exec-3/4 fd landing) — PROVEN census jitter by captain isolation: the stem passes 7/7 on both the base tree and this head's tree on the server; 1× issue2333 carrier + 1× issue2883 prompt, both on faces this diff cannot reach (flake standard). issue3316 cell still red on the head census — known fixture defect, reopened as #3316, separate lane. - Goldens job: exactly the 2 baseline names. CLI job: exactly the one pre-existing cell (compat_issue78, #3899 — fixed by pending #3903). - Guard: no file collision with open PRs (#3538/#3398 touch script_driver.rs only; #3902 also touches trap_exec.rs but different hunks — it rebases after this merge). 本 PR 删除了什么: - 删除了 `execute_stdio_only_exec_redirect` 里 `{var}` heredoc 只在 tail loop 滞后绑定的旧路径(walk 已消费的 twin 不再走到 tail 绑定)。 - 删除了 fd_var 分支里对 heredoc 条目调用无 HereDoc/HereString 臂的 `execute_dynamic_fd_var_redirect` 所产生的无操作调用(该调用对 heredoc 除只读检查外什么都不做)。 - 未删除任何公开 API、测试或产品行为;funnel 面 `apply_dynamic_fd_var_redirects` 的同类分裂限制未动,已另立 #3906 跟进。 UNVERIFIED-BY-CAPTAIN — captain review: PASS. Merge by captain; #3893 to be hand-closed by the captain after merge (Refs-only body, no auto-close).
…efs #3899, Refs #3900) The close-char scan's top-level `(` arm classified any command-position `(` with a non-empty pending word as an array list (`is_array_list = !is_subshell`). A negation/extglob opener (`!(`, pending word `!`) is not an assignment, so the frame wrongly carried `array_list: true` — and the EOF status split added by the parent commit read it as "a compound array assignment is open", flipping the issue3229 case-position extglob cell from GNU's 2 to 1 (head census on 20677f6; green on the base and on five earlier heads; GNU 5.3.20 probe: `case ab in / !(ab` -> rc 2, line 3). The pending word is an assignment only when it ends in `=` (`name=`, `name+=`); any other command-position word opens a subshell grouping (`array_list: false`, `command: true`, `report_open: false`). Applied in lockstep to the oracle scan (`unclosed_input_close_char_posix`) and its checkpointable mirror (`close_char_residuals_advance`). GNU anchors: parse.y:5658 (read_token_word routes `=` + `(` to parse_compound_assignment); parse.y:7104/7151-7152/7167-7169 (EOF inside the compound-assignment token loop nails status 1); parse.y:5466-5489 (extglob matched-pair scan); parse.y:6892-6901 ("unexpected end of file from `(' command" for a real subshell). Verification (captain, server legs): issue3229 stem 10/10 on the base tree, 9/10 (only unclosed_group_case_position) on the parent commit's tree; after this commit the stem must return 10/10, with compat_issue78 7/7, issue551 9/9 and the 40-shape oracle matrix unchanged (40/43 byte-identical, A14 still open for #3905).
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
…hebang script (Refs #3316) test(issue3316): replace multicall-fragile /bin/echo carrier with a shebang script (Refs #3316) The pin copied /bin/echo to a file named `back\slash` and exec'd it. On hosts where /bin/echo is a multicall coreutils hardlink, the copy is rejected inside the multicall dispatcher (`coreutils: unknown program ''back\slash''`) — the same failure reproduces under GNU bash 5.3.9 with the same fixture and under direct exec with no shell involved. Product behavior matches GNU; the defect is in the nail's fixture, not the exec face. The carrier is now a `#!/bin/sh` script printing its argument (`printf '%s\n' "$1"`); the nail's three intent elements are kept (backslash filename, exec full path, stdout `literal-ok`). Verification (captain-adjudicated, REPORT ~/workspace/fix-3316-nail/REPORT.md): - Fail-first on the base tree: `coreutils: unknown program ''back\slash''` at tests/issue3316_exec_full_pathname.rs:132, byte-identical to the #3885-head census cell. After the fix: single test 3x green, full stem 7/7; GNU 5.3.20 runs the same new fixture to `literal-ok`, rc=0. - Head census (a2ee9d0) total 83 (era band 79-88): the issue3316 cell is green; new cells vs tip are census jitter only (issue2029 x2 flipped between two runs of the same product tree — this PR is test-only; issue2333 carrier family; issue3640 x2 already proven jitter by captain server isolation, 7/7 on both trees). Goldens exactly the 2 baseline names. CLI exactly the 2 pre-existing cells (coproc flake + the #3899 compat_issue78 pin, pending #3903). - Guard: no open PR touches this test file. Product code untouched. 本 PR 删除了什么: - 删除了钉夹具里对 `/bin/echo` 二进制的复制(`fs::copy("/bin/echo", ...)`), 改为写出带 `#!/bin/sh` 的小脚本并 `chmod +x`。 - 未删除任何产品代码、测试用例或钉意图;三要素(反斜杠文件名、exec 全 路径、`literal-ok` 输出)原样保留。 UNVERIFIED-BY-CAPTAIN — captain review: PASS. Merge by captain; #3316 to be hand-closed by the captain after merge (Refs-only body, no auto-close).
caomengxuan666
marked this pull request as ready for review
November 18, 2026 12:35
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
… EOF (Refs #3904) GNU parse.y:5635-5639 admits the P_ARRAYSUB scan only for a pure identifier at a command position (assignment_acceptable) or an element-start [ (token_index == 0 && PST_COMPASSIGN). Inside parse_compound_assignment's token loop (parse.y:7104-7169) the previous element token is a WORD, so a [ after a non-empty word fragment (v=(a[1) is literal word text and EOF falls through to the loop's own ') report (parse.y:7151-7152). The subscript walk's command-position tracking stayed true from input start through the name=( opener, so a[ looked like a command-position identifier and opened a phantom ] hunt. Gate that disjunct on being outside any compound assignment, and treat a newline (or comment-terminating newline) inside the list as an element start, like a space. Nails: tests/issue3904_compassign_subscript_closer.rs (17 diagnostic cases + 3 closed-form guards, GNU 5.3.20/5.3.9 byte-checked). Known follow-ups (not in this commit): the rc-1 assertions need PR #3903's status split (rebase after it merges); the A29 token-error face needs a script_driver.rs arm (guarded by #3903); the continuation.rs subscript mirror needs the same three edits in lockstep (captain-only file) or lib subscript_residual_incremental_tests::incremental_matches_full_randomized stays red.
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
… EOF (Refs #3904) fix(lexer): report compound-assignment ) not ] for a mid-element [ at EOF (Refs #3904) A13 half of #3904: inside a compound assignment, a `[` after a non-empty element word is literal word text (parse.y:5635-5639 P_ARRAYSUB admission needs assignment_acceptable, parse.y:3163; inside the list the preceding element is a WORD), so EOF is reported by parse_compound_assignment's own parser_error as `)` line 1 (parse.y:7151-7152, rc 1 via :7167-7169), not as an unclosed `]`. Element-start `[` still reports `]`; a bare command-position `a[1` still reports `]` rc 2. Two commits: the lane's skip.rs walk fix + regression pin (tests/issue3904_compassign_subscript_closer.rs), and the captain's lockstep mirror in src/lexer/continuation.rs subscript_residuals_advance (REPORT §9: `[` gate gains compassign_depth == 0; comment/whitespace newline arms set element_start = compassign_depth > 0), landed by the captain because continuation.rs is captain-exclusive and the lane's REPORT explicitly handed the mirror back. Captain verification: rebased onto c22017c (post-#3903). Server legs on the merged content: new pin stem 2/2 (rc assertions green with #3903's split), lib randomized mirror tests 3/3, lib full 1280/0, adjacent stems issue3605 x3 + issue1184 f4/f6 green, CLI 460/11 same pre-existing set, RUSTFLAGS="-D warnings" clean. Head CI adjudicated by name: census 78 (era band 79-88; new pin stem green; only new name vs the #3903 head is issue2771 tempenv, unreachable from this diff, jitter class), goldens exactly the 2 baseline names, CLI only the documented coproc flake, Rust tests pass. Merged without update-branch under the zero-intersection exception: c22017c...e3e9281 touches only scripts/ci-pin-exclusions.txt. 本 PR 删除了什么: - 未删除任何内容。纯新增/修正:skip.rs 下标门三处判定、continuation.rs 镜像三处平行判定、新回归钉一个文件。 #3904 stays OPEN: its A29 half (CompassignTokenError wording arm in script_driver.rs, REPORT §5) is dispatched next.
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
…F split (Fixes #3905, Fixes #3914) fix(lexer): compound assignment inside $(...) takes the compassign EOF split (Fixes #3905, Fixes #3914) Two commits, both captain-authored (continuation.rs is captain-exclusive; the #3905 lane's REPORT localized the defect and handed the file back): 1. The nested `(` arm in both close-char scans (unclosed_input_close_char_ posix + mirror close_char_residuals_advance) recognizes a compound- assignment opener from the raw text — nested_compassign_opener: an identifier or subscripted name directly followed by `=`/`+=` at a command token position (GNU token_is_assignment parse.y:5270/:5653 + assignment_acceptable parse.y:3163, or PST_ASSIGNOK for declare/local/ export/readonly/typeset) — and pushes an array_list frame like the top-level arm's, so the #3903 EOF status split reads it. Suppressed inside an array list (element text, the #3904 A29 family), a case pattern (PST_CASEPAT), arithmetic bodies, and process substitutions. 2. Residual #3914: the scans' in-delimiter escape arm consumed a `\<newline>` pair without advancing the line counter, so every later EOF report in the body named a line one too low (plain-comsub probe: GNU line 3, rubash line 2). Both arms now count the escaped newline, like the stack-empty arm already did. Verification: fail-first on the base tree (pin 2 passed / 1 failed — the fidelity test red, controls green). Fixed tree on the server: pin 3/3, 13 adjacent EOF stems green, lib randomized 8/8, lib full 1280/0, cli_tests 461/10 (the documented pre-existing set: 9 examples cells + the signal-mask trap-listing cell), RUSTFLAGS="-D warnings" rc=0, marker lint rc=0, utf8 hygiene rc=0, rustfmt clean. Head CI adjudicated by name: census 77 (era band; issue3905 stem 3 PASS lines in census, no new failing stems vs the #3908 head), goldens exactly the 2 baseline names, CLI pass, Rust tests pass, niubash-builds pass. 本 PR 删除了什么: - 未删除任何内容。纯新增:raw-text 识别助手三件、两扫描嵌套臂的 compassign 分支、两扫描转义臂的行计数、新回归钉一个文件。
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.
Refs #3899, Refs #3900 — 车道 fix-eof-split 交付,待队长终审(不自合)。
修什么
#3897 把未闭合定界符 EOF 的退出状态按 construct 拆分时,通用臂改成无条件 2 —— 对词内配对是对的,但漏了「失败的词读取被
parse_compound_assignment词元循环消费」这一族:GNU 在该循环里诊断后set_exit_status (EXECUTION_FAILURE),状态钉在 1(parse.y:7151-7152 诊断、parse.y:7167-7169 置状态;error yacc_EOF产生式 parse.y:484-493 只对仍为 0 的状态强制 2)。于是:a=(\n1\n2\n文件形 EOF 退出 2(GNU 1),compat_issue78 钉红(fix(parser,script_driver): fix master CI regressions from #3755 and #3701 #3897 引入的回归)。v=(<(echo等 procsub 元素形,诊断行对(EOF 行,parse.y:6891 嵌套解析报告)、状态错(2 应为 1),issue551 c6 钉红(fix(comsub,parser): honor ANSI-C $'...' in $( walkers; split EOF exit status by construct #3701 残余)。改动(仅 src/script_driver.rs,+68/−7)
unclosed 路由里三个无条件返 2 的臂(通用 close-char 臂、
$[猎取臂、extglob 臂)改为查定界栈的array_list位(栈内任一处有 array-list 帧开着):开着 → 1(errexit 活着 → 2,error.c:324-327);没开 → 保持 #3897 的 2。诊断(closer 与行号)仍归最内层失败扫描,一字未动。下标臂(已有 inside_compassign 分流)与 command 臂 fallthrough(已有 array_list 检查)不重复改。未碰 src/lexer/continuation.rs,未碰 parser,未改任何测试。GNU 对照(5.3.20 oracle,43 形 × 文件/stdin 双模式)
复合赋值全族 rc=1:纯列表、
declare/+=/关联下标变体、引号/双引号/反引号/comsub/procsub/$[/下标/${/算术元素、extglob 元素;errexit 变体 rc=2;非赋值的词内配对全族保持 rc=2;闭合赋值 rc=0。修复后二进制与 oracle 的差异只剩三处存量(尖上即如此,非本 PR 引入):A13v=(a[1仅 closer 字符差(]'vs)',状态同为 1,下标臂面);A14echo $(a=(1状态/行号差(走 comsub 诊断路由,不同子系统);A29v=(a (echo诊断措辞差(GNU 是 token 错误,状态同为 1)。三处已写入车道 REPORT §7,建议队长另行立案裁量。验证(服务器腿,逐茎 test result)
RUSTFLAGS="-D warnings"构建 rc=0;rustfmt --check干净。附带核验(只报告,按派工要求未改)
keeps_comsub_case_subject:K 形探针(echo $(case $(ls) in esac)、v=$(case x in esac))在尖与修复后二进制上与 GNU 5.3.20 可观察行为逐字一致(rc 0、输出相同),lib 钉在修复树上 ok —— #3897 把期望对齐到 Some(...) 是 GNU 正确的产品行为,不是钉掩盖缺陷。车道 REPORT:~/workspace/fix-eof-split/REPORT.md(GNU 矩阵全文、守卫表、逐茎结果在内)。
本 PR 删除了什么
无删除(纯增改:状态分流逻辑 + 注释;删去的是三处「无条件返 2」的旧表达式行)。