Shell: Make the 'not' builtin return the correct exit code for functions

This commit is contained in:
AnotherTest 2021-03-07 09:55:02 +03:30 committed by Andreas Kling
parent fec8d7d699
commit 4f6bf2931c
Notes: sideshowbarker 2024-07-18 21:40:00 +09:00

View File

@ -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;
}