From 4f6bf2931c5df4336b848b4a299ce30bae8dc299 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sun, 7 Mar 2021 09:55:02 +0330 Subject: Shell: Make the 'not' builtin return the correct exit code for functions --- Userland/Shell/Builtin.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Userland') 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; } -- cgit v1.2.3