Skip to content

[P1][parse] multi-line arithmetic command with (grouped assign) + comma-newline rejected; GNU 5.3.0 accepts — breaks 6 ble.sh files #435

Closed

Description

@caomengxuan666

Found by the wt97b/hres ecosystem-harvest gold triage (fresh master build, niu 1.3.4 @ 04d7b7f; rubash 8ff0d05).

Minimal repro

a=1 b=2 c=3
((a&&(b=1),
  c+=${a}))
  • GNU bash 5.3.0 (WSL /usr/local/bin/bash, file-arg): bash -n rc=0, runtime rc=0
  • rubash -n (8ff0d05): rc=2 line 2: syntax error near unexpected token ','
  • niu runtime: rc=2, diagnostic rewrites the construct to a && ( b=1 ) , ; — the arithmetic command is terminated at the comma-newline and the continuation is parsed as a fresh command

Variant matrix (all GNU-accepted, all rubash/niu-rejected unless noted):

  • ((a||(b=1),\n c+=${a})) fails (|| too)
  • ((a&&(b[i+1]=1),\n c+=${#a})) fails (array subscripts fine elsewhere)
  • same construct on ONE line passes; c+=${#a} )) (space before ))) passes; $(( ... )) substitution form passes

So the trigger class is: two-line (( )) + (...)-grouped assignment before the comma + newline continuation.

Real-world impact (ble.sh — akinomyoga/ble.sh, the flagship bash line editor)

All six GNU -n-accept (rc=0); rubash -n rejects all six; for canvas/color/edit GNU runtime rc=0 while niu runtime rc=2:

file rubash -n failing line construct
lib/core-syntax.sh:3975 ((${#rematch2}>=2&&(_ble_syntax_attr[i+1]=CTX_CMDXC, grouped assign + comma-NL
lib/init-term.sh:313 ((j1=(i1==3?6: ternary across lines
lib/keymap.vi.sh:3488 ((index=(bol+${COLUMNS:-eol})/2, comma-NL chain
src/canvas.sh:335 `0x3100<=code&&code<0xA4D0
src/color.sh:539 x+=Range*(h2<60?h2:60)/60, compound assign + comma-NL
src/edit.sh:5330 _ble_edit_mark<iend?( ternary-NL

This blocks sourcing ble.sh under niu/rubash — a high-value ecosystem entry point.

GNU C source anchor (specification)

  • parse.y:4904 parse_dparen() — (( dispatch (reserved_word_acceptable path returns ARITH_CMD)
  • parse.y:4963 parse_arith_cmd() — "Look for the matching ))": the body scan carries newlines as ordinary characters; nothing terminates at a newline
  • parse.y:1203 grammar arith_command: ARITH_CMD; newline is plain whitespace inside the arithmetic expression (expr.c evaluator)

rubash's ((-body scanner apparently ends/invalidates the command at the newline after (...)+comma instead of scanning to the matching )).

Evidence paths

  • Repro files: E:/eco-harvest/tmp/arith/q1.sh (minimal), w3.sh, z1-z6.sh, c1.sh/c2.sh (verbatim ble.sh lines)
  • Full 6 files + 4-way ladder (GNU -n / rubash -n / GNU rt / niu rt): E:/eco-harvest/tmp/gold-sr/, driver D:/eco-harvest/scratch/syntax-ladder-wt97b.py
  • Original gold rows: D:/eco-harvest/results/test-results.jsonl (hashes bb7c22c7…, 8b99971a…, d325949b…, 5900462c…, f4cb220f…, 651b1578…)

Activity

  1. added
    bug
    gnu-baseline
    on Oct 5, 2026
  2. changed the title [-][P1][parse] multi-line arithmetic command rejected; GNU 5.3.0 accepts — breaks 6 ble.sh files[/-] [+][P1][parse] multi-line arithmetic command with (grouped assign) + comma-newline rejected; GNU 5.3.0 accepts — breaks 6 ble.sh files[/+] on Oct 5, 2026
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

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions