summaryrefslogtreecommitdiff
path: root/Shell
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-05-15 12:21:45 +0300
committerAndreas Kling <kling@serenityos.org>2020-05-15 11:43:58 +0200
commit7aad44b8257f84c9a9dfe0c95eca86e1ba932b5b (patch)
tree2d9e01c980b5e5cd92ca0f1ebfd8b204dc094ee2 /Shell
parent888329233bb95db64555296d867f3507b40fedd1 (diff)
downloadserenity-7aad44b8257f84c9a9dfe0c95eca86e1ba932b5b.zip
Shell: Print correct errno when execvp() fails
Amusingly enough, this was caused by yet another bug.
Diffstat (limited to 'Shell')
-rw-r--r--Shell/main.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Shell/main.cpp b/Shell/main.cpp
index 0b9a5cedfc..9d0c1faaf7 100644
--- a/Shell/main.cpp
+++ b/Shell/main.cpp
@@ -1044,12 +1044,13 @@ static ExitCodeOrContinuationRequest run_command(const StringView& cmd)
} else
fprintf(stderr, "%s: Command not found.\n", argv[0]);
} else {
+ int saved_errno = errno;
struct stat st;
if (stat(argv[0], &st) == 0 && S_ISDIR(st.st_mode)) {
fprintf(stderr, "Shell: %s: Is a directory\n", argv[0]);
_exit(126);
}
- fprintf(stderr, "execvp(%s): %s\n", argv[0], strerror(errno));
+ fprintf(stderr, "execvp(%s): %s\n", argv[0], strerror(saved_errno));
}
_exit(126);
}