Repository navigation
fix(executor): dual quote-state for subscript ANSI-C spans + unset operand quote-removal (rubash#847) - #857
Conversation
…erand quote-removal (rubash#847) Two faces left in the span-state family after #839: 1. E3b - the #822 assignment/reader decode_ansi_c_spans scanner tracked only single-quote state, so a span INSIDE double quotes was decoded anyway: master stored the merged prexpost for M["pre$'x'post"]=w. GNU's expand_word_internal never recognizes ANSI-C quoting inside dquotes - the spelling is data and the key stays pre$'x'post (70726524277827706f7374) on the assignment entry, the ((...)) entry and the ${...} reader alike. Mirror the #839 dual-state law into decode_ansi_c_spans: $' opens a span only outside both quotes, '/" toggle only outside the other quote. 2. u-family - unset's deferred operand pass decoded a quoted-source $'...' spelling down to the stored clean key and deleted the cell (the CR Nit 2 divergence #839 pinned). GNU's deferred expand_subscript_string pass quote-removes it instead: the quotes drop, the span dollar stays literal, the content rides verbatim ($'x' resolves the key $x - gnu9 probe: with a literal $x cell present the unset deletes THAT cell) - so u1/u2/u3 keep the $'...'-written cell. quote_remove_ansi_c_spans mirrors the same dual-state law on mark_arith_span_data carriers; $k-style operands still expand (P3 probe) and the bare/variable spellings still delete (g1/V7, u5). 3. A kept span on the arith entry landed in storage with a raw \x17 carrier mid-key - expand_assoc_subscript_once now dequotes the final key text through decode_word_position_carriers (the subst.c:4807 dequote_string port the other word-position consumers use). Tests: tests/issue828 grows the E3b family (assignment/reader/arith variable-read rows, dq-adjacency and dq-escaped-backslash shapes, E3/E1 non-regressions) and the u-family rows (u1/u2/u3 keep, literal-dollar hit, bare/variable/param non-regressions); the CR Nit 2 divergence pin flips to parity. scripts/regression-catalog gains issue-847.sh + a must-match row; the stale issue-734 row flips to must-match on catalog PROMOTE (verified matching already on pristine b79e678).
CR #857 — 独立复核结论:APPROVE-WITH-NITS(无 BLOCKER,可合并;不代合并)不复述实现者主张,以下全部独立实做(自建 worktree 1. 双态法则一致性(核心审计)
2. GNU 语义核对(WSL 5.3.0 oracle 自跑,三方 GNU/master/fix)目录 case 11 行逐字节一致;另自设 28 探针(dq 相邻文本、dq 转义反斜杠、跨入口互读、跨度内容含 3. Face ③ 位置正确性
4. 目录 PROMOTE 复核b79e678 干净树 build 后跑 5. 回归
6. 夹带扫描merge-base diff 恰 6 文件(2 src + 1 unset + 2 tests/catalog + manifest);无进程/杀进程面;GPL:注释仅引 GNU 源码行号坐标,无源码拷入。 NITS(非阻塞)
残余差异立票判断(应立)PR "Out of scope" 两项均真实、master 相等(已复核),但目前均无 open issue 跟踪,而本 PR 合并即关 #847 —— 建议立即立票,症状可直接搬运 PR 原文:
(复核产物:三方探针脚本 + 双向全量日志在 cr 代理侧存档;本 worktree 及基线 worktree 评审完即删。) |
Closes #847 (both faces).
Face 1 — E3b: the #822
decode_ansi_c_spansscanner lacked double-quote statedecode_ansi_c_spanstracked onlyin_single, so aprexpostforM["pre\$'x'post"]=w.GNU's
expand_word_internalnever recognizes ANSI-C quoting inside dquotes — the whole spelling is data and the key stayspre$'x'post(70726524277827706f7374), verified identical on the assignment entry, the((...))entry and the${...}reader (the reader self-readgrand the arith-write variable read missed on master; both hit after the fix).Fix: mirror the #839 dual-state law ($\$'$ opens a span only outside both quotes,
transform_arith_ansi_c_spans) intodecode_ansi_c_spans—'/"toggle their own state only outside the other quote. Bare (E3) and sq-piece (E1) shapes are untouched and pinned as non-regressions.Face 2 — u-family: unset's deferred operand pass decoded quoted-source$\$'...'$ spellings
unset 'A[\$'"'"'x\\ty'"'"']'/unset "A[\$'x\\ty']"— GNU 5.3.0 keeps theFix:
quote_remove_ansi_c_spans(same dual-state scanner law) — GNU's deferred pass quote-removes the spelling: quotes drop, the span dollar stays literal, content rides verbatim, soA[\$'x']resolves the key$x(discriminating probe: with a literal$xcell present, that cell is the one deleted). Non-regressions pinned: the bare spelling still decodes at word expansion and deletes (g1/V7), the variable spelling still expands and deletes (u5), and a$koperand without a span still expands from a single-quoted source (P3).Carry-out: carrier decode on the arith entry
A kept span on the
((...))entry stored a raw\x17carrier mid-key (master's variable-spelling read of((G["pre\$'x'post"]=1))missed).expand_assoc_subscript_oncenow dequotes the final key throughdecode_word_position_carriers(thesubst.c:4807dequote_string port other word-position consumers already use).Out of scope (observed during probing, pre-existing on master, left for follow-ups)
unset 'A4[\\\ty]'withxunset: rubash reports[\\\ty]: bad array subscript(mask-before-expand folds$x+\\tyinto$xty→ empty key); GNU keeps silently (nonempty key). No span involved — mask/expansion ordering, its own ticket.K=( ["pre\$'x'post'"]=v )stores the right listed key bytes but the same-spelling read misses (hidden bytes in the kvlist dequote path).kv=write row is parity on master and here; the read face is unchanged by this PR.Verification (WSL GNU bash 5.3.0 oracle, three-way GNU / master b79e678 / fix)
M["pre\$'x'post"]=wkey bytes70726524277827706f737470726578706f7374(prexpost)70726524277827706f7374${G["pre\$'x'post"]}after((...))write11unset 'A1[\$'"'"'x\\ty'"'"']'/ u2 dq / u3 dq-escaped$xcell +unset "C[\\\$'x']"$x, keepsx$x, keepsxtests/issue82839/39 (25 fix(arithmetic): normalize assoc subscripts on the ((...))/let entry (rubash#828) #839 pins + 14 new/updated incl. the flipped CR Nit 2 pin),tests/issue73415/15; fullcargo test --no-fail-fast -- --test-threads=1bidirectional vs pristine b79e678: zero new failures, zero flipped (24 failures on both sides, all machine-state: partial Niubash toolchain —opt/niugit/git.exemissing, tilde-user passwd faces — plus the known-flakyexecutor::pathcache test that flaked only on the master run).issue-847case + manifest row (must-match), full runner 36/36 against declared expectations;issue-734row flipped tomust-matchon catalog PROMOTE (verified matching already on pristine b79e678).cargo fmt --checkclean;RUSTFLAGS="-D warnings" cargo build --releaseclean. Master advanced during the branch (build(package): exclude target-variant dirs from the crate — guard against >10MiB upload rejection #851/test(interactive): pin (A;B);) stray-close family to GNU 5.3.0 across all modes (#845) #852) — merged and re-verified.