Skip to content

[bug] Parser rejects GNU-valid input: ((# 1 + 2)), { foo } }; }, pattern-replacement with $'\'' quote, heredoc after 'cat <<EOF ;;' in case arm, [[ a =~ ( ]]<>;&) ]] #222

Closed

Description

@caomengxuan666

Found via mvdan/sh parser-corpus -n parity run (ecosuite lane; family 3 of 3). rubash -n returns 2 where WSL GNU Bash 5.3.0 returns 0:

file input rubash stderr (head) GNU
t0026.sh ((# 1 + 2)) line 2: syntax error: unexpected e... 0
t0164.sh { foo } }; } line 1: syntax error near unexpect... 0
t0286.sh ${foo/$a/$'\''} line 1: unexpected EOF while looki... 0
t0383.sh case $i in 1) cat <<EOF ;; + heredoc body + EOF + esac line 1: syntax error near unexpect... 0
t0411.sh [[ a =~ ( ]]<>;&) ]] line 1: syntax error near unexpect... 0

Notes and GNU C source owners:

  • ((# 1 + 2)): bash parses ((-arithmetic; # inside arithmetic is not a word-level comment start and the expression parses (GNU accepts, rc 0). rubash errors.
  • { foo } }; }: a } that does not follow a command terminator is a literal word inside the group; GNU's parse.y:1196 group_command: '{' compound_list '}' closes on the DELIMITED }. rubash mis-scans and errors. (Related direction to rubash#219: brace-scan termination, here over-strict.)
  • ${foo/$a/$'\''}: pattern-replacement with $'...' containing an escaped quote — same quoting-in-expansion family as rubash#211 (FUNSUB escaped quote) and rubash#138; rubash reports unexpected EOF, GNU parses.
  • heredoc in a case arm (1) cat <<EOF ;; with body following before esac): GNU attaches the here-document after the ;; across the arm boundary (parse.y here-doc queue). rubash errors at line 1.
  • [[ a =~ ( ]]<>;&) ]]: GNU's =~ regex scan finds the terminating ]] correctly (the inner ]]<>;&) stays inside the regex). rubash terminates early and chokes on <>;&). Over-strict direction of the rubash#129 family ([[ =~ ]] ERE scanning).

Artifacts: target/issue-suites/results/ecosuite/mvdan-n/ (matrix.txt 559 rows / 16 diverge, per-file .rub.err/.gnu.err), corpus target/ecosuite/mvdan-corpus/ extracted from mvdan/sh @ aebdf2b86f56f96eb885260bb03827aa5fc94ec4.

Lane: wt4/ecosuite evaluation suites (no src/ fixes in lane).

Activity

  1. added 2 commits that reference this issue on Sep 27, 2026
  2. caomengxuan666 commented on Sep 27, 2026

    @caomengxuan666
    MemberAuthor

    已修复并合入 master(commit d3e8aff,lane wt4/ecofix,GNU 引用见提交;探针/夹具与 WSL GNU 5.3.0 字节一致)。感谢报告!

  3. added
    bug
    area:parser
    on Oct 17, 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

    area:parserbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions