mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 00:27:35 +00:00
Shell: Make run_command() return a NonnullRefPtrVector<Job>
This never returns null Job pointers.
This commit is contained in:
parent
3055f73d48
commit
bf2cd9374c
4 changed files with 7 additions and 7 deletions
|
@ -909,7 +909,7 @@ RefPtr<Value> Execute::run(RefPtr<Shell> shell)
|
||||||
try_read();
|
try_read();
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto job : shell->run_commands(commands)) {
|
for (auto& job : shell->run_commands(commands)) {
|
||||||
shell->block_on_job(job);
|
shell->block_on_job(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -734,7 +734,7 @@ int Shell::builtin_time(int argc, const char** argv)
|
||||||
timer.start();
|
timer.start();
|
||||||
for (auto& job : run_commands(commands)) {
|
for (auto& job : run_commands(commands)) {
|
||||||
block_on_job(job);
|
block_on_job(job);
|
||||||
exit_code = job->exit_code();
|
exit_code = job.exit_code();
|
||||||
}
|
}
|
||||||
fprintf(stderr, "Time: %d ms\n", timer.elapsed());
|
fprintf(stderr, "Time: %d ms\n", timer.elapsed());
|
||||||
return exit_code;
|
return exit_code;
|
||||||
|
|
|
@ -588,9 +588,9 @@ RefPtr<Job> Shell::run_command(const AST::Command& command)
|
||||||
return *job;
|
return *job;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<RefPtr<Job>> Shell::run_commands(Vector<AST::Command>& commands)
|
NonnullRefPtrVector<Job> Shell::run_commands(Vector<AST::Command>& commands)
|
||||||
{
|
{
|
||||||
Vector<RefPtr<Job>> jobs_to_wait_for;
|
NonnullRefPtrVector<Job> jobs_to_wait_for;
|
||||||
|
|
||||||
for (auto& command : commands) {
|
for (auto& command : commands) {
|
||||||
#ifdef SH_DEBUG
|
#ifdef SH_DEBUG
|
||||||
|
@ -618,10 +618,10 @@ Vector<RefPtr<Job>> Shell::run_commands(Vector<AST::Command>& commands)
|
||||||
if (command.should_wait) {
|
if (command.should_wait) {
|
||||||
block_on_job(job);
|
block_on_job(job);
|
||||||
if (!job->is_suspended())
|
if (!job->is_suspended())
|
||||||
jobs_to_wait_for.append(job);
|
jobs_to_wait_for.append(*job);
|
||||||
} else {
|
} else {
|
||||||
if (command.is_pipe_source) {
|
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) {
|
} else if (command.should_notify_if_in_background) {
|
||||||
job->set_running_in_background(true);
|
job->set_running_in_background(true);
|
||||||
restore_ios();
|
restore_ios();
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
int run_command(const StringView&);
|
int run_command(const StringView&);
|
||||||
bool is_runnable(const StringView&);
|
bool is_runnable(const StringView&);
|
||||||
RefPtr<Job> run_command(const AST::Command&);
|
RefPtr<Job> run_command(const AST::Command&);
|
||||||
Vector<RefPtr<Job>> run_commands(Vector<AST::Command>&);
|
NonnullRefPtrVector<Job> run_commands(Vector<AST::Command>&);
|
||||||
bool run_file(const String&, bool explicitly_invoked = true);
|
bool run_file(const String&, bool explicitly_invoked = true);
|
||||||
bool run_builtin(int argc, const char** argv, int& retval);
|
bool run_builtin(int argc, const char** argv, int& retval);
|
||||||
bool has_builtin(const StringView&) const;
|
bool has_builtin(const StringView&) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue