From 6bf50bc40bb93e91b269e525de3c19912bd1f38f Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 12 Dec 2021 15:55:53 +0330 Subject: [PATCH] Shell: Make the Join operation respect nodes that have a next chain This would show up when resolving aliases, when an alias contains a sequence. Fixes #11219. --- Userland/Shell/AST.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index 09587b3573..f45c547ca3 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -879,7 +879,7 @@ CloseFdRedirection::~CloseFdRedirection() void CommandLiteral::dump(int level) const { Node::dump(level); - print_indented("(Generated command literal)", level + 1); + print_indented(String::formatted("(Generated command literal: {})", m_command), level + 1); } RefPtr CommandLiteral::run(RefPtr) @@ -2036,6 +2036,13 @@ RefPtr Join::run(RefPtr shell) if (shell && shell->has_any_error()) return make_ref_counted({}); + if (left.last().should_wait && !left.last().next_chain.is_empty()) { + // Join (C0s*; C1) X -> (C0s*; Join C1 X) + auto& lhs_node = left.last().next_chain.last().node; + lhs_node = make_ref_counted(m_position, lhs_node, m_right); + return make_ref_counted(move(left)); + } + auto right = m_right->to_lazy_evaluated_commands(shell); if (shell && shell->has_any_error()) return make_ref_counted({});