Skip to content

fix(main): -c operand marker-zone entry escaping — respawn exclusion is double-escape only (rubash#948) - #952

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/948
Oct 21, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/948

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

Fixes #948 — the -c face's marker-zone decode residual. #947 fixed the stdin/script faces; the same typed literal still decoded on -c because the -c operand skipped entry escaping entirely.

Root cause / decode-path difference. run_command_string_with_init fed the raw argv operand straight to the drivers — no marker-zone entry escaping. Script files get bytes_to_script_text, stdin gets bytes_to_shell_text, both E400-escape literal zone chars at entry so decoders see them as data. -c got nothing, so rubash -c 'echo "x<U+E319>41;y"' printed xAy and x<U+E000><U+E041>y mangled, while GNU prints both literally.

Semantic boundary (成文, per ticket). The respawn exclusion documented in substitution_metadata.rs is a double-escape exclusion, not an all--c exclusion:

  • Respawned &/coproc children (RESPAWNED_CHILD — __RUBASH_SHELL_PID/__RUBASH_COPROC_CHILD, incl. __RUBASH_CMD_FILE) receive serialized AST already in transport spelling → skip entry escaping (unchanged).
  • Every other -c string is fresh source like a script file → escaped by new substitution_metadata::command_string_entry_text.
  • Nuance found during verification: a rubash parent's argv materialization keeps E400+zone pairs when it launches a plain rubash -c child — transport spelling arrives without env markers. The escaping therefore preserves existing E400+zone pairs verbatim (idempotent within one text) instead of double-encoding them. A lone typed U+E400 stays the documented ambiguous seam.

Test plan

  • rubash -c 'echo "x<U+E319>41;y"' → x<U+E319>41;y verbatim (was xAy), single- and double-quoted
  • typed __RUBASH_CSB1_41; via -c → verbatim
  • respawn face unchanged: __RUBASH_SHELL_PID + transport text — E400+E319 pair → literal E319, bare sentinel → protocol decode (no double-escape)
  • plain -c sanity (echo hi; $((x+1))) unchanged
  • new catalogue case cases/issue-948.sh + manifest row (must-match) — runs under arm green locally; runner requires WSL oracle, not executed here
  • cargo test --lib substitution_metadata 27/27
  • full 83-suite ledger — not run (task scope: targeted tests only)

Residual noted for follow-up: a literal U+E000 word emitted by a rubash parent into a spawned child's argv arrives mangled (E400+payload) — a parent-side argv materialize defect, separate root cause outside the -c entry boundary. Recommend a follow-up issue.

Generated with Devin

@caomengxuan666

Copy link
Copy Markdown
Member Author

CR(本轮不合并)

阻塞:与 master 冲突,无法 squash。 scripts/regression-catalog/manifest.tsv 撞车——master 侧 #949 已把 issue-879 行翻成 must-match(并补了 pinned 测试说明),本 PR 是在该行还是 diverges 时分叉的,又在文件尾追加了 issue-948 行:

CONFLICT (content): Merge conflict in scripts/regression-catalog/manifest.tsv

解法明确:保留 master 的 issue-879 must-match 行,把 issue-948 行追加在其后(两边改动语义不冲突,纯 rebase 工作)。rebase 后 CI 也需要重跑——本轮 fix/948 头上只有 greet/stale,CI workflow 根本没起(head sha 2bd33dc4 的 check-runs 只有 greet/stale),以本地复验代替了这层。

本地复验(全绿,附证据)

按票面三项验收:

  1. typed-cell 形 -c 面修复(与 fix(executor): E400-aware sentinel decode family for marker output boundary #947 stdin 面同契约) — cargo test --lib substitution_metadata 27/27;二进制探针(ps-tgt debug 构建,argv 精确字节):
    • rubash -c 'echo "x<U+E319>41;y"' → x\u{E319}41;y 逐字(master 同形 = xAy,票面复现形已修);
    • x<U+E000><U+E400>41;y 双引号形 → 逐字,无 mangling;
    • rubash -c 'echo "__RUBASH_CSB1_41;"' → 逐字;
    • 平面 sanity echo hi; echo $((40+1)) → hi/41 不变;
    • script 文件面(fix(executor): E400-aware sentinel decode family for marker output boundary #947 面)x<U+E319>41;y → 逐字,不回退。
  2. respawn 双重转义排除语义成文 — substitution_metadata.rs/main.rs 注释把边界写清了(排除的是 double-escape、不是全 -c;RESPAWNED_CHILD/__RUBASH_SHELL_PID/__RUBASH_CMD_FILE 走 Borrowed 旁路),且探针差分证明门是真生效的:同一段 argv,带 __RUBASH_SHELL_PID 时裸 typed zone char 仍走协议解码(xAy,与 master respawn 行为一致),不带时被 entry escaping 保护为字面量——分叉点正是新加的 Cow::Borrowed 分支。transport E400+E319 对在 respawn 面 → 字面 E319,无 E400 残留、无双重编码。
  3. E400 对保留 nuance(rubash 父进程 argv 物化的部分 transport 拼写)实现与文档一致,command_string_entry_text 对既有 pair 原样拷贝。

catalogue cases/issue-948.sh + manifest 行(must-match)在位(runner 要 WSL oracle,遵规未跑,只验了文件形)。遗留建议照 PR 所写立 follow-up issue:rubash 父进程向子进程 argv 物化时裸 U+E000 词到达即 mangling(E400+payload)——父侧独立根因,不在 -c entry 边界内。

rebase 后 push 即可,语义面本轮已验全,无需重验。

…is double-escape only (rubash#948)

The -c face skipped entry escaping entirely, so a literal marker-zone
char in a user-supplied command string (e.g. a typed U+E319 sentinel or
U+E000 introducer) was read as live protocol and decoded into its payload
char where GNU prints the literal glyph. stdin/script faces were already
protected by bytes_to_script_text / bytes_to_shell_text (#856/#947).

Semantic boundary, aligned with the #947 respawn comment: the exclusion
is a DOUBLE-ESCAPE exclusion only, not an all-`-c` exclusion. Respawned
`&`/coproc children (RESPAWNED_CHILD via __RUBASH_SHELL_PID /
__RUBASH_COPROC_CHILD, incl. __RUBASH_CMD_FILE transport) receive
serialized AST already in transport spelling and keep skipping entry
escaping. Every other -c string is fresh source like a script file and
is now escaped by new substitution_metadata::command_string_entry_text —
which additionally preserves an existing E400+zone pair verbatim because
a rubash parent's argv materialization emits pairs when it launches
another rubash -c (plain spawned children, not only & respawns, can carry
transport spelling). A lone typed U+E400 remains the documented
ambiguous seam.

Probes: rubash -c 'echo "x<U+E319>41;y"' -> x<U+E319>41;y (was xAy);
typed A via -c verbatim; respawned-child transport
spelling still decodes as protocol (no double-escape). Residual noted
for follow-up: a parent-side argv materialize mangles a literal U+E000
word to bare E400+payload when spawning a child — separate root cause
outside the -c entry boundary.

Fixes #948

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

返工完成(rebase + CI)

  • 冲突已解:rebase 到 origin/master 95700a5b;scripts/regression-catalog/manifest.tsv 按评审方向保留 master 的 issue-879 must-match 行([P3][test] catalogue manifest issue-879 行过时:已与 GNU 一致应 flip must-match(现报 PROMOTE) #949 pinned 说明原文不动),issue-948 must-match 行追加在其后。git diff origin/master HEAD -- manifest.tsv 净增量仅 +issue-948 一行。
  • 补丁等价:rebase 前后补丁逐项 diff(a3d368c5..2bd33dc4 vs 95700a5b..49e25dfa)——除 manifest 的 issue-879 上下文行、以及 src/script_driver.rs hunk 行号平移(4317→4357,master 在上方新增代码所致)外逐字节一致;marker-zone entry escaping 修复、substitution_metadata.rs/main.rs 注释边界、cases/issue-948.sh 全部保留。
  • push:2bd33dc4 → 49e25dfa(--force-with-lease);mergeable=MERGEABLE。
  • CI:synchronize 已触发 CI / Rust tests(run 39529705098)→ success,全部 job 通过("Bash upstream test progress" 为 skipped 门禁,非失败)。此前 head 2bd33dc4 只有 greet/stale 的问题已解除。

语义面未动,仍以上轮本地复验证据为准。

@caomengxuan666
caomengxuan666 merged commit 7979117 into master Oct 21, 2026
6 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member Author

终审:通过,合并

rebase 返工验收四项全过(head 49e25dfa,基座=master 95700a5,单 commit):

  1. manifest.tsv 无冲突且等值 — 与 master 全文件 diff 仅一行:尾部追加 issue-948 948 must-match 行;issue-879 行与 master([P3][test] catalogue manifest issue-879 行过时:已与 GNU 一致应 flip must-match(现报 PROMOTE) #949 落地后的)must-match 值逐字节一致(diff 为空)。
  2. marker-zone -c 面修复完整保留 — PR 自有文件(src/main.rs、src/executor/substitution_metadata.rs、cases/issue-948.sh)相对上轮头 2bd33dc4 逐字节不变(rebase 纯净,script_driver.rs 仅承接 master 侧位移、包装 hunk 原样在位)。本机二进制探针复核:rubash -c 'echo "x<U+E319>41;y"' 输出字节 78 ee 8c 99 34 31 3b 79 0a —— 字面 U+E319 逐字透传(ee 8c 99),不再被协议解码。
  3. CI 本轮实跑终态全绿 — Cross-target / GNU goldens+canaries / Rust tests / Rust tests (macOS) / Shell functionality 全 pass(上轮 greet/stale 未起跑的问题已消除)。
  4. metadata 测试绿 — cargo test --lib substitution_metadata 27/27。

上轮遗留(父侧 argv 物化 mangling 裸 U+E000 词)照 PR 所写属独立根因、不在本边界内,维持 follow-up 建议。

Fixes #948

@caomengxuan666
caomengxuan666 deleted the fix/948 branch October 30, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P3][test] -c 脸的 marker-zone 解码残留:typed-cell 形经 -c 仍解码为载荷字符(stdin 面已修)

1 participant