Repository navigation
Description
Found by captain spot-check during the wt23/hist274 recovery (probe files under target/pd4.sh / target/pd5.sh). Pre-existing at 2e6b0e9 (= the 1.2.1 release lineage) — byte-identical failure on pristine base and current master; NOT a regression from 2ad6c17/b5b78aab. Shipped in 1.2.1.
Reproducer (WSL GNU Bash 5.3.0 script-file oracle)
echo "$((1+1)):$((2+2))" # GNU: 2:4 rubash: rc=1, no outputrubash stderr: pd4.sh: line 1: 1+1)):4: arithmetic syntax error in expression (error token is ")):4")
Evidence matrix (all GNU-verified; rubash output vs GNU)
| input | rubash | GNU |
|---|---|---|
echo "$((1+1)):$((2+2))" |
ERROR 1+1)):4, empty stdout |
2:4 |
echo $((1+1)):$((2+2)) (unquoted) |
ERROR 1+1)):4 |
2:4 |
echo "$((1+1)) $((2+2))" (space) |
ERROR 1+1)) 4 |
2 4 |
echo "$((1+1)).$((2+2))" |
ERROR 1+1)).4 |
2.4 |
echo "$((1+1))-$((2+2))" |
ERROR 1+1))-4 |
2-4 |
echo "$((1+1)):$((2+2)):$((3+3))" (triple) |
ERROR 1+1)):4:6 |
2:4:6 |
v=9; echo "$((v)):$((v))" (vars) |
ERROR v)):9 |
9:9 |
echo "$((1+1)):$PATH" (param 2nd) |
OK | ok |
echo "$PATH:$((1+1))" (param 1st) |
OK | ok |
echo "a$((1+1))b$((2+2))c" (alnum-adjacent) |
OK a2b4c |
same |
single "$((expr))" any shape |
OK | ok |
Class boundary and mechanism evidence
Fires when a word contains two or more $((...)) separated only by non-alnum material (: space . -); alnum-adjacent material or a $param on either side avoids it. The error text pattern is diagnostic: first-raw-body + "))" + separator + <EXPANDED VALUES of the later comsubs> — e.g. triple colon gives 1+1)):4:6. That means the FIRST comsub's body slice greedily extends to the LAST )) of the word, the swallowed later $((...)) spans are then expanded (their values appear in the error), and the merged text fails the arithmetic parse. A span-matcher admission/anchoring bug in the word-level $(( scanner — the rubash#117 fast-path family shape.
GNU spec pointer for the fix lane
parse.y:5305 read_token_word() — on $(( the walker delegates to the arithmetic-command branch and the matched-pair machinery (parse.y:3877 parse_matched_pair()); each subsequent $(( is its own word event. Fix must make our span slicing anchor per-$(( (innermost/closest-first) instead of word-greedy. No whack-a-mole: if this lives on a text-layer fast path, converge it to the real scanner per AGENTS.md.
Upstream arith.tests has no )):$(( shape (verified by grep) — corpus blind spot; our gnusweep probes also missed it. Suggest adding the 11-shape matrix above as a regression fixture (tests/regression/fixtures or a new issueNNN suite) together with the fix.
Activity
docs: record wt23/hist274 recovery (ArithDynamicContext, #368 root ca…
fix(executor): whole-word $((...)) admission uses the real span scann…
caomengxuan666 commentedon Oct 1, 2026
Landed as d1cdb7b (cherry-picked from wt24/adjcomsub lane commit d8fa09be): new whole_word_arithmetic_substitution_body real span scanner (paren depth from 2, quotes/escapes opaque, admits only when the first balanced
))is the word's final characters) replacing the naive strip_prefix/strip_suffix admissions at parameter_core/expand_word/command_prepare. GNU spec: parse.y:3877 parse_matched_pair closes at the FIRST balanced))(parse.y:3988), each later$((is an independent word event (parse.y:5521). 14-test regression suite + 3 scanner unit tests; 11-shape matrix and expanded class boundary byte-identical to WSL GNU 5.3.0; carrier-domain (#354 family) and true-baseline slices unchanged. CI green on d1cdb7b. Incidental pre-existing gap ($'\n'between comsubs folded to space) filed separately.docs: record wt24 recovery (#376/#369/#370 closed, #377-#379 opened, …
fix(#377): unquoted compound-assignment fan-out pathname-expands its …