Skip to content

[parse] compound-group state leaks into later nested function-definition brace tracking: EOF from '{' — GNU accepts (breaks mirkop.sh) #465

Closed

Description

@caomengxuan666

Construct (minimal repro, 11 lines)

f() {
  [[ a == b ]] && {
    ((0)) && {
      g <<< ""
    }
  }
}
function h {
  function i {
    printf X
  }
}

rubash -n (fresh master a157656, release build):

nn2.sh: line 11: syntax error: unexpected end of file from `{' command on line 9

GNU bash 5.3.0 parses this file (Git Bash 5.2 grammar: rc=0, non-authoritative corroboration).

Measured boundaries on the fresh build:

variation rubash -n GNU 5.3
full repro above syntax error (EOF from {) ok
[[ ]] && { (( )) && { g <<< "" } } alone ok ok
nested function h { function i { ... } } alone ok ok
function h { function i { ... } } with function h () form + the group above syntax error ok
herestring word non-empty (<<< x) instead of <<< "" ok ok
either the [[ ]] or the (( )) line removed ok ok
inner function given () (function i () {) ok ok

So the state produced by the [[ … ]] && { (( … )) && { cmd <<< "" ; } ; } group makes rubash mis-track the body of a later function NAME { definition whose body itself contains a nested function NAME2 { — the inner function's { is reported as never closed ("unexpected end of file from { command"). The same signature appears with entirely different bodies (a bare printf 'X'), so it is the nesting/state, not the content.

Real-world evidence (ecosystem harvest)

Klapptnot/dotf-old/.config/bash/mirkop.sh (374-line prompt framework; harvest 2026-10-04):

function __mirkop_transient_prompt {          # line 185: [[ ]] && { ((..)) && { ... <<< "" } }
...
function __mirkop_load_prompt_config {        # line 259
  function hex_to_shell {                     # line 265 — reported unclosed
  • WSL GNU Bash 5.3.0 bash -n: rc=0 on the whole file (recorded oracle, harvest 2026-10-04/05)
  • Git Bash 5.2 grammar: rc=0 (non-authoritative corroboration)
  • rubash master a157656 rubash -n: rc=2, syntax error: unexpected end of file from '{' command on line 265
  • rubash's own runtime sources the file (ConPTY run reaches the prompt) — only the -n parse path fails.

GNU C source anchor (vendored bash.git @b4608166, Bash-5.3 patch 15)

  • parse.y:1056 function_def: FUNCTION WORD function_body and parse.y:1054 function_def: WORD '(' ')' newline_list function_body — both definition forms share the same function_body machinery; a preceding compound group must not change how the later definition's body braces are tracked.
  • parse.y:1193 group_command: '{' compound_list '}' — group bodies are tracked by brace state in the lexer; GNU keeps the brace/quote state per construct, with no leakage from a completed &&-group (including its <<< herestring and (( )) arithmetic-command lines) into later definitions.

Classification

Parser/lexer state divergence (cross-construct state leakage into function-definition brace tracking). Distinct from rubash#460 (terminator-less then after ]] in a function body) — different construct, different failure signature.

Activity

  1. added
    bug
    gnu-baseline
    P2-medium
    on Oct 9, 2026
  2. changed the title [-][parse] compound-group state leaks into later nested function-definition brace tracking: EOF from '{' — GNU accepts (breaks mirop.sh)[/-] [+][parse] compound-group state leaks into later nested function-definition brace tracking: EOF from '{' — GNU accepts (breaks mirkop.sh)[/+] on Oct 9, 2026
  3. added 2 commits that reference this issue on Nov 20, 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

    P2-mediumbuggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions