Repository navigation
fix(expansion): command-word field split keeps carrier-byte provenance (Refs #3103) - #3115
Merged
Merged
Conversation
Values carrying carrier bytes but no IFS byte must return from the split machinery as exactly one byte-identical field in all three command-word shapes (args / set -- / for-list). On the unfixed tree these cells fail through the same re-encode provenance loss as the split cells (gate misfire + finalizer folds), so they pin the mechanism, not just the split shapes. Refs #3103
…venance (Refs #3103) GNU subst.c:12377 word_split splits the expansion result on IFS characters only; a data 0x1c-0x1f byte in the result is an ordinary character end to end (subst.c:13219 expand_word_list_internal). field_split_with_raw_byte_markers decoded its input WITH glue provenance (rubash#3004: a pair payload is data, only a bare transport char is IFS_GLUE protocol) but re-encoded the output fields with a local encoder that emitted bytes < 0x80 as bare chars. A data 0x1C therefore left the splitter as a bare IFS_GLUE char and a data 0x1F as a bare DATA_DOLLAR char, and every char-domain consumer downstream of a command-word split -- word materialization (decode_word_position_carriers), the glue strips in the for/set binding finalizers, the splits gate's would-change comparison -- read those data bytes as protocol: 0x1C eaten, 0x1F folded to '$'. The array-assignment consumers #3004 verified never re-enter those passes, so the loss stayed invisible there. Re-encode the fields with the canonical storage encoder (substitution_metadata::bytes_to_shell_text), which pair-tags every carrier byte and E400-escapes marker-zone chars exactly as at storage entry, and delete the local duplicate encoder: the splitter's output now carries the same provenance form as every stored value, for all three command-word shapes and the array path alike. Net: src/executor/arrays.rs +16/-33 (one local encoder deleted).
caomengxuan666
marked this pull request as ready for review
November 8, 2026 13:39
This was referenced Nov 8, 2026
Merged
caomengxuan666
added a commit
that referenced
this pull request
Nov 9, 2026
# merge-body 草稿 — PR #3123(新头 9e229cf 口径,队长复核 PASS 后由合入执行员使用) Refs #2759 Refs #2819 E6 组(词分裂族两单): - #2759:引号段在 unquoted `${arr[@]}` 汇合处保住 quoted-site IFS 保护——顶层段扫描器把普通双引号段及 `$"..."` 段发为独立的 quoted 字面段(与引号体内段模型既有的 `Literal{quoted:true}` 同一机制),段展开器据此对该段展开结果做 IFS 保护(GNU subst.c:11229 逐字跟踪引号状态、subst.c:12273+ 分裂时跳过被引字符)。随之启用 issue2706 钉中原被 ignore 的汇合格 `quoted_result_protection_at_array_junction`。 - #2819:单字节 locale 按 IFS 字节而非字符切分——`field_split_values_with_ifs` 在非多字节 locale 走字节域分裂(值/IFS 解码为字节、逐字节成员判定、字段按存储编码回编);`read` 标量与 `read -a`(非 -r)的值级路径在 `read_split.rs` 内以同样字节域语义运行(逻辑单元 = 字节)。非多字节 locale 之外行为逐字节不变。 - 返工重接:本 PR 旧头曾因 merge-commit 树 E0425(18 处)终判 NOT-PASS——已合入的 #3115 provenance 重写删除了 byte-domain 切分所调用的三参私有 helper 定义、调用悬空。本次 rebase 后按 #3115 的模型把调用点改接 canonical 编码器 `substitution_metadata::bytes_to_shell_text`(一参),未复活私有拷贝;新头全量重验(头钉 6/0、6/0、9/0、#3103 回归茎 7/0、近邻 32/0、lib 双边 1206/0/4 失败名集同为空集、基底 fail-first 红集恰缺陷格)与 CI 10 pass + 1 skipping 均经队长复核。 - 外加一条卫生门 allowlist 条目(`read_split.rs` `byte_domain_text` 的 ASCII 放宽点,`<0x80` 守卫复核记录,无行为改动)。 本 PR 删除了什么:段装配中「双引号段只能整段留在未引字面 run」的旧路径被新的 quoted 段发射取代(该路径在拼接时抹掉引号/非引号边界,是 #2759 的边界信息丢失点;段模型本身未删);issue2706 钉文件中汇合格的 `#[ignore]` 标记与其残余说明注释被删除(该格现已启用并通过;总 diff 的 −7 行全在此文件)。src/ 侧对 master 为纯新增(字节域分裂路径、quoted 段发射、canonical 编码器调用点),未删除任何 API 或函数。 净行数:7 files changed, +657/−7(vs master)。 合入前置(执行员):ready → update-branch(master 已前进至 6ace561 之后须以合入时点为准)→ 盯新 merge-commit 的 CI 全绿后再 squash;本 PR 为 Refs-only,合入后 #2759 / #2819 的关单由队长按证据另行处置,不由本合并自动触发。
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 #3103
问题
命令词位置(for 词表 /
set --/ 命令参数)的非引号分裂丢失载体字节数据:值中的\x1c被吞、\x1f折成$。GNU subst.c:12377word_split只按 IFS 字符切分展开结果,结果中的数据\x1c–\x1f字节全程是普通字符(subst.c:13219expand_word_list_internal)。根因
字节域分裂器
field_split_with_raw_byte_markers的解码侧带来源(#3004:对载荷是数据、只有裸传输字符才是 IFS_GLUE 协议),但它输出字段的再编码用了一个本地编码器,把 <0x80 的字节按裸字符发出。于是数据 0x1C 以裸 IFS_GLUE 字符离开分裂器、数据 0x1F 以裸 DATA_DOLLAR 字符离开,下游每个字符域消费者(词物化decode_word_position_carriers、for/set 绑定收尾的 glue 剥离、splits 门的 would-change 比较)都把数据字节读成协议:0x1C 被吞、0x1F 折$。#3004 验过的数组赋值消费者不重入这些通道,所以丢失在那边不可见。修法
再编码改用规范存储编码器
substitution_metadata::bytes_to_shell_text:每个载体字节重新打成对、标记区字符 E400 转义,与存储入口完全同形。分裂器输出从此与一切存储值同为带来源形态,三形状与数组路径同修,无逐形状补丁。验证:钉 7 格全绿(基底移植 fail-first 红格恰为机制格)、lib 头/基底双边名集一致、邻茎抽验、GNU 探针逐字节 SAME。详见车道 REPORT。
本 PR 删除了什么
删除
src/executor/arrays.rs中本地重复的字节→文本再编码器(bytes_to_shell_text局部函数,−33/+16 净行数变化中的删除主体):它只给 ≥0x80 字节打对、把载体字节裸发,是来源丢失点;删除后分裂器统一走规范存储编码器,无行为分叉的第二实现。