mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 05:25:54 +08:00
postfork: Also check if interpreter is a directory
"#!/bin/"
This commit is contained in:
parent
ead0b03108
commit
f1a150ed43
@ -462,7 +462,9 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
||||
char interpreter_buff[128] = {};
|
||||
const char *interpreter =
|
||||
get_interpreter(actual_cmd, interpreter_buff, sizeof interpreter_buff);
|
||||
if (interpreter && 0 != access(interpreter, X_OK)) {
|
||||
struct stat buf;
|
||||
auto statret = stat(interpreter, &buf);
|
||||
if (interpreter && (0 != statret || access(interpreter, X_OK))) {
|
||||
// Detect Windows line endings and complain specifically about them.
|
||||
auto len = strlen(interpreter);
|
||||
if (len && interpreter[len - 1] == '\r') {
|
||||
@ -477,6 +479,11 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
||||
"executable command.",
|
||||
actual_cmd, interpreter);
|
||||
}
|
||||
} else if (interpreter && S_ISDIR(buf.st_mode)) {
|
||||
FLOGF_SAFE(exec,
|
||||
"Failed to execute process '%s': The file specified the interpreter "
|
||||
"'%s', which is a directory.",
|
||||
actual_cmd, interpreter);
|
||||
} else if (access(actual_cmd, X_OK) == 0) {
|
||||
FLOGF_SAFE(exec,
|
||||
"Failed to execute process '%s': The file exists and is executable. "
|
||||
|
Loading…
x
Reference in New Issue
Block a user