mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-01 07:35:02 +03:00
Shell: Make the 'not' builtin return the correct exit code for functions
This commit is contained in:
parent
fec8d7d699
commit
4f6bf2931c
Notes:
sideshowbarker
2024-07-18 21:40:00 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/4f6bf2931c5 Pull-request: https://github.com/SerenityOS/serenity/pull/5672
@ -892,10 +892,15 @@ int Shell::builtin_not(int argc, const char** argv)
|
||||
|
||||
auto commands = expand_aliases({ move(command) });
|
||||
int exit_code = 1;
|
||||
auto found_a_job = false;
|
||||
for (auto& job : run_commands(commands)) {
|
||||
found_a_job = true;
|
||||
block_on_job(job);
|
||||
exit_code = job.exit_code();
|
||||
}
|
||||
// In case it was a function.
|
||||
if (!found_a_job)
|
||||
exit_code = last_return_code;
|
||||
return exit_code == 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user