Repository navigation
executor: protect literal ' ' under null-IFS / W_SPLITSPACE (dollar-at-star9) - #3925
Merged
Merged
Conversation
…11939-11949)
GNU expand_word_internal's case ' ' arm (subst.c:11939-11949) emits a
literal ' ' from word text as CTLESC+' ' whenever ifs_is_null or the
word carries W_SPLITSPACE, so the deferred split-on-" "
(subst.c:11535 -> 12103-12107) fires only at the $* join bytes and
affix/rhs spaces stay glued: a${0+ $* }b -> "a X Y" "Z b".
- embedded_mutations::expand_embedded_parameters_mut_inner and
embedded_parameters::expand_embedded_parameters_inner: under the
alternate-rhs walk (protect_ifs), emit literal ' ' as IFS_GLUE+' '
when IFS is set-but-empty or the output already carries
SPLIT_ON_SPACES_SENTINEL.
- command_prepare::alternate_list_fields: unquoted $*/${*}/${name[*]}
under an empty IFS return per-element fields (W_SPLITSPACE,
subst.c:10207); quoted still joins on IFS[0] or '' (subst.c:3031).
Refs #3605
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
Author
|
队长复核:可合(头 e70eb34,基底即现尖 f983851,无需 update-branch)。 头 CI 逐名裁定(run 44353126092):census 78,唯一新增格 说明:本 PR 为 draft,队长不代 mark ready;你 mark ready 后可合。服务器腿(钉 stem 实跑、lib 对齐)待链路恢复后补跑。 |
This was referenced Nov 18, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
…3545) ## 根因 载体字节(0x0c、0x11、0x13、0x14..=0x1f)在 rubash 传输层以 U+E000 raw-byte pair 编码存储,但 `[[ =~ ]]` 两侧的解码并不对称: - 带引号的 regex 路径(`regex_rhs_marked_chars` 经 `shell_text_to_raw_bytes`)把 pattern 侧的 pair 解回裸字节; - subject 侧只过 `decode_command_substitution_payload`,它只还原 U+E319 comsub sentinel,不动 U+E000 pair; - 于是 `$'...'` 字面形与 `|` 后的 `${c}`(走带引号路径)pattern 为裸字节、subject 为 pair 编码,永不匹配;而不带引号的 `a${c}b` 形两侧都保持 pair 编码,只是碰巧一致才匹配。 修法:在 regex 边界上把两种拼写都解开——pattern 在 `compile_conditional_regex_uncached` 入口、subject 在三个 match 入口(`conditional_regex_match` / `conditional_regex_match_status` / `conditional_quoted_regex_match_status`),共用一个 `decode_regex_operand`(sentinel 先解——它只产 U+0000..=U+00FF,不可能造出 pair introducer——再折叠 raw-byte pair)。这是 #729 glob 侧已在用的同一归一化。 ## GNU 锚点 - `execute_cmd.c:4068` `arg2 = cond_expand_word (cond->right->op, mode)`(`=~` 且 compat > 31 时 mode 2)、`:4096` `sh_regmatch (arg1, arg2, ...)`:两侧展开后都以裸字节进 regcomp/regexec; - `subst.c:4077` `cond_expand_word`、`:4114` QGLOB_REGEXP(`pathexp.c:212` `quote_string_for_globbing`)只把带引号的 regex 元字符字面化,载体字节本身是数据,原样进 regcomp。 ## 改动 - `src/executor/conditional.rs`:新增 `decode_regex_operand`,4 处调用(pattern 1 + subject 3)。不碰 `src/executor/parameter_replace.rs`(在飞 PR #3926)、`src/executor/embedded_parameters.rs`(在飞 PR #3925)、`src/lexer/continuation.rs`、`docs/api-ledger.md`。 - `tests/issue3545_regex_operand_carrier_bytes.rs`:3 个钉(issue 原样复现循环、全载体集 15 字节 × var/alt/lit 三形 + 3 个非载体对照、`|` 位置对照 + `BASH_REMATCH[0]` 字节值)。 ## 验证(新服务器 [email protected],Linux;本地 VM 未构建) - fail-first(base db580be + 钉):3/3 红,输出与 issue 所述逐字一致(0c/14/1b/1f `alt=n`、`lit-n`;全集 15 字节 `y n n`;`x|${c}` 与 `${c}|x` 为 y、仅带引号的 `$'\\x01'|${c}` 为 n——正是带引号路径解码不对称的证据)。 - 绿腿(fix 树):stem 3/3 绿;15 个 guard stem 全绿(92 测:#729 carrier_byte_class、#3489、#1059/#1365 BASH_REMATCH、#1177/#1290/#1491/#1717/#3791/#322/#461 regex、#2981/#2987/#3100 quoted RHS、#1061/1242);`RUSTFLAGS="-D warnings" cargo check --locked --lib --bins` exit 0;rustfmt 两文件 OK;复现脚本用修后二进制跑出与 GNU 逐字节一致的输出。 - lib 对齐:fix 树 1280 passed / 0 failed / 4 ignored;base 树(db580be6)1280 passed / 0 failed / 4 ignored——逐数对齐。 - Windows 腿 PENDING(X299 隧道未通);CI 腿待合入前复核。 ## 本 PR 删除了什么 什么也没删除。只改 `src/executor/conditional.rs`(+36/−8)并新增一个测试文件;没有删除函数、文件、公开面或行为分支。`decode_command_substitution_payload` 的其余 10 处调用不受影响。 ## 队长复核(头 ef443d3,run 44379902406) - census **77**,零新增(issue1902 与 issue2883 两格抖动族翻绿);自带钉 **3/3 绿**。 - goldens 仅基线二名(lib 1383/0 通过);CLI 全绿;darwin/linux/Windows 编译/shell/ledger/niu-build 全绿。 - 基底即现尖 db580be,无需 rebase。服务器腿齐(§验证)。
caomengxuan666
marked this pull request as ready for review
November 19, 2026 03:09
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
Ports GNU
expand_word_internal'scase ' 'protection (subst.c:11939-11949) to the alternate-rhs walkers, fixing the empty-IFS$*/ affix family indollar-at-star9.sub(lines 56-140) and related${param OP rhs}splices.GNU model: a literal
' 'in word text is emitted asCTLESC+' 'wheneverifs_is_nullor the word carriesW_SPLITSPACE, so the deferred split-on-" "(subst.c:11535 → 12103-12107) fires only at the$*join bytes while affix/rhs spaces stay glued:a${0+ $* }b→"a X Y" "Z b", nota | "X Y" | Z | b.Changes:
embedded_parameters::expand_embedded_parameters_inner+embedded_mutations::expand_embedded_parameters_mut_inner: under the alternate-rhs walk (protect_ifs/alternate), a literal' 'with a set-but-emptyIFS(or output already carryingSPLIT_ON_SPACES_SENTINEL) is emitted asIFS_GLUE+' '.command_prepare::alternate_list_fields: unquoted$*/${*}/${name[*]}under an empty IFS return per-element fields (W_SPLITSPACE, subst.c:10207); the quoted arm joins onIFS[0]or''(subst.c:3031-3040).Verified vs GNU bash 5.3.20 byte-for-byte:
${0+ $* },${0+ ${*} },${0+ ${a[*]} },${0+ ${a[@]} },a${0+ $* }b,a${0+ $@ }b,a${0+ "$@" }b,${0+ p $* q },"${0+ $* }",${0+ "$*" },IFS=:${0+ $* },${0+$*},set -- '' ''— plus a zero-diff replay of everydollar-*.subin the run-dollars dir except the already-deferred\x7fcarrier lines ofdollar-at-star9.sub.Remaining sub-families (documented, not fixed here):
a${b-$@}csplice on the-op path,${0+ ${a[*]} }mid-rhs array-star element split, scalar-[*]edge in"${0+ ${a[*]} }".Refs #3605