Shell: Do not try to recreate a command from a list of args in time

Shell already provides a run_command(AST::Command) which can be
constructed from a list of arguments, use that instead.
This commit is contained in:
AnotherTest 2020-06-19 16:32:19 +04:30 committed by Andreas Kling
parent bc3285abb0
commit 16def040af
Notes: sideshowbarker 2024-07-19 05:09:25 +09:00

View File

@ -654,15 +654,18 @@ int Shell::builtin_time(int argc, const char** argv)
if (!parser.parse(argc, const_cast<char**>(argv), false))
return 1;
StringBuilder builder;
builder.join(' ', args);
AST::Command command;
for (auto& arg : args)
command.argv.append(arg);
Core::ElapsedTimer timer;
timer.start();
// TODO: Exit code
run_command(builder.string_view());
auto job = run_command(command);
if (!job)
return 1;
block_on_job(job);
fprintf(stderr, "Time: %d ms\n", timer.elapsed());
return 0;
return job->exit_code();
}
int Shell::builtin_umask(int argc, const char** argv)