Repository navigation
executor: redirect target field-split verdict for quoted-space words - #3262
Merged
Merged
Conversation
Twenty cells for the redirect-target word that joins a quoted segment containing an IFS space with a substitution segment: GNU creates or reads the single joined field where the base reports an ambiguous redirect, plus the ambiguous controls that must keep failing. Refs #3089
expand_redirect_target now runs the marked (carrier-protected) word through the same IFS field splitter the argument pipeline uses: GNU redir.c decides the ambiguous-redirect error from the field count of the split, not from a textual scan of the expansion. The count is trusted when the marked expansion carries a protection carrier, or when a raw-word scan proves no quoted IFS character and no quoted expansion site exists (a custom IFS can make a quoted space plain data, in which case no carrier is ever stamped). When the trusted split yields exactly one field, that field is the file name, so a trailing IFS blank inside a substitution result is handled by field semantics instead of surviving into the name. The marker-lint consumption of the carriers goes through the pair-aware contains_bare_sentinel helper; the one remaining bare strip is registered in the allowlist as an owner restore chain (typed C0 bytes never arrive as bare C0 chars). Refs #3089
caomengxuan666
marked this pull request as ready for review
November 10, 2026 13:46
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 #3089
问题
重定向目标词把一个含 IFS 空格的引号段与一个替换段拼起来时,rubash 误报
ambiguous redirect,而 GNU bash 按单字段语义建/读拼接出的文件。例:> 'a b'$(printf '')、> "a b"$V(V 空)、>> 'a b c'${V}(V 空)。根因(GNU 锚点):GNU 的判词在
redir.c:298 redirection_expand——目标词展开后走subst.c:12397 word_list_split做 IFS 字段切分,字段数 ≠ 1 才报 ambiguous;引号段产出在subst.c:4773 quote_string经subst.c:11862 add_quoted_string得到保护,永不被切分。rubash 此前的判词对带标记的展开不做字段切分,而是对剥除载体后的文本做空白扫描,于是引号内的 IFS 空格被误判。改法(机制级,无形状特判)
src/executor/expand_word.rs:expand_redirect_target对带标记的展开改走与参数管线同一个 IFS 字段切分器(field_split_values_with_ifs),以字段数作判词。信任条件二选一:(a) 标记展开带保护载体(经 markers.rs 的 pair-aware 助手contains_bare_sentinel判定,E400 对内成员是数据不是协议);(b) 原始词扫描证明不存在引号内 IFS 字符、也不存在引号内展开点——自定义 IFS 可使引号内空格成为普通数据、永不落载体(如IFS=:时空格非 IFS 字符),此时仿真标记本就无可保护,计数字段仍是 GNU 语义。信任且切分恰得一字段时,该字段即文件名——替换结果尾部的 IFS 空格按字段语义处理,不再残留在文件名中(V='x '时 GNU 的单字段为a bx)。src/executor/redirection.rs:>(...)进程替换的同位点同步采用该判词(两行)。scripts/marker-lint-allowlist.txt:一处裸剥除按仓库既有形态登记为 owner restore chain——依据是 markers.rsrestore_bare_sentinels文档的不变量:带类型的 C0 字节永不以裸 C0 字符到达(恒以 raw-byte 标记对承载),故对 C0 载体的裸剥除不可能折入用户数据。其余两处裸字面消费已改走 pair-aware 助手。本 PR 删除了什么
无删除。仅新增字段切分判词、两个模块内扫描助手与一条 allowlist 登记;被替代的文本扫描判词保留为无标记词的回落路径(其语义与基底一致,见基底对账)。
验证(Simular box,基底
beab07dc,按逐茎 test result 行与失败名集判读)62e46bb8-D warnings --all-targets --keep-going^error计数 32 = 32)cargo fmt -- --checkcargo check --tests --target x86_64-unknown-linux-gnudarwin/msvc 跨目标在验证箱上不可判(箱缺跨目标 C 工具链,基底同样失败),留 CI 判读。
门禁与漂移
4526a493文件面恰 42 文件,不含expand_word.rs/redirection.rs,本面 NOT gated。530d7063做git apply --check通过(F2: exec ordered redirect walk, fd-limit gate, stage stderr routing (Refs #2395, #2635, #2803, #2821) #3144 的 redirection.rs 六处与本补丁的判词条件零重叠)。Refs #3089