Repository navigation
fix(executor): mark_quoted_ifs_from_raw applies quoted-IFS marks on the recorded byte-offset basis (#876) - #882
Conversation
…he recorded byte-offset basis (#876) push_quoted_char recorded quoted IFS positions as simulated.len() — a BYTE offset — while the apply loop counted one per char. A multi-byte char before a quoted IFS char shifted every later record past the loop's counter, so the \x1c glue never landed on the recorded char and the splitter released it: with IFS=' :', "é a"$w split into <é><aW> where GNU keeps <é aW> (the 2-byte é puts the space at byte 2; the loop asked at char 1). The quoted non-whitespace faces were backstopped by mark_literal_ifs_chars, which is why only the whitespace face diverged — and #874's carrier awareness lets more multi-byte words through the simulation gate, widening the reach (the #874 CR prediction). The apply loop now advances its counter by ch.len_utf8() — the same byte units push_quoted_char records. IFS_GLUE keeps being skipped without advancing the counter, so the counter always names the byte offset of the current char in cooked (== simulated, pinned by the equality guard). The #874 carrier arms and the #868 double-mark protection land above this fix and are untouched. GNU spec: quoted source characters are CTLESC-protected during expansion (subst.c:11639-11673) and the field splitter skips them (subst.c:3119 list_string) — protection is per-character and byte-transparent. Verification (WSL GNU bash 5.3.0 oracle, cat script | wsl bash -s with tr -d '\0', byte-exact both sides): - 24-shape battery (é/中文/ä/emoji leads x quoted blank/colon/tab x single-quote/escape/nested/ANSI-C-decode/carrier-tail/unset/after-close faces + ASCII controls): all byte-match GNU; master 41bfdd3 diverged on 11 of the 24. - New regressions tests/issue876_multibyte_quoted_ifs_mark_regressions.rs (7 cases) + regression-catalog case issue-876 (diverges on master 41bfdd3, must-match here). - No-regression: #868 7 cases + the #874 family 107 cases (#298 12, #795 arrdefault 11 + parameter_transform 18, #843 12, #315 5, #369 7, #428 14, #432 13, marker_leak_golden 8) all green. - Full suite --no-fail-fast --test-threads=1 both sides vs pristine base 41bfdd3: fix 5640 passed / 37 failed vs base 5634 / 36 (+7 new tests); failure sets identical except profiler fixture_text_tree_matches_normalized_output, a pre-existing timing flake that also fails standalone runs on pristine base (4/6). Zero new failures. - cargo fmt --check clean (fmt also fixed a pre-existing 2-line use-order in command_prepare's test module, required by the fmt hook); rustc check warnings 28/28 base/fix, clippy 549/549 — zero new. closes #876
Independent CR review of PR #882 (fix/876 @ bfae5df vs base 41bfdd3) — verdict: APPROVEFull re-verification performed on an isolated worktree ( 1. Diff scope — verified minimal. Exactly one code line ( 2. Byte-basis audit (core) — correct for all widths. 3. GNU 5.3.0 oracle — re-run independently, byte-exact. WSL 4. Regressions — all green, run by me. New 7/7; #868 7/7; family per the PR's own enumeration: #298 12, arrdefault 11, parameter_transform 18, #843 12, #315 5, #369 7, #428 14, #432 13, marker_leak_golden 8 = 100/100. Catalog runner: exit 0 on two runs, 5. Full suite, both directions, 6. fmt / warnings — clean. Non-blocking notes
Verdict: APPROVE — the record/apply bases are now provably the same units, the guard that backs them ( |
Closes #876. Third defect in
mark_quoted_ifs_from_rawfrom the #874 CR round (pre-existing on master; #874's carrier awareness lets more multi-byte words through the simulation gate, widening the reach — the #874 CR prediction). #874's carrier arms and the #868 double-mark protection land above this fix and are preserved untouched.Problem
push_quoted_charrecords quoted IFS positions assimulated.len()— a byte offset — while the apply loop counted one perchar. A multi-byte char before a quoted IFS char shifts every later record past the loop's counter, so the\x1cglue never lands on the recorded char and the field splitter releases it:The 2-byte
éputs the quoted space at byte 2; the loop asked at char 1. Quoted non-whitespace IFS chars were backstopped bymark_literal_ifs_chars, which is why only the whitespace face diverged.Fix
The apply loop advances its position counter by
ch.len_utf8()— the same byte unitspush_quoted_charrecords (cooked_pos += 1→cooked_pos += ch.len_utf8(), plus basis comments).IFS_GLUEkeeps being skipped without advancing the counter, so the counter always names the byte offset of the current char incooked(==simulated, pinned by the equality guard).GNU spec: quoted source characters are CTLESC-protected during expansion (
subst.c:11639-11673) and the field splitter skips them (subst.c:3119 list_string) — protection is per-character and byte-transparent.Verification
WSL GNU bash 5.3.0 (
/usr/local/bin/bash) oracle,cat script | wsl bash -swithtr -d '\0', byte-exact both sides:tests/issue876_multibyte_quoted_ifs_mark_regressions.rs(7 cases, expectations GNU-verified) + regression-catalog caseissue-876(diverges on master 41bfdd3, must-match here). No-regression: mark_quoted_ifs_from_raw simulator is carrier-blind: carrier-laden raw words silently lose per-char IFS marking #868 7 cases + the fix(executor): mark_quoted_ifs_from_raw recognizes markers.rs carrier bytes (#868) #874 family 107 cases ([bug] Unquoted positional parameter in array assignment is not word-split on IFS: set -- a.b.c; IFS=.; A=($1) gives 1 element (GNU 3) — breaks OMB _omb_util_split / half-life git version compare #298 12, #789 splitting rework: two field-splitting regressions vs GNU 5.3.0 (nested-quote guard + ${$+<nl>}) #795 arrdefault 11 + parameter_transform 18, patsub 替换文本的用户 PUA 码点未 E400 转义,与 PATSUB 标记碰撞(release 可复现)——#838 CR NIT-3 #843 12, [bug] inside guard reports SET for unset element; empty quoted element dropped in unquoted slice assignment c=( ${b[@]+"${b[@]:0:2}"} ) — liquidprompt test_array 2/3 fail #315 5, regression(8c52cb7f): wholly-quoted compound-assignment element undergoes pathname expansion — arr=("$x") globs when x='*' #369 7, [P1] variable assigned via ${V:=default} never word-splits again (breaks bash-it powerline segment loops) #428 14, [P2] compound-array quoted default ${v:=x y} inside ("${v:=x y}") stores wrong elements (wt66-adjacent family) #432 13, marker_leak_golden 8) all green.cargo test --no-fail-fast --test-threads=1both sides vs pristine base 41bfdd3 — fix5640 passed / 37 failedvs base5634 / 36(+7 new tests); failure sets identical except profilerfixture_text_tree_matches_normalized_output, a pre-existing timing flake that also fails standalone runs on pristine base (4/6). Zero new failures.cargo fmt --checkclean (fmt also fixed a pre-existing 2-line use-order in command_prepare's test module, required by the fmt hook); rustc check warnings 28/28 base/fix, clippy 549/549 — zero new.