Skip to content

[bug] Parser over-lax ×4 from the ShellCheck unit-test corpus: [[ 3 \< 4 ]], 'true | ! true', var=( (1 2) (3 4) ), var=(1 [2]=(3 4)) — all rejected by GNU 5.3.0 #360

Closed

Description

@caomengxuan666

Found by ecosweep4 lane (wt22/nest22; corpus: ShellCheck's own embedded unit tests, 2164 prop_* snippets extracted from src/ShellCheck/*.hs, bash -n rc-parity vs WSL GNU Bash 5.3.0 script-file runs; worktree base a522eb3, release build).

2164 probes: 2157 parity, 7 divergent → 4 distinct shapes. This issue = the 4 over-lax shapes (rubash rc=0 accept where GNU rc=1/2 rejects); the 1 over-strict shape is a separate issue.

1. [[ 3 \< 4 ]] — escaped operator in conditional

  • rubash -n: rc=0 (accepted)
  • GNU 5.3.0: line 1: unexpected token <', conditional binary operator expected+syntax error near `<`` (rc=2)

GNU owner: parse.y:5080 cond_term() — after the lhs WORD, the binary-operator slot only accepts WORDs in test_binop() or the raw tok == '<' || tok == '>' tokens (parse.y:5156-5174); the escaped \< arrives as a WORD that matches neither → the error branch at parse.y:5179-5191. rubash accepts \< as an operator.

2. true | ! true — ! after a pipe

  • rubash: rc=0 (accepted)
  • GNU: syntax error near unexpected token !`` (rc=2)

GNU owner: parse.y:1410 pipeline_command: ... | BANG pipeline_command — ! may only prefix a whole pipeline_command, never appear in command position after |. rubash admits the reserved word mid-pipeline. (Same text appears twice in the corpus: Parser_2066/ShellSupport_1846 shapes.)

3./4. Array-assignment nested parens

var=( (1 2) (3 4) ), var=( 1 [2]=(3 4) ), var=(1 [2]=(3 4)) (three snippet forms):

  • rubash: rc=0 (accepted)
  • GNU: syntax error near unexpected token ('` (rc=2)

GNU owner: parse.y:7104 parse_compound_assignment() — the element loop (~parse.y:7145) accepts only WORD and ASSIGNMENT_WORD tokens; a bare ( subshell token inside the array body hits the error path. Note foo=([) over-acceptance was already filed in rubash#221 for the mvdan corpus — same acceptance surface, different constructs (parenthesized element and per-index [i]=(...) compound), both still accepted at this base.

Corpus pointers

  • Probes: target/issue-suites/results/ecosweep4/sc/snips/{Analytics_0255,Parser_2069,ShellSupport_1846,Parser_2144,Parser_2145,Parser_2146}.sh
  • rc matrix: target/issue-suites/results/ecosweep4/sc/{rub,gnu}.rc.txt, diverge list sc/diverge.txt
  • Extractor: sc/extract.py (Haskell string unescape incl. numeric escapes)

Classification: rubash-caused (parser admission), over-lax direction. Related families: #220 (mksh/zsh operators over-lax), #221 (GNU-invalid constructs over-lax) — these four shapes are NOT covered by the mvdan corpus.

Activity

  1. added
    bug
    on Sep 30, 2026
  2. added a commit that references this issue on Sep 30, 2026
  3. caomengxuan666 commented on Sep 30, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt22/p0fix (7c4d580, master 3ade4b2): four over-lax admissions, all GNU-anchored. (1) [[ 3 < 4 ]] — the operator slot matched on the DEQUOTED value; now matches on the raw (GNU tests the word text before quote removal) and the error text/offending-line echo uses the raw with the full physical line (print_offending_line parse.y:6814). (2) true | ! true — BANG admission now rejects immediately-after-a-pipeline-segment (parse.y:1408-1413: BANG only prefixes a whole pipeline_command); &&/;/if/{ } all still legal (GNU matrix). (3)(4) array ( element positions and after [i]=( — the compound-assignment ctrl-op scanner gains ( (parse.y:7104-7160 element loop takes WORD/ASSIGNMENT_WORD only). Full ShellCheck corpus re-run: 2163/2164 (the one left is #361). cond 100=100, array 8=8, errors 2=2. 9 regressions.

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