1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 13:30:45 +00:00

Shell: Avoid infinite loop when parsing heredoc entry in POSIX mode

Previously, the shell would enter an infinite loop when attempting to
parse a heredoc entry within a `$(` command substitution.
This commit is contained in:
Tim Ledbetter 2023-11-07 22:29:02 +00:00 committed by Ali Mohammad Pur
parent c170dd323e
commit ff81513634

View File

@ -250,7 +250,7 @@ ErrorOr<Lexer::ReductionResult> Lexer::reduce_operator()
auto result = TRY(reduce(Reduction::Start));
tokens.extend(move(result.tokens));
while (expect_heredoc_entry && tokens.size() == 1) {
while (expect_heredoc_entry && tokens.size() == 1 && result.next_reduction != Reduction::None) {
result = TRY(reduce(result.next_reduction));
tokens.extend(move(result.tokens));
}