diff --git a/Shell/AST.cpp b/Shell/AST.cpp index ac3a6e8352..bb441d907d 100644 --- a/Shell/AST.cpp +++ b/Shell/AST.cpp @@ -909,7 +909,7 @@ RefPtr Execute::run(RefPtr shell) try_read(); }; - for (auto job : shell->run_commands(commands)) { + for (auto& job : shell->run_commands(commands)) { shell->block_on_job(job); } diff --git a/Shell/Builtin.cpp b/Shell/Builtin.cpp index 33a2d91178..ebc8644a81 100644 --- a/Shell/Builtin.cpp +++ b/Shell/Builtin.cpp @@ -734,7 +734,7 @@ int Shell::builtin_time(int argc, const char** argv) timer.start(); for (auto& job : run_commands(commands)) { block_on_job(job); - exit_code = job->exit_code(); + exit_code = job.exit_code(); } fprintf(stderr, "Time: %d ms\n", timer.elapsed()); return exit_code; diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp index 3d7dd49030..b4e8ee0d40 100644 --- a/Shell/Shell.cpp +++ b/Shell/Shell.cpp @@ -588,9 +588,9 @@ RefPtr Shell::run_command(const AST::Command& command) return *job; } -Vector> Shell::run_commands(Vector& commands) +NonnullRefPtrVector Shell::run_commands(Vector& commands) { - Vector> jobs_to_wait_for; + NonnullRefPtrVector jobs_to_wait_for; for (auto& command : commands) { #ifdef SH_DEBUG @@ -618,10 +618,10 @@ Vector> Shell::run_commands(Vector& commands) if (command.should_wait) { block_on_job(job); if (!job->is_suspended()) - jobs_to_wait_for.append(job); + jobs_to_wait_for.append(*job); } else { if (command.is_pipe_source) { - jobs_to_wait_for.append(job); + jobs_to_wait_for.append(*job); } else if (command.should_notify_if_in_background) { job->set_running_in_background(true); restore_ios(); diff --git a/Shell/Shell.h b/Shell/Shell.h index a0b29d0bdd..3fceed2215 100644 --- a/Shell/Shell.h +++ b/Shell/Shell.h @@ -76,7 +76,7 @@ public: int run_command(const StringView&); bool is_runnable(const StringView&); RefPtr run_command(const AST::Command&); - Vector> run_commands(Vector&); + NonnullRefPtrVector run_commands(Vector&); bool run_file(const String&, bool explicitly_invoked = true); bool run_builtin(int argc, const char** argv, int& retval); bool has_builtin(const StringView&) const;