mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Shell: Don't return early if command is in PATH and a directory
This commit is contained in:
parent
11054fc9f9
commit
2623bd711b
Notes:
sideshowbarker
2024-07-19 07:28:10 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/2623bd711b6 Pull-request: https://github.com/SerenityOS/serenity/pull/1873
1 changed files with 8 additions and 8 deletions
|
@ -885,12 +885,6 @@ static int run_command(const String& cmd)
|
|||
if (handle_builtin(argv.size() - 1, argv.data(), retval))
|
||||
return retval;
|
||||
|
||||
struct stat st;
|
||||
if (stat(argv[0], &st) == 0 && S_ISDIR(st.st_mode)) {
|
||||
fprintf(stderr, "Shell: %s: Is a directory\n", argv[0]);
|
||||
return 126;
|
||||
}
|
||||
|
||||
pid_t child = fork();
|
||||
if (!child) {
|
||||
setpgid(0, 0);
|
||||
|
@ -911,10 +905,16 @@ static int run_command(const String& cmd)
|
|||
|
||||
int rc = execvp(argv[0], const_cast<char* const*>(argv.data()));
|
||||
if (rc < 0) {
|
||||
if (errno == ENOENT)
|
||||
if (errno == ENOENT) {
|
||||
fprintf(stderr, "%s: Command not found.\n", argv[0]);
|
||||
else
|
||||
} else {
|
||||
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));
|
||||
}
|
||||
_exit(1);
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
|
|
Loading…
Reference in a new issue