Skip to content

Fix silent partial parses and quoted Bash keywords - #8

Merged
webpro merged 2 commits into
webpro-nl:mainfrom
privatenumber:fix/parser-fidelity
Aug 7, 2026
Merged

Fix silent partial parses and quoted Bash keywords#8
webpro merged 2 commits into
webpro-nl:mainfrom
privatenumber:fix/parser-fidelity

Conversation

@privatenumber

@privatenumber privatenumber commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Problem

unbash could return a clean AST even when it stopped before the end of the source. Given:

safe
fi; recovered

it returned only safe, omitted recovered, and reported no error. Consumers therefore could not tell that the AST did not represent the complete input.

Bash recognizes reserved words only when unquoted. unbash instead checked the processed word value in some paths, so "time" echo became timing syntax rather than a command named time; ANSI-C spellings such as $'if' were similarly classified as keywords.

Changes

Unconsumed top-level tokens now produce source-positioned errors. When a statement separator provides a safe restart point, parsing continues so later statements remain available in the best-effort AST.

Reserved-word recognition now records whether a word is lexically eligible. Quoted, escaped, or expanded spellings remain commands or operands, while ordinary and backslash-newline-spliced keywords retain Bash semantics. Deep recovery follows the same rule.

@privatenumber privatenumber changed the title Fix root recovery and time keyword parsing Fix silent partial parses and quoted Bash keywords Aug 7, 2026
@webpro
webpro merged commit 7802826 into webpro-nl:main Aug 7, 2026
1 check passed
@webpro

webpro commented Aug 7, 2026

Copy link
Copy Markdown
Member

Thanks Hiroki!

@webpro

webpro commented Aug 7, 2026

Copy link
Copy Markdown
Member

In v4.0.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants