Skip to content

[parse] multi-line [[ expression inside a function body: continuation line starting with || rejected ("conditional binary operator expected") — GNU accepts #505

Closed

Description

@caomengxuan666

证据源

wt92 生态快照重审计(2026-10-12,unixwin/niubash 分支 eco/reaudit-20261010):
sheldritch/sheldritch @ pinned core/args.sh 行 1303-1308 —— SYNTAX-REJECT-RUBASH-ONLY 桶里唯一在现行 master(1.4.0,41de8319)仍复现的真误拒。同桶其余 38 个唯一资产:20 个 GNU 平价(bash -n 同拒)、11 个快照后已修、4 个 zsh 方言/语料污染、3 个 ohmyzsh 系归因 zsh(见台账,另发 #452 评论)。

最小复现(已双向验证)

f() {
if [[
  ( -z "$ExactMatch" && "$ArityMin" = "$ArityMax" )
  || ((${#_ARGS_BOUNDS[@]} == 0))
]]; then
  :
fi
}
  • GNU bash 5.x:bash -n 通过(无需 extglob),实跑输出正常
  • rubash 1.4.0 master:rubash -n 与实跑均在续行处拒绝:
line 4: unexpected token `newline', conditional binary operator expected
line 4: syntax error near `((${#_ARGS_BOUNDS[@]} == 0))'
line 4: `  || ((${#_ARGS_BOUNDS[@]} == 0))'

要素矩阵(定位触发条件)

变体 rubash
同构造、无函数包裹 PASS
函数包裹、[[ ... ]] 单行 PASS
函数包裹、跨行、无注释 FAIL
函数包裹、跨行、tab 缩进(原始形态) FAIL

→ 触发条件 = 函数体内的跨行 [[ 表达式(换行后的 || 续行);注释/缩进无关。去掉函数包裹或并成单行即通过,说明是函数体上下文里 [[ 的换行续行状态没被带上。

关联

验收

  • 上述最小复现 rubash -n 通过、实跑与 GNU 一致
  • 原资产 sheldritch/sheldritch/core/args.sh(56KB)rubash -n 通过(现失败于行 1307)

Activity

  1. added
    bug
    on Oct 12, 2026
  2. caomengxuan666 commented on Oct 12, 2026

    @caomengxuan666
    MemberAuthor

    清偿代理回执(fix/legacy-505-431-433 → #571):

    • 根因:lexer 把命令位平衡 ((...)) 折叠成单 Keyword token,cond 收集器当单词操作数,续行换行在 binop 槽裸露。GNU 锚点 parse.y:3780(PST_CONDCMD 下 ( 按分组 token 投递)+ parse.y:5108/5140/5243(每个词项收尾 cond_skip_newlines)。
    • 修法:collect_conditional_args 把折叠 token 重切回 GNU 组 token 群(=~ RHS 例外,parse.y:5443 单词读)。
    • 验收:issue 最小复现 -n/实跑与 GNU 一致;原资产 sheldritch/sheldritch core/args.sh 56394B -n 通过(修前失败于行 1307);GNU 拒收形态控件不松动。
    • 回归:tests/issue505_multiline_cond_folded_arith_regressions.rs 15/15;全量失败集与 fresh master 逐名双向一致。
  3. added a commit that references this issue on Oct 12, 2026
  4. caomengxuan666 commented on Oct 12, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by #571 (legacy batch). Vendored-bash anchors and RED-then-GREEN regression evidence in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions