## 复现 ```bash echo $((echo hi) 2>&1) ``` ```bash echo $((echo a) | tr a-z A-Z) ``` | 片段 | GNU bash 5.3.0 | rubash 764b9dde | |---|---|---| | F158 | `hi`,rc=0 | `...: arithmetic syntax error in expression (error token is "hi) 2>&")`,rc=1 | | F159 | `A`,rc=0 | `...: arithmetic syntax error in expression (error token is "a) | tr a-z A-")`,rc=1 | ## 根因 `$((` 存在算术/命令替换二义性。bash 的裁决:先按算术表达式扫描,**一旦确定不是算术表达式即回退按命令替换解析**(`$((echo hi) 2>&1)` ≡ `$( (echo hi) 2>&1 )`),输出 `hi`。rubash 强制按算术解析,报语法错误且 rc=1。 ## 规范/源码依据 - POSIX XCU 2.6.4 对 `$((` 二义性的处理约定 + bash 实际行为(命令替换回退)。 - 判据取自 GNU 实测:`$((echo hi) 2>&1)` 输出 `hi`;`echo $((echo hi))` bash 同样输出 `hi`(同根因的无重定向形态)。 ## 跨实现互证(huck) huck 有同名 harness(dollar_paren_subshell,divergence 442 条之列,其契约即 ==GNU);算术行为总账见 [huck#60 "Remaining arithmetic behavioral divergences (post-v216)"](https://github.com/jdstanhope/huck/issues/60)(open)——`$((` 回退属其跟踪的算术分歧面。 ## 证据 - 语料出处:dollar_paren_subshell_diff_check.sh:17-18(F158/F159) - 复核:764b9dde 仍复现;旧构建 41de8319 行为一致
Activity
fix: Wave4a P2 batch - redirect ambiguity gate, backtick diagnostic w…
caomengxuan666 commentedon Oct 12, 2026
Fixed by the merged Wave batch (#576 for #512/#513, #569 for #550). RED-then-GREEN regression evidence in the PR.
fix: take the $(( arithmetic verdict at the (( opener at six lexer sc…