Repository navigation
W-WORD 续跑:#3192 单引号跨度逐字段 / #3084 case 词 DQ 装框 / #3218 重定向目标字节拼写 - #3368
Merged
Merged
Conversation
…tions rubash#3192: in a command-substitution array junction, a single-quoted (or $'...') span's suffix was re-cooked by the junction path, so a quoted space/text tail lost its verbatim form. GNU keeps quoted spans inert through word assembly (parse.y read_token_word quoting state) and only dequotes at the end (subst.c:4807 dequote_string); the junction cooker now records such spans as a VerbatimQuoted segment and emits them untouched. Pin: tests/issue3192_array_junction_single_quote_suffix.rs (9 cells; fail-first on master 5 passed / 4 failed, reds exactly the four single-quoted/ANSI-C suffix cells). Refs #3192
rubash#3084: quote_aware_case_word consumed the quotes of a
double-quoted case subject and fed the cooked fragment bare into
expansion, so ${v=a\ b} inside the subject read as unquoted and the
assignment split at the escaped space (GNU keeps the subject a
quoted word: subst.c:7663 parameter_brace_expand_word runs under the
word's quote frame). The DQ arms now route a fragment containing
"${" through expand_case_dq_segment, which re-frames it with the
lexer's wholly-quoted-word marker (STORAGE_WORD_PREFIX) so the
assignment expansion sees the double-quoted frame, exactly as a
plain double-quoted word elsewhere does.
Pin: tests/issue3084_case_word_dq_backslash.rs (already on master
via PR #3165; fail-first 3/6, head 6/6).
Refs #3084
rubash#3218: name folding destroyed per-character source fidelity for redirect targets. Face 1: a name mixing a genuine non-ASCII char with a raw-byte transport char (genuine é + byte 0x9C) was spelled with EVERY <=0xFF char as a single byte, so é hit the disk as 0xE9 instead of UTF-8 C3 A9. Face 2: the transport record was keyed by the folded target string, so two redirects in one command folding to the same string shared the verdict — a genuine-char target was opened with the other target's raw-byte spelling. GNU has no fold: redir.c:298 redirection_expand's string is opened verbatim, byte for byte. The expansion now computes the target's byte spelling while the transport pairs are still present (transport_name_spelling_bytes, the byte-emitting twin of decode_raw_byte_markers_to_byte_chars) and records it under both the folded literal (string-only consumers) and the redirect node (redirect_target_node_spellings). create_redirect_output / create_redirect_output_prepared and the redirect walks gained node-aware _for forms that treat the node's own record as authoritative; string-only consumers keep the string-keyed record. All other open funnels are unchanged. Pin: tests/issue3218_fold_mixed_source_names.rs (2 cells, oracle-verified byte spellings under LC_ALL=C.UTF-8; fail-first on master 0/2, head 2/2). Regression net: issue3104 24/24, lib bilateral 1245/0/4 both sides, failure name sets empty. Refs #3218
This was referenced Nov 11, 2026
caomengxuan666
marked this pull request as ready for review
November 11, 2026 14:48
This was referenced Nov 11, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 16, 2026
…3372) (#3565) GNU redir.c:298 redirection_expand gives every redirect its own expanded bytes and redir.c:702 redir_open opens them verbatim, so in `: >"$a" >>"$b"` a raw-byte x<9C> and a genuine x<U+009C> (same folded string) land as two files. #3368 made the create funnel read the redirect-node spelling record; the append funnel still read the folded-string record and reopened the other redirect's spelling. - shell_options: open_append_target_for(Option<&Redirect>, target); every filesystem arm resolves through the node record when a node is given (plain funnel otherwise, never the string-keyed record). probe_output_redirect_append takes the node too, for both its FIFO stat and its open. - builtin_redirects / external_redirects / redirection: the append call sites that hold the node pass it. - mod.rs: correct the field comment that claimed a no-transport outcome clears the string-keyed record (the code never removes it). Also rustfmt tests/d11_pipeline_squote_carrier_regressions.rs, which landed unformatted on master (#3511) and fails the pre-commit check. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
… the node (Refs #3372) (#3872) * fix(executor): resolve redirect/cd/funsub/type byte spellings through the node (Refs #3372) #3218 residual: the sibling consumers of the #3368/#3218 node-key funnel still consulted the folded-string record, so same-string collisions survived for the pre-create opens, the external stdout/cat-output opens, `cd`, `$(<file)`, and the `type` display face. Root cause: `a="$(printf 'x\234')"` (raw byte 0x9C) and `b=x$'\u009c'` (genuine U+009C, UTF-8 C2 9C) fold to the same string. GNU hands each redirect its own expanded bytes (redir.c:298 redirection_expand) and opens them verbatim (redir.c:702 redir_open); cd chdirs the verbatim bytes (builtins/cd.def change_to_directory); `$(<file)` reads the verbatim bytes (subst.c command_substitute); `type` prints the name and the find_user_command hit verbatim (builtins/type.def describe_command). The consumers below took the folded-string record instead, so a transport sibling's spelling steered the genuine leg onto the raw-byte file (or vice versa). Fix (same mechanism as #3368): consumers that hold the node resolve the byte spelling through the node's own record; no record falls back to the plain funnel; the string-keyed record is never consulted. - source_type_state.rs / function_calls.rs pre-create opens take `Some(redirect)` (`create_redirect_output_prepared[_open]_for`). - external_redirects.rs `apply_external_stdout_target` and external_finish.rs `open_cat_output[_sink]` take the node and use `create_redirect_output_for` / `open_append_target_for`. - `cd` takes the byte spelling computed before the fold (`transport_name_spelling_bytes`) on unix (`cd_filesystem_path`). - `$(<file)` takes the pre-fold byte spelling on unix. - `type` / `type -p` / `command -v` / `type -a` write describe lines byte-wise (`write_describe_line` + `describe_display_bytes`) in both `describe_name_with_io` and `describe_name_all_with_io`; with no transport the byte spelling is the folded name's UTF-8 bytes, so plain names print exactly as before. Regression pins (6 stems, 12 tests; expectations from GNU bash 5.3.20 oracle probes, LC_ALL=C.UTF-8): - tests/issue3372_precreate_node_spelling.rs (3) - tests/issue3372_external_stdout_node_spelling.rs (2) - tests/issue3372_cat_output_node_spelling.rs (2) - tests/issue3372_cd_byte_spelling.rs (2; marker landing, not pwd output) - tests/issue3372_funsub_input_byte_spelling.rs (2) - tests/issue3372_type_display_byte_spelling.rs (1) UNVERIFIED-BY-CAPTAIN: no build route was available (X299 tunnel down, local build banned, box wallet empty), so the pins were not run and no cargo check/test ran. The captain verifies fail-first on base and green on this head on a live route before merge. Known residuals (see lane REPORT): `pwd`/PWD display of a raw-byte directory still diverges from GNU (byte-level pwd output is a separate face, deliberately not pinned); function-definition printing in `type` Verbose still goes through folded AST text; external_redirects.rs has 6 pre-existing rustfmt-drift hunks unrelated to this change. ## 本 PR 删除了什么 无删除。纯增量修法 + 6 个新钉文件;既有 `tests/issue3372_append_funnel_node_spelling.rs` 未动。 * fix(executor): deref boxed redirect nodes in open_cat_output_sink (Refs #3372) * test(3372): fix octal escape depth so $a carries raw byte 0x9C (Refs #3372) * fix(executor): complete node-aware probe, >&word, and logical cd byte-spelling fixes (Refs #3372) --------- Co-authored-by: 曹梦轩 <[email protected]>
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.
W-WORD 半成品续跑收官:三单同波交付(基底 master
8f904d3f,三笔提交逐单对应)。#3192 — comsub 数组连接处单引号跨度失真
提交
738dee1b。修法(原车道已写、本波验证并移植到活尖):src/executor/command_substitution_values.rs新增VerbatimQuoted段变体,'…'/$'…'跨度在连接烹饪中逐字保留(GNU:引号跨度在词组装期惰性、仅在 subst.c:4807 dequote_string 末段去引)。单文件 +84/−3,移植时与活尖的唯一漂移(#3201 的 ~970 行不相交 hunk)无冲突应用。tests/issue3192_array_junction_single_quote_suffix.rs(9 格):基底 top-up fail-first 5 过 / 4 红,红格恰为缺陷四格(single_quoted_suffix_space、single_quoted_suffix_text_and_space、ansi_c_suffix_space、ansi_c_suffix_text_and_space);头 9/9。Refs #3192
#3084 — case 词双引号段内 ${v=a\ b} 赋值丢引号框
提交
faf7fd08。机制:quote_aware_case_word(compound_exec.rs)消费主语 DQ 段引号后把烹饪片段裸喂展开,in_double派生自词面 → 片段按未引读,${v=a\ b}在转义空格处劈开。GNU 主语是带引号框的词(subst.c:7663 parameter_brace_expand_word 在词的引号框下运行)。修法:新增expand_case_dq_segment——片段含"${"时以 lexer 自家的全引词标记STORAGE_WORD_PREFIX重新装框再展开,两条 DQ 臂($"..."与"...")共用;cook_double_quoted_segment经核无罪(${...}单元逐字拷贝)。tests/issue3084_case_word_dq_backslash.rs(已在 master,PR test: wave-2 pins W2d (Refs #3066, #3084, #3097) #3165):现尖 fail-first 3/6(红格 = dq 赋值主语两格 + 非 case 对照/链格的链半),头 6/6。Refs #3084
#3218 — 重定向目标名折叠丢逐字来源保真(#3104 残差)
提交
86947759。GNU 无折叠:redir.c:298 redirection_expand 的串被逐字节打开。两面:folded_name_to_path_bytes把每个 ≤0xFF 字符都作单字节发射,真 é 落盘成 0xE9(GNU 应为 UTF-8 C3 A9)。修法:展开期在传输对尚存时计算字节拼写(
transport_name_spelling_bytes,decode_raw_byte_markers_to_byte_chars的字节发射孪生),双键记录——折叠串键(字符串型消费者)+ 重定向节点键(redirect_target_node_spellings,走查持节点、节点判词权威、无记录则走平凡漏斗、绝不借串键记录)。create_redirect_output/create_redirect_output_prepared与各重定向走查点新增节点感知_for形(约 25 处调用点转换,节点不在作用域的 3 处保持串键口径)。同串同跨预展开顺序使串键「后判词覆盖」与「删除」两方案均经实证否决(插桩探针存~/workspace/fix-W-WORD/probes/p3218pin.sh,LC_ALL=C.UTF-8 下与 GNU 5.3.20 目录字节逐一相同)。tests/issue3218_fold_mixed_source_names.rs(2 格,期望 = GNU oracle 实测字节):基底 0/2,头 2/2。Refs #3218
验证汇总(本地 canonical 路线:build-slot + scrubbed_cargo,逐茎 test result 判读)
f5f65d35):1245 过 / 0 红 / 4 ignored,头同数,失败名集双边 ∅;rebase 至8f904d3f后四钉复验全绿、lib 复跑见报告。RUSTFLAGS="-D warnings"lib+bins rc=0;scripts/check-marker-literals.pyrc=0;scripts/check-utf8-boundary-hygiene.shrc=0;cargo fmt --check净。cargo check --all-targets -D warnings在 master 上有一处tests/issue2698_job_death_notice_retirement_regressions.rs死字段警告,基底同红,归测试卫生面。本 PR 删除了什么
无删除。本 PR 为纯增量修复:#3192 新增一个段变体;#3084 新增一个展开辅助函数;#3218 新增拼写计算函数、一个节点键记录表与
_for变体——旧串键 consult 与旧 create 入口全部保留(create_redirect_output转为薄委托),无函数、无文件、无测试被删。三单均为 Refs 口径:覆盖完整性如上,关单请队长在复核合入后处置。不自合、不自关。