Repository navigation
fix(exec): quoted "$*" joins with IFS[0] under a null IFS in every word position (Refs #4273) - #4277
Merged
Merged
Conversation
…rd position (Refs #4273)
Member
Author
CAPTAIN:暂缓合入——census 有一处非轮换红名待核验CI 裁定(run 46178270541):census FAIL 3 名,goldens 恰为 2 张常设快照,0 SIG。
失败签名(CI 日志原文): 已派核验车道在 devin-mac 树上复现并定位(单文件复跑 + 最小探针 + oracle 对照);确认是回归则修后推 v2,确认是轮换则补名集证据后合入。在此之前本 PR 不合入。 |
…rd position (Refs #4273) Refs #4273 (not Fixes). v2: fixes the issue2827 regression introduced by v1. A fully double-quoted assignment-shaped conditional operand ([[ "k0=v0" =~ ^k0=(v[0-9]+)$ ]]) failed to match: the STORAGE-prefixed word was claimed by expand_marked_or_special_word before expand_assignment_word, leaving the lexer's 0x1C IFS_GLUE (QUOTED_WORD_VALUE_PREFIX) in the comparison value. The fix records a `marked` flag in expand_conditional_word_inner and strips the glue with markers::strip_ifs_glue for marked words after expansion (conditional words are comparison values with no field-split consumer downstream); unmarked words keep the old path. Re-verification (devin-mac): issue2827_regex_compile_cache 5/5, issue4273 pins 5/5, issues_4200_4299 33/33; oracle (bash 5.3.20) 25/27 verbatim, the 2 diffs being pre-existing residual (a) (CTLESC affix leak, same shape on base).
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 #4273
根因
GNU subst.c:3040-3056
string_list_pos_params的分发顺序是:quoted(Q_DOUBLE_QUOTES / Q_HERE_DOCUMENT / Q_PATQUOTE)→string_list_dollar_star(以ifs_firstc连接,null IFS 即无分隔符);interp-888 的 dollar_at 词表分发只适用于 unquoted。rubash 有三层缺口:$*臂(embedded_parameters.rs、embedded_mutations.rs)计算dollar_star = assign_rhs || no_split,从不查 quoted 上下文——凡上下文以旗标/heredoc 形式到达的入口都受影响(heredoc 面在 base 上就是错的:标记泄漏 +[a b c])。raw——这正是代码库处理"$@"的既有机制(quoted_positional_at_*段机器)。assign_rhs,与命令路径分发的不是同一个判定——「两条 join 路径不一致」即此。修复
src/executor/embedded_parameters.rs、src/executor/embedded_mutations.rs:两个 walker 的$*臂加quoted_star项(非 mut 版信号 =in_double || double_quoted || heredoc;mut 版 =in_double || context ∈ {DoubleQuoted, HereDocument},与同文件@臂的quoted_at同源)。服务所有以旗标携带引号的入口(赋值、heredoc、双引号参数词)。src/executor/command_substitution_values.rs:段机器新增PositionalStar段(ArrayStar的 positional 对应物):引号体扫描器仅在 null IFS 时认领$*/${*}(非 null/未设 IFS 下 plain 展开已按 IFS[0] 连接成单一引号词、结果与 GNU 一致,故不认领——与既有整词$*null-IFS 门控同一先例);resolver =positional_params_star_joined()(subst.c:2902 dollar_star 的既有实现);展开器臂按「一个 IFS 保护的引号词」拼接(零参时为一个空词,与"$@"的消失语义相区别)。另:段展开器 flat_map 的空 IFS 短路改为仅对不含 W_SPLITSPACE sentinel 的词生效——含未引号$*件的混合词(如"[$*]"$*)的 sentinel 必须走field_split_values_with_ifs的 sentinel 分支消费。src/executor/compound_exec/case.rs:expand_case_dq_segment的出处恢复(DQ-backslash case subject loses the backslash (Refs #3045) #3084 的 STORAGE 前缀机制)从仅${扩展到裸$*段。src/executor/conditional.rs:新增raw_is_fully_double_quoted扫描;raw 操作数整体由双引号段构成时,在展开点以同一 STORAGE 前缀恢复出处再走expand_word_mut。混合操作数刻意保留 plain 路径(见残差 c)。本 PR 删除了什么
不删除任何机制或文件。删除的是两个 walker
$*臂中「只有赋值/no-split 上下文才走 dollar_star」的错误前提(由quoted_star项取代),以及段展开器 flat_map 对 sentinel 词的无条件空-IFS 短路(改为条件短路)。其余为新增分发面与 GNU 引证注释。净行 delta(git numstat)
测试证据
tests/issues_4200_4299/issue4273_ifs_null_quoted_dollar_star.rs(5 个测试):fail-first 在 base 上 3 红(command_positions / parameter_shapes / other_word_positions)、2 绿(非 null IFS 与未引号两个对照);修复后 5/5 绿;issues_4200_4299全文件 33/33 绿。rustfmt --edition 2021 --check全清。残差(不在本 PR 范围)
以下三项均已证 base 同形,已另立 #4276 跟踪,本 PR 不声称修它们:
a. 段路径 CTLESC affix 泄漏(非 null IFS):base 上
IFS=:; echo "[$@]"即输出\x11[a b c\x11],属段机器 carrier 传输问题;本修复以 null-IFS 门控保证$*不新暴露于此。b. 重定向目标:
IFS=; echo hi > "[$*]"在 base 与修复版上都生成名为[\u{E31C}a b c]的文件——重定向目标展开既不走段机器也不剥 W_SPLITSPACE sentinel。c. 混合 conditional 操作数(如
[[ a"[$*]"b == … ]])保留 plain 路径:整词 STORAGE 标记无法表达段级引号;全引号操作数已修。验证口径
captain-verified on devin-mac; CI pending(goldens
upstream_suite_slice_snapshots_*不在本地 cargo test 集合内,留 CI 裁定)。