mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-28 04:08:08 +00:00
Shell: Explicitly check if command is a directory
This is a bit nicer than getting "Exec format error" after trying to execvp() a directory.
This commit is contained in:
committed by
Andreas Kling
parent
0ec37c0d64
commit
fc09767872
@@ -885,6 +885,12 @@ 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);
|
||||
|
||||
Reference in New Issue
Block a user