Skip to content

fix(expansion): preserve U+E316 in assignment concatenation (Refs #3016) - #3041

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/3016-e316-assignment-concat
Nov 8, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/3016-e316-assignment-concat

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

根因

preserve_prompt_escapes(src/executor/assignment_expansion.rs)末尾的盲 .replace(PROTECTED_PROMPT_ESCAPE, "\\") 把用户 E400 + E316 对中已被转义的成员当作 live protocol 读:吞掉 E316、留下一个孤儿 E400,输出解码器将其折成反斜杠。于是 w="a${v}b" 存成 a\b,而 GNU 存 a<E316>b。

GNU 锚点:subst.c:4309 expand_string_internal + variables.c bind_variable(verbatim store,赋值处不做 guard 折叠)。同族先例:rubash#735 与 rubash#840 分歧 3。

修法

单点:preserve_prompt_escapes 末尾改走 markers::restore_bare_sentinels(E400-aware)——仅本函数自身为 \!/\# 引入的裸 E316 映回 \;E400+E316 用户对原样复制。两调用方(expand_assignment_value_inner、expand_quoted_prompt_arithmetic_assignment)同时受益。未动 markers.rs / quotes.rs / continuation.rs / docs/api-ledger.md。

测试

  • 钉 tests/issue3016_e316_assignment_concat_regressions.rs:8 单元。Fail-first(transplant 到 base):5 passed / 3 failed(恰为预测的 3 单元)。修后:8 passed / 0 failed。
  • 邻茎 8 个:marker_leak_golden、issue735、issue824、issue1634、issue757、issue1099、assignment_quote_roundtrip、assignment_chain,合计 55 passed / 0 failed。
  • 全量 lib:branch 1197 passed / 0 failed / 4 ignored;base(6eb861b8)1197 passed / 0 failed / 4 ignored;失败名集合两边皆空,逐数对齐。
  • RUSTFLAGS="-D warnings" cargo check:通过。cargo fmt --check(两触文件)+ scripts/check-utf8-boundary-hygiene.sh:通过;两触文件 0 个 CR 字节。

本 PR 删除了什么

什么也没删除。净行数 +183(修法 src/executor/assignment_expansion.rs +9/−1,净 +8;新钉 tests/issue3016_e316_assignment_concat_regressions.rs +175)。

Refs #3016

preserve_prompt_escapes ended with a blind
`.replace(PROTECTED_PROMPT_ESCAPE, "\\")` that read the escaped
member of a user `E400 + E316` pair (typed `$'\uE316'`, E400-escaped
at entry by `push_literal_char`) as live protocol: it consumed the
E316 and left a stray E400, which the output decoder folded to a
backslash, so `w="a${v}b"` stored `a\b` instead of `a<E316>b`.

Restore E400-aware via `markers::restore_bare_sentinels`: a bare
guard (only one this function itself introduced for `\!` / `\#`)
maps back to `\`; an `E400 + E316` pair copies verbatim. Same family
as rubash#735 and rubash#840 divergence 3.

GNU anchor: subst.c:4309 expand_string_internal + variables.c
bind_variable (verbatim store); no guard folding at assignment.

Refs #3016
)

8 cells (LC_ALL=C.UTF-8 on the child): braced + unbraced assignment
concat, direct-use control, plain/braced assignment controls,
E316 + ` \!`, `\!` / `\#` guard preservation, E315/E317 neighbours,
C0 control. Fail-first (transplant onto base 6eb861b): 5 passed /
3 failed — exactly the 3 predicted cells. Post-fix: 8 passed /
0 failed.

Refs #3016
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 8, 2026 00:25
@caomengxuan666
caomengxuan666 merged commit 30ddc12 into master Nov 8, 2026
19 of 20 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 8, 2026
…2885)

- markers.rs census: add EXACT entry for __RUBASH_CURRENT_FILE
  (new carrier from #3035/#3047, missing from the E8 census).
- marker_registry_roundtrips: remove all four TYPED_DATA_EXCEPTIONS
  (E002 shapes 1-3 fixed by #2882/#3006; E316 shape 3 by #3016/#3041);
  the stem now asserts every shape round-trips.
- marker-lint-allowlist: delete the two #2882 KNOWN BLIND SPOT entries
  (their own text said delete when #2882 lands), plus two entries made
  stale by master-side changes: set.rs ESC rendering entry (#3044
  restructured the table) and command_prepare contains:QUOTED_NULL_MARKER
  (#3006 converted those consumers to E400-aware helpers).
- marker_leak_golden_pty: un-ignore the read -p cell (#3001 landed the
  read -p decode).
- marker_leak_golden: set-listing C0 scalar cell now expects the
  ansic-quoted GNU form (rubash#3017/#3044), byte-verified against
  GNU bash 5.3.20; the no-marker assertion is unchanged.

Verified on the merged tree (merge bd87ed1 + this commit):
lint OK (117 consts / 258 sites), registry 10/0, PTY 2/0,
golden 20/0, lib 1200/0/4, -D warnings rc=0, hygiene/fmt/CR clean.
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.

1 participant