diff --git a/Shell/AST.h b/Shell/AST.h index 21eff815a3..713f604340 100644 --- a/Shell/AST.h +++ b/Shell/AST.h @@ -429,6 +429,7 @@ public: virtual bool is_list() const { return false; } virtual bool would_execute() const { return false; } + virtual bool should_override_execution_in_current_process() const { return false; } const Position& position() const { return m_position; } void set_is_syntax_error(const SyntaxError& error_node) @@ -829,6 +830,7 @@ private: virtual HitTestResult hit_test_position(size_t) override; virtual Vector complete_for_editor(Shell&, size_t, const HitTestResult&) override; virtual bool would_execute() const override { return true; } + virtual bool should_override_execution_in_current_process() const override { return true; } NameWithPosition m_name; Vector m_arguments; diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp index c70b982413..0bc877ce58 100644 --- a/Shell/Shell.cpp +++ b/Shell/Shell.cpp @@ -729,6 +729,12 @@ RefPtr Shell::run_command(const AST::Command& command) } } + if (command.argv.is_empty() && !command.next_chain.is_empty() && command.should_immediately_execute_next && command.next_chain.first().node->should_override_execution_in_current_process()) { + for (auto& next_in_chain : command.next_chain) + run_tail(command, next_in_chain, last_return_code); + return nullptr; + } + Vector argv; Vector copy_argv = command.argv; argv.ensure_capacity(command.argv.size() + 1);