Fix silent partial parses and quoted Bash keywords - #8
Merged
Conversation
Member
|
Thanks Hiroki! |
Member
|
In v4.0.7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
unbash could return a clean AST even when it stopped before the end of the source. Given:
it returned only
safe, omittedrecovered, 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" echobecame timing syntax rather than a command namedtime; 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.