From aa73a7c961a941b8dfaac01ea8f14577011fb942 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Fri, 17 Nov 2023 21:39:56 +0330 Subject: [PATCH] Shell: Accept null heredocs in POSIX mode Fixes #21837. --- Userland/Shell/AST.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index 54850e0cab..fc7e836245 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -1425,6 +1425,10 @@ ErrorOr Heredoc::dump(int level) const ErrorOr> Heredoc::run(RefPtr shell) { + if (shell && shell->posix_mode() && !m_contents) { + m_contents = make_ref_counted(position(), ""_string, StringLiteral::EnclosureType::None); + } + if (!m_contents) { if (shell) shell->raise_error(Shell::ShellError::EvaluatedSyntaxError, "Attempt to evaluate an unresolved heredoc"sv, position());