Shell: Simply print "cmd: Command not found." for ENOENT on execution.

This looks a little nicer than 'execvp(cmd): No such file or directory'
This commit is contained in:
Andreas Kling 2019-07-25 07:03:29 +02:00
parent f186c018f1
commit 7c3b2e0728
Notes: sideshowbarker 2024-07-19 13:04:11 +09:00

View file

@ -463,7 +463,10 @@ static int run_command(const String& cmd)
int rc = execvp(argv[0], const_cast<char* const*>(argv.data()));
if (rc < 0) {
fprintf(stderr, "execvp(%s): %s\n", argv[0], strerror(errno));
if (errno == ENOENT)
fprintf(stderr, "%s: Command not found.\n", argv[0]);
else
fprintf(stderr, "execvp(%s): %s\n", argv[0], strerror(errno));
exit(1);
}
ASSERT_NOT_REACHED();