mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-02 08:16:14 +08:00
Improve error message for fish scripts without shebang
When we execute something and it doesn't have a shebang, typically we fall back on running it with /bin/sh. For .fish scripts, we still refuse to do this (assuming that /bin/sh won't handle .fish scripts properly). Only the error wasn't great. So we now explicitly mention when there's a missing shebang, and point towards the shebang line otherwise.
This commit is contained in:
parent
a9f6a38e37
commit
4ceed7c482
|
@ -417,10 +417,21 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
|||
}
|
||||
|
||||
case ENOEXEC: {
|
||||
FLOGF_SAFE(exec,
|
||||
"The file '%s' is marked as an executable but could not be run by the "
|
||||
"operating system.",
|
||||
actual_cmd);
|
||||
char interpreter_buff[128] = {};
|
||||
const char *interpreter =
|
||||
get_interpreter(actual_cmd, interpreter_buff, sizeof interpreter_buff);
|
||||
if (!interpreter) {
|
||||
FLOGF_SAFE(exec,
|
||||
"The file '%s' is executable but missing a Shebang (#!) line.",
|
||||
actual_cmd);
|
||||
} else {
|
||||
// If the shebang line exists, we would get an ENOENT or similar instead,
|
||||
// so I don't know how to reach this.
|
||||
FLOGF_SAFE(exec,
|
||||
"The file '%s' could not be run by the "
|
||||
"operating system. Maybe the Shebang (#!) line is broken?",
|
||||
actual_cmd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user