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] Over-lax: empty or comment-only brace-group body accepted (f() {<newline>}, f() {<newline># c<newline>}, { # c }) — GNU: syntax error near '}' #327
Found by ecosweep3 lane (pure-bash-bible corpus, section 053 'obsolete function declaration'; carrier release build of 6106961). New instance of the over-lax family (#221).
Reproducer matrix (target/probe-out/p13a-d.sh)
f() {
}
echo ok-empty
f() {
# c
}
echo ok-comment
{
# c
}
echo ok-group
GNU bash 5.3.0: ALL THREE are syntax error near unexpected token }`` (rc=2) — a brace group must contain a command list, and a comment is not a command.
rubash: all three accepted and run (rc=0).
Control (both shells agree, rc=2): while false; do\n# c\ndone and if cmd; then\n# c\nfi — so rubash already enforces the rule for loop/if bodies; the { } group case alone is missing.
GNU anchor
parse.ybrace_group production requires a list; } only terminates after a nonempty newline_list + command sequence (see parse.y grammar brace_group: '{' newline_list list '}' region and the error_near_token reporting at }). Note rubash's while-body error text also appends a stray ; (done' vs GNU done' — minor wording, same family as #285).
Impact
Scripts relying on the GNU syntax error (typo detection, shellcheck-clean guarded blocks) silently behave differently; corpus-counted as parse over-acceptance in 1 pbb section.
Fixed by wt14/pbbfix (8738568, master): the brace-group completeness check treated comment-only+newline bodies as complete, and both function-body paths lacked the empty-body check the multi-token path had. { requires a compound_list (parse.y:1196). Also fixed the offending-line echo gluing the newline token synthetic semicolon into the line text (done; -> done). All three reproducers + loop-control cases + inline { } messages/line numbers/rc byte-identical; 12 legal-body scans identical.
Activity
fix(#327): empty/comment-only brace-group and function bodies are syn…
caomengxuan666 commentedon Sep 29, 2026
Fixed by wt14/pbbfix (8738568, master): the brace-group completeness check treated comment-only+newline bodies as complete, and both function-body paths lacked the empty-body check the multi-token path had. { requires a compound_list (parse.y:1196). Also fixed the offending-line echo gluing the newline token synthetic semicolon into the line text (done; -> done). All three reproducers + loop-control cases + inline { } messages/line numbers/rc byte-identical; 12 legal-body scans identical.