-
-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syntax: do not require peeking two bytes after
echo *
The lexer wants to know if literal characters like `*` or `@` are followed by `(`, because then they would be an extended globbing expression like `@(pattern-list)`. However, the current implementation first peeked for the bytes `()`, to detect function declarations like `@() { ... }`. Unfortunately, this caused interactive shells to hang on `echo *` followed by a newline, as a newline is a single character. To work around the problem, only peek `()` if we first peek `(`. Moreover, the logic to call Parser.fill in Parser.peekBytes seems wrong. The conditional definitely needs to use len(s), as that is the number of bytes we want to look for. The new logic seems clearly better; we call Parser.fill when p.bs contains fewer remaining bytes than len(s). Note that we no longer loop on that logic, because we have zero tests exercising that edge case, and I am slightly worried about endless loops until we properly test those edge cases. Fixes #835.
- Loading branch information
Showing
2 changed files
with
34 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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