mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:27:34 +00:00
Shell: Make redirection errors raise ShellErrors
Naturally, this means that a command with a failing redirection will not start, and so will terminate the pipeline (if any). This also applies to the `exit` run when the shell is closed, fixing a fun bug there as well (thanks to Discord user Salanty for pointing that out) where closing the terminal (i.e. I/O error on the tty) with a failing `exit` command would make the shell retry executing `exit` every time, leading to an eventual stack overflow.
This commit is contained in:
parent
8de8a7766d
commit
783e27f8f9
3 changed files with 79 additions and 77 deletions
|
@ -1093,7 +1093,13 @@ int Shell::builtin_kill(int argc, const char** argv)
|
|||
command.position = m_source_position.has_value() ? m_source_position->position : Optional<AST::Position> {};
|
||||
|
||||
auto exit_code = 1;
|
||||
if (auto job = run_command(command)) {
|
||||
auto job_result = run_command(command);
|
||||
if (job_result.is_error()) {
|
||||
warnln("kill: Failed to run {}: {}", command.argv.first(), job_result.error());
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
if (auto job = job_result.release_value()) {
|
||||
block_on_job(job);
|
||||
exit_code = job->exit_code();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue