diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2021-03-07 09:55:02 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-07 10:58:42 +0100 |
commit | 4f6bf2931c5df4336b848b4a299ce30bae8dc299 (patch) | |
tree | 3f2a839d761378dea237e9f5541f35b6220140de /Userland | |
parent | fec8d7d699c6dfe71390a73e264f95d834ceb1eb (diff) | |
download | serenity-4f6bf2931c5df4336b848b4a299ce30bae8dc299.zip |
Shell: Make the 'not' builtin return the correct exit code for functions
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Shell/Builtin.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index 3b1cb9db33..1eada40364 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -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; } |