## 复现 ```bash echo "[$(echo hi # c with ) paren )]" ``` | | stdout | rc | |---|---|---| | GNU bash 5.3.0 | `[hi]` | 0 | | rubash 764b9dde | `[hi paren` + 换行 + `)]` | 0 | ## 根因 `$( ... )` 体内的 `#` 注释延伸到行尾,注释中的 `)` 不应终结替换。rubash 在扫描替换终结符时未跳过注释,被注释内的 `)` 提前截断:`$(echo hi # c with )` 被当成替换体,剩余 ` paren\n)]` 按普通文本输出。 ## 规范/源码依据 - XCU 2.3 Token Recognition:`#` 开启注释至行尾,注释内容不参与 token 化——该规则在 `$( )` 扫描域内同样适用。 - bash 源码 parser(parse.y read_token 路径):`$(` 体扫描中注释由 lexer 统一吞掉,`]`/`)` 只有在 token 位置才参与配对。 ## 跨实现互证(huck) [huck#109 "Comment inside `$(...)` body mis-parsed as syntax error (comment-after-open / comment-only body)"](https://github.com/jdstanhope/huck/issues/109)(已修复)——同一语义点(cmdsub 体对注释的处理),huck 修复覆盖注释后内容/纯注释体;本例(注释内的 `)`)是其对偶表现,huck 修复后同样正确。 ## 证据 - 语料出处:cmdsub_comment_diff_check.sh:14(F049,label: paren in comment) - 复核: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(executor,lexer): #880 rework -- close the two PR#898 review block…