Shell: use exit code 127 on command not found
This commit is contained in:
parent
1d11b62ca4
commit
fdc9b3c5a0
Notes:
sideshowbarker
2024-07-18 23:36:37 +09:00
Author: https://github.com/nvella Commit: https://github.com/SerenityOS/serenity/commit/fdc9b3c5a0e Pull-request: https://github.com/SerenityOS/serenity/pull/4954
1 changed files with 3 additions and 1 deletions
|
@ -886,10 +886,12 @@ void Shell::execute_process(Vector<const char*>&& argv)
|
|||
struct stat st;
|
||||
if (stat(argv[0], &st)) {
|
||||
fprintf(stderr, "stat(%s): %s\n", argv[0], strerror(errno));
|
||||
_exit(126);
|
||||
// Return code 127 on command not found.
|
||||
_exit(127);
|
||||
}
|
||||
if (!(st.st_mode & S_IXUSR)) {
|
||||
fprintf(stderr, "%s: Not executable\n", argv[0]);
|
||||
// Return code 126 when file is not executable.
|
||||
_exit(126);
|
||||
}
|
||||
if (saved_errno == ENOENT) {
|
||||
|
|
Loading…
Add table
Reference in a new issue