Skip to content

[bug] Lexer dies on escaped quote + backtick inside ANSI-C dollar-quote string: unexpected EOF hunting matching ) - whole ble.sh (29,601 lines) unparseable #215

Closed

Description

@caomengxuan666

Corpus: ble.sh nightly-2026-09-27 (29,601 lines, sha256 4b76374a…; corpus2 lane, first run of this corpus). Artifacts: target/issue-suites/results/corpus2/results/ble/ (diff-n.txt, diff-x.txt), bisect probes probe/p4a-ble.*, probe/p4d-inner-esc.*, probe/p4g-escquote-tick.*.

Kill: rubash -n corpora/ble.sh = rc=2 (GNU rc=0), and source ./corpora/ble.sh --noattach = rc=2 (GNU: sources the whole file, stops cleanly at "This is not an interactive session", rc=1). The whole 29,601-line ble.sh is unparseable and unsourcable.

Failure site: ble.sh:7319

local chars=%$'\t\n !"$&\'();<>\^`|' # <emacs bug `>

Error: corpora/ble.sh: line 7319: syntax error near unexpected token 'then' (the printed offending text joins lines 7319-7320; in source mode the same mis-lex attributes the error to line 28 syntax error near unexpected token 'if' — #204/#201-family display, secondary here).

Minimal reproducer (LF script file, both shells, identical bytes):

x=$'a\'b`c'
y=1
  • GNU Bash 5.3.0: rc=0 (the \' is an escaped quote inside ANSI-C quoting; the backtick is a literal character in the string).
  • rubash: rc=2, probe/p4g-escquote-tick.sh: line 2: unexpected EOF while looking for matching ')'.

Bisect matrix (all file-based, both shells):

probe content GNU rubash
p4f x=$'a\'b' (escaped quote, no backtick) rc=0 rc=0
p4e x=$'a`b' (backtick, no escaped quote) rc=0 rc=0
p4h x=$'a\b`c' (other escape + backtick) rc=0 rc=0
p4g x=$'a\'b`c' (escaped quote + backtick) rc=0 rc=2 EOF hunting )
p4a the full ble.sh:7319 word + if rc=0 rc=2

So the trigger is specifically \' inside $'...' followed (before the closing quote) by a backtick — the lexer apparently loses the ANSI-C string state at the escaped quote, then treats the backtick as a command-substitution opener and hunts for ) to EOF. Note \ also combines (p4d $'a\'b\cd'` fails), consistent with the same lost-state mechanism.

GNU C source owner: parse.y:5546-5558 read_token_word() — $'...' is lexed by parse_matched_pair (peek_char, peek_char, peek_char, &ttoklen, P_ALLOWESC) (parse.y:3877); P_ALLOWESC is exactly what keeps \' (and \) inside the string, and the backtick inside the matched pair is never a comsub opener.

Classification: rubash-caused, parse-level (rc=2 kills the rest of the script; no execution reached). Not a duplicate of #109 (array-element quote storage) or #199 (PUA carrier in argv) — this is a hard lexer rejection.

Activity

  1. caomengxuan666 commented on Sep 27, 2026

    @caomengxuan666
    MemberAuthor

    已修复并合入 master(lane wt4/corpusfix,2026-09-27):根因修复 + 全形状矩阵与 WSL GNU 5.3.0 字节一致;源语料复跑(bash-preexec/tldr 转 CLEAN)。感谢报告!

  2. 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