Repository navigation
fix(executor): scope the #3855 bad-substitution scan gate to verdicts the scan can own (Refs #3864) - #3874
Merged
Conversation
Fail-first nails, written before the repair: the #3855 braced_name_is_bad_substitution pre-scan check fires on spans whose verdict the real expansion owns (compound element words, $'name' extquote names, POSIX-fatal bad substitutions), so the scan's whole-word display and status-1 class pre-empt the correct diagnostic. Not executed in this lane (build chain down); the captain re-runs the head census after the chain recovers.
… the scan can own (Refs #3864) The #3855 pre-scan gate judges every ${...} inner as a braced name and reports the scan's whole word with status 1, but GNU's bad substitution default (subst.c:10276-10288) reports the WORD BEING EXPANDED with the error class of the context. The scan may only emit that verdict when it coincides with the real expansion's, so the gate now defers to the real expansion when (a) the word is a compound assignment value — GNU expands elements individually (arrayfunc.c:557) and names the element word, which the scan's whole-word display cannot name (issue3500); (b) the name head is a $'...' literal the real expansion decodes — subst.c:7583 judges the extracted NAME (issue2650); (c) the verdict is POSIX-fatal — subst.c:10285-10286 FORCE_EOF when POSIX + non-interactive + compat > 43, which status 1 cannot express (audit B4-F08). All seven #3502 pins and the #3869 funsub pins are preserved by construction: no deferral fires on their words. UNVERIFIED-BY-CAPTAIN: no build/test executed in this lane (build chain down); head census re-run parked for the captain.
caomengxuan666
marked this pull request as ready for review
November 17, 2026 23:37
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
## 根因
${v//[...]/r} 的三个 finder(find_parameter_pattern_match / find_parameter_prefix_match / find_parameter_suffix_match)用 pattern_match_length_bound(pattern 原子数)剪候选,但候选边界是 value 的字符边界。载体字节在 value 里是双字符 raw-byte marker 对(U+E000 + payload),单原子 bracket pattern 的 bound = 1,于是唯一能匹配的候选(双字符 pair 切片)被剪掉,匹配器永远见不到它。匹配器本身无缺陷(byte-spelling 门已把 pair 折成一个 byte-char);${v#pat}/${v%pat} 的 removal walk 早已排除 marker-pair split 点(rubash#1261),只有 replace 侧三个 finder 缺了同一排除。
修法:三个 finder 的候选边界改为匹配单元边界(marker_pair_split_points 过滤),parameter_decode.rs 一处可见性提升(fn → pub(in crate::executor));bound 注释由“字符”改为“匹配单元”。不动匹配器、不动 carrier 编解码、不动 pattern 展开;未碰 markers.rs / compound_exec.rs / conditional.rs / continuation.rs / docs/api-ledger.md;[[ =~ ]] 面(#3545)未动。
GNU 锚点:subst.c:9184 pat_subst() → lib/glob/sm_loop.c:398 BRACKMATCH() 按字节比较括号成员;载体字节是数据。
回归钉:tests/issue3546_bracket_carrier_bytes_regressions.rs(3 个 test fn,7 字节 × 3 拼法 + 双载体 + #/%/?/range/单次/无匹配/纯 ASCII guard)。期望值 = issue 记的 GNU 5.3.20 输出,队长已用本地 oracle 5.3.20 逐形复核(含原始字节 od 校验),与钉期望逐字节一致。
## 队长复核(2026-11-18 23:5x)
头 CI 逐名裁定:census 78,自带钉 3/3 绿,零新增 vs 现尖;goldens 基线二名;CLI 全绿;Rust tests、交叉编译、ledger、niu-build 全绿。分支基底即现尖 e39c44d(已 rebase,base...tip 文件表为空),无需 update-branch。
fail-first 说明(#3874 模式,代码分析 + 头尾 census 佐证):基底上单原子 bracket 的 bound=1 会剪掉唯一能匹配的双字符 marker-pair 候选,钉的细胞在基底上不可能通过;修后头 census 3/3 绿。服务器验证腿(基底 fail-first 实跑、全量 lib 对齐、RUSTFLAGS=-D warnings、hygiene/rustfmt)因路由中断未跑,转移文件在 ~/workspace/fix-3546-transfer/,待路由恢复后补跑;不作为合入前置(钉期望已由队长 oracle 5.3.20 亲测)。
残差(REPORT §6,不在本单):零长匹配恰落 carried byte 前时推进会切半 pair;字面 U+E000 用户数据按一单元走边界(与 removal 侧既有行为一致)——已另立单跟进。
Refs #3546。
本 PR 删除了什么:
未删除任何文件、函数、公开面或测试。仅修改两处既有实现(parameter_replace.rs 三个 finder 的候选边界构造 + 注释、parameter_decode.rs 一个函数的可见性),新增一个回归测试文件。
caomengxuan666
added a commit
that referenced
this pull request
Nov 19, 2026
…l (A29) ## 摘要 #3904 的 A29 半:复合赋值列表自身层级的 token 错误此前被报成 EOF 形。`UnclosedComsubShape::CompassignTokenError` 扩为 `{ line, token, in_comsub }`:shape 扫描在复合赋值帧自身层级记录第一个元字符 token(`;`/`;;`/`;&`/`;;&`、`&`/`&&`、`|`/`||`/`|&`、重定向算符、IO_NUMBER 数字串),帧于 EOF 仍开才浮现;script_driver 新增渲染 arm(token 措辞 + comsub/procsub 的 `while looking for matching ')'` 后缀 + 犯行回显;状态 1、errexit 活时 2 且不回显),并在 `command_paren_verdict_disproved_by_parser` 加同型 guard 例外(真 parser 的 EOF marker 不再抢判);trap_exec 的 eval arm 同步渲染 token 与后缀。GNU 锚点:parse.y:7141-7159、:6833-6865、:6858-6859、:7167-7169、error.c:324-327。 ## 队长复核(头 e1511f0) - CI census:自带钉 `issue3904_compassign_token_error` **6/6 全绿**;总集 69(尖集 72 内 68),唯一新名 `issue2340 repeated_bare_wait_keeps_survivor` 裁为 census flake(19 个已存头集全无此格;本 diff 到不了 wait/作业留存面;issue2340 属已判不稳定族)——评论 issuecomment-6998676374。 - goldens 恰基线 2 名;Rust tests / CLI / 交叉靶 / ledger / niu 构建全绿。 - **fail-first 由 CI 自证**:首头 b76cf3b 的 census 里新钉 5/6 红(实况为旧 EOF 文案),guard 修复(e1511f0c)后 6/6 绿。 - 与尖 3638227(#3925 合入)零交集已程序化证明(compare 文件集 ∩ PR 文件集 = ∅),故未走 update-branch。 ## 验证债(明示,按 #3874 先例) 服务器 sshd 自 ~10:35 CST 起不应答,全部构建路线断(X299 隧道亦断、box 休眠)。车道的服务器腿(base-only fail-first 复跑、lib 双边名集、`RUSTFLAGS="-D warnings"` check、逐文件 rustfmt)**仍欠**,腿脚本与 bundle 已备(~/workspace/fix-3904-a29/legs/);路线恢复后由队长补跑销账,账记 dispatch-state.md。lib 面由本头 CI 的 Rust tests 绿 + 全量 census 覆盖;fail-first 由 CI 双头对照覆盖(见上)。 ## 本 PR 删除了什么 trap_exec.rs 中 CompassignTokenError 臂原先写死的 `` `(' `` 措辞被 token 携带的渲染取代;无命令、选项或公开面删除。 Refs #3904(A13 半已由 #3908 合入;本 PR 合入后 #3904 由队长手关)
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.
Summary
Refs #3864. PR #3855 added a
braced_name_is_bad_substitution(inner)check to theparameter_expansion_error_in_word_contextpre-scan so a bad substitution inside a:?message word surfaces as the inner error (rubash#3502:${v:?${-x}}prints only${-x}: bad substitution). The check judges the whole${...}inner as a braced name and reports the scan's whole word with status 1 — but the scan may only emit that verdict when it coincides with what the real expansion would report. Where it does not, the scan pre-empts the correct diagnostic:arrayfunc.c:557 expand_compound_array_assignment) and the diagnostic names the element word (\\[0\\]=${-x}); the scan names the raw parenthesised value.$'name'extquote names (issue2650):subst.c:7583 valid_brace_expansion_wordjudges the extracted NAME; the real expansion decodes$'x1'tox1in a quoted context, where the gate on the raw literal misjudges it.subst.c:10285-10288makes a bad substitution FORCE_EOF when POSIX + non-interactive + compat > 43; the scan's status 1 downgrades it to DISCARD.The funsub faces (issue2763/issue2761/issue3092/issue3823, golden_funsub_valsub, the arithmetic-for CLI case) are already fixed by #3869, which exempts funsub bodies at the top of this same scan loop; this PR does not touch that exemption.
Repair
The gate now fires only when the scan's verdict coincides with the real expansion's: it defers (returns nothing, letting the real expansion report) when any of these holds —
(): GNU's diagnostic is per-element, which the scan's whole-word display cannot name;$'...'literal thatresolve_dollar_quoted_parameter_namedecodes: the gate must judge the decoded name;compatibility_level > 43, mirroring the fatal arm incommand_execute.rs): the scan's status 1 cannot express FORCE_EOF.Everything else is unchanged: the gate still fires for bare bad names (
${-x},${},${(M)y}), still pre-empts a later:?error left-to-right, and still fires inside:?/:-operator-word recursions — so all seven #3502 pins and the #3869 funsub pins keep passing by construction.What this PR removes
Nothing from the product surface: the #3855 gate check stays; only its three over-broad firing slices are deferred to the real expansion. No new diagnostic text, no new error class.
Validation
UNVERIFIED-BY-CAPTAIN — no build or test was executed in this lane: the build chain is down (X299 tunnel refused, Simular box wallet empty, local build banned: MemAvailable ~503M, below the 1.5G gate).
cargo test/cargo check/ lib+base alignment /RUSTFLAGS="-D warnings"check are all parked; the captain re-runs the head census after the chain recovers.tests/issue3864_parameter_errors_regression.rs(11 tests): issue3500 element words (indexed/assoc/nested/valid guard), issue2650 extquote top-level + bare forms, POSIX fatal + compat43 guard, funsub-valsub shapes, [bug] ${v:?${-x}} 多报一行 v: (:? 与 bad substitution 竞发次序) #3502 inner-only + pin-7 ordering guards. Written fail-first, before the repair; fail-first is by code analysis, not execution (see above)./bin/bash5.2.21; stems already carry 5.3.20 verification):"[${$'x1'}]"->[hello];a=([0]=${-x})->\\[0\\]=${-x}: bad substitutionrc 1; POSIXecho ${}-> fatal, no ALIVE, rc 1;${v:?${-x}}-> only${-x}: bad substitutionrc 1.rustfmt --checkclean on both touched files.${span in their scripts that can trip the gate, so noparameter_errors.rschange can clear them; they are recorded in the lane REPORT as unattributed (likely census flakes / other-window commits) for the captain's census re-run to confirm.