## 复现 ```bash echo `case x in` ``` | | stdout+stderr | rc | |---|---|---| | GNU bash 5.3.0 | ``bash: command substitution: line 2: syntax error: unexpected end of file from `case' command on line 1`` + 空行 | **0** | | rubash 764b9dde | `...: line 1: syntax error near unexpected end of file` + `...: syntax error in command substitution` | **2**(无输出) | ## 根因 反引号替换内的语法错误在 bash(非 posix 模式)是**非致命**的:报错后替换取空值,外层命令照常执行(`echo` 打印空行),rc=0,脚本继续。rubash 把替换内解析错误升级为整壳致命(rc=2、后续输入全部丢弃)。 ## 规范/源码依据 - bash 手册(Command Substitution / POSIX mode 差异):非 posix 模式下替换内语法错误报错后继续。 - GNU 实测:替换报错 → 输出空行 rc=0;posix 模式下 bash 才会致命(rubash 行为相当于永远 posix 化了这一路径)。 ## 跨实现互证(huck) [huck#215 "backtick command-substitution syntax error: huck aborts where bash recovers (empty subst, rc 0)"](https://github.com/jdstanhope/huck/issues/215)(sev:low→已修复)——**逐字同一语义点**:反引号语法错误应恢复(空替换)而非中止。huck 修复可作参考。 ## 证据 - 语料出处:comsub_marker_diag_diff_check.sh:20(F001,label: bt-unterm-case) - 复核:764b9dde 仍复现;旧构建 41de8319 行为一致
Activity
caomengxuan666 commentedon Oct 12, 2026
审计增量(huck 443-issue 全量对照,issues-audit we-diverge A10):多命令脚本级复现确认本 issue 在 764b9dd 仍复现,且补 huck 侧两条同族互证:
BEFORE、AFTER都照跑,rc=0,脚本继续。BEFORE,rc=2 整个输入中止,AFTER丢失。huck 侧互证(除正文 #215 外):
根因模型注:#493(rubash 把 backtick/
${}体当 parse 期错误)是同一模型问题的两面——${x[}半(parse 期杀全脚本、GNU 运行期 bad substitution 只丢当前命令)已另开姊妹 issue。fix: Wave4a P2 batch - redirect ambiguity gate, backtick diagnostic w…
caomengxuan666 commentedon Oct 12, 2026
Fixed by #576 (Wave4a). Vendored-bash anchors and RED-then-GREEN regression evidence in the PR.
Refs #1184 f6 follow-up: withhold the backquote-body terminator after…
fix: -c string comsub read-time failure exits 127 (#2787)
fix(executor): contain arith-fallback comsub parse errors
Refs unixwin#1184 f6: two-layer backquote EOF diagnostic (v2 design)