You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] shopt -s extglob inside a SOURCEd file breaks parsing of subsequent 'function NAME()' headers: syntax error near '(' (GNU accepts) — breaks OMB svn completion #302
GNU bash 5.3.0 (WSL /usr/local/bin/bash): prints OK, done=0.
rubash: b18-extglob-fn.sh: line 2: syntax error near unexpected token '('
(and line 2: function f()), done=2.
Executing the same file directly as a script is fine on both shells (rubash b18-extglob-fn.sh → OK); rubash -n on it is also clean. The failure needs the source path: the shopt -s extglob executed mid-source changes parser state so the
next function NAME() header's ( is rejected.
Real-world impact
oh-my-bash completions/svn.completion.sh:40 does shopt -s extglob; line 45 is function _svn_read_hashfile() → sourcing the completion under rubash dies with line 45: syntax error near unexpected token '('; _svn never defined
(target/issue-suites/results/ecosweep/omb/completions/svn.err). GNU sources the same
file cleanly (verified on the LF copy, rc=0). 58/59 other OMB completions source OK.
Any bash-completion-style file that flips extglob on before defining functions is
affected — that is a common upstream idiom (bash-completion's own files do shopt -s extglob via _comp_enable_extglob).
GNU C anchor
shopt -s extglob sets the parser flag for subsequent reads; GNU's reader
(parse.y yylex / read_token_word with sh_syntaxtab extended-class bits) applies
extglob only where a pattern word can appear — a function-definition header
(parse.y function_def production, function WORD ()) is parsed by the grammar before
pattern-word treatment, so () after the name stays legal. The rubash source-mode
reader applies the extglob word rules at the grammar position of the header.
Over-strict class relative to #222 (GNU-valid constructs rejected), but a distinct
trigger (source + runtime extglob + function header).
Fixed by wt11/lexmix (a5ae33b4, master): the extglob attribution was a MISDIAGNOSIS — the v5 repro fails with no shopt at all. Real root: stdin_source_is_function_signature's paren-stripping arm reduced function f() to function f (not a single WORD) and returned false outright, never reaching the keyword-form check — the group broke after the header line in every incremental reader (source builtin, piped stdin); whole-text paths (direct exec, eval) passed, which is why ecosweep's harness missed it. Now a fall-through with a function_keyword_operand_name() that strips the optional () while validating the whole operand (parse.y:1054-1061 function_def productions, incl. FUNCTION WORD '(' ')' newline_list function_body at :1056). Same-family residue in parser/function_command.rs: function f g now produces GNU's syntax error rc=2 instead of 'function: command not found' (g1-g5 byte-identical). Verification: 11-case sourced function-header matrix, the REAL oh-my-bash svn.completion.sh (49944B) sources clean with _svn defined; 12 new regressions; 505/505 lib.
Activity
docs(corpus): ecosweep lane — OMB item-by-item matrices + new ecosyst…
fix(#302,#304): function NAME() headers in incremental readers; <<< o…
caomengxuan666 commentedon Sep 28, 2026
Fixed by wt11/lexmix (a5ae33b4, master): the extglob attribution was a MISDIAGNOSIS — the v5 repro fails with no shopt at all. Real root: stdin_source_is_function_signature's paren-stripping arm reduced
function f()tofunction f(not a single WORD) and returned false outright, never reaching the keyword-form check — the group broke after the header line in every incremental reader (source builtin, piped stdin); whole-text paths (direct exec, eval) passed, which is why ecosweep's harness missed it. Now a fall-through with a function_keyword_operand_name() that strips the optional () while validating the whole operand (parse.y:1054-1061 function_def productions, incl. FUNCTION WORD '(' ')' newline_list function_body at :1056). Same-family residue in parser/function_command.rs:function f gnow produces GNU's syntax error rc=2 instead of 'function: command not found' (g1-g5 byte-identical). Verification: 11-case sourced function-header matrix, the REAL oh-my-bash svn.completion.sh (49944B) sources clean with _svn defined; 12 new regressions; 505/505 lib.