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.
This commit is contained in:
Ali Mohammad Pur 2021-12-12 15:55:53 +03:30 committed by Ali Mohammad Pur
parent 18f053ac31
commit 6bf50bc40b
Notes: sideshowbarker 2024-07-17 22:49:36 +09:00

View file

@ -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<Value> CommandLiteral::run(RefPtr<Shell>)
@ -2036,6 +2036,13 @@ RefPtr<Value> Join::run(RefPtr<Shell> shell)
if (shell && shell->has_any_error())
return make_ref_counted<ListValue>({});
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<Join>(m_position, lhs_node, m_right);
return make_ref_counted<CommandSequenceValue>(move(left));
}
auto right = m_right->to_lazy_evaluated_commands(shell);
if (shell && shell->has_any_error())
return make_ref_counted<ListValue>({});