From ff81513634166023db92ddcf757d5ffd6805e5a7 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Tue, 7 Nov 2023 22:29:02 +0000 Subject: [PATCH] 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. --- Userland/Shell/PosixLexer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Shell/PosixLexer.cpp b/Userland/Shell/PosixLexer.cpp index bc1953f93c..28afbacd26 100644 --- a/Userland/Shell/PosixLexer.cpp +++ b/Userland/Shell/PosixLexer.cpp @@ -250,7 +250,7 @@ ErrorOr 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)); }