## 现象 跨行的算术命令 `(( ... ))`(换行后以 `||` 续行)在 rubash 下报 `arithmetic syntax error` 并**整体按假处理**——条件求值结果错误 + 诊断泄漏。GNU Bash 5.3.0 正常跨行求值。`$(( ))` 赋值形式的同形跨行**正常**,只有 `if (( ))` 命令形式坏。 生产杀伤: portage 的 `bin/ebuild.sh`(~850 行 EAPI 处理入口)第 44 行 bash 版本门禁就是跨行 `if (( BASH_VERSINFO[0] < maj\n\t\t|| (BASH_VERSINFO[0] == maj && BASH_VERSINFO[1] < min) ))` ——rubash 直接死在门禁上,整个 ebuild 相位机制(~2k 行 EAPI 酷刑)无法进入。GNU 侧继续走到标准 die() 报错(`PORTAGE_PYM_PATH does not exist`),证明语义链完整。 ## 最小复现 `probe-arith2.sh`(LF 落盘,双侧脚本文件运行): ```sh a=9 b=3 c=4 maj=5 min=3 if (( a > maj || (a == maj && c < min) )) then echo "lt-branch"; else echo "ge-branch"; fi ``` | | GNU 5.3.0 | rubash 8f897670 | |---|---|---| | stdout | `lt-branch` | **`ge-branch`(错误分支)** | | stderr | 空 | `probe-arith2.sh: line 2: ((: a > maj; || (...): arithmetic syntax error: invalid arithmetic operator (error token is "; || ...")` | 注意错误 token 里的 `maj;` —— rubash 把换行折叠成了 `;` 再喂给算术求值器(`;` 不是合法算术符)。而 `$(( ))` 赋值形式的跨行(`v=$(( 1\n || 0 ))` → 1、`w=$(( 1 +\n 2 ))` → 3)双侧一致正常(probe-arith.sh)。 ## ebuild.sh 现场 ``` rub stderr: ./ebuild.sh: line 44: ((: BASH_VERSINFO[0] < maj; || (BASH_VERSINFO[0] == maj && BASH_VERSINFO[1] < min) : arithmetic syntax error ... gnu stdout: * ERROR: /:: failed (setup phase): PORTAGE_PYM_PATH does not exist ... (走完版本门禁后的正常 die) ``` 源(portage bin/ebuild.sh:43-44): ```sh if (( BASH_VERSINFO[0] < maj || (BASH_VERSINFO[0] == maj && BASH_VERSINFO[1] < min) )) ``` ## 定位建议 `(( ))` 命令的词法收集在换行处提前终止并把换行折为 `;`;GNU 的算术命令读取直到匹配 `))`(跨行合法)。对照 GNU expr parser: expr.c `exprec()`/`read_token` 在 arithmetic 上下文吃掉换行。 版本: rubash 8f897670 (target-wire/debug), 对照 WSL GNU Bash 5.3.0(1)-release。 产物: `D:/repo/rubash/target-ecosys6/out/{arith.*,arith2.*,ebuild.*}`
Activity
caomengxuan666 commentedon Sep 27, 2026
已在 51df49a 修复并关闭(commit 48089806,四单合一)。GNU 锚点与矩阵见 issue 评论区独立说明。