diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2006-05-29 15:36:25 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2006-05-29 15:36:25 +0000 |
commit | 29ed6c7e3ab32da20f528aeba4bb76635f1a3b06 (patch) | |
tree | f0b3c4d7bb272b4569736096b06ac09f160aaaf6 /Src | |
parent | ef04a344809a7bf2f1a2dd9e940a544c38214dd7 (diff) | |
download | zsh-29ed6c7e3ab32da20f528aeba4bb76635f1a3b06.tar.gz zsh-29ed6c7e3ab32da20f528aeba4bb76635f1a3b06.tar.xz zsh-29ed6c7e3ab32da20f528aeba4bb76635f1a3b06.zip |
10343: improve error message for bad #! lines
Diffstat (limited to 'Src')
-rw-r--r-- | Src/exec.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Src/exec.c b/Src/exec.c index 4612c9c1e..7efd7d857 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -385,7 +385,7 @@ zexecve(char *pth, char **argv) * then check for an errno equal to ENOEXEC. This errno is set * * if the process file has the appropriate access permission, * * but has an invalid magic number in its header. */ - if ((eno = errno) == ENOEXEC) { + if ((eno = errno) == ENOEXEC || eno == ENOENT) { char execvebuf[POUNDBANGLIMIT + 1], *ptr, *ptr2, *argv0; int fd, ct, t0; @@ -405,7 +405,14 @@ zexecve(char *pth, char **argv) execvebuf[POUNDBANGLIMIT] = '\0'; for (ptr = execvebuf + 2; *ptr && *ptr == ' '; ptr++); for (ptr2 = ptr; *ptr && *ptr != ' '; ptr++); - if (*ptr) { + if (eno == ENOENT) { + char *buf; + if (*ptr) + *ptr = '\0'; + buf = tricat("%s: bad interpreter: ", ptr2, + ": %e"); + zerr(buf, pth, eno); + } else if (*ptr) { *ptr = '\0'; argv[-2] = ptr2; argv[-1] = ptr + 1; @@ -414,11 +421,11 @@ zexecve(char *pth, char **argv) argv[-1] = ptr2; execve(ptr2, argv - 1, environ); } - } else { + } else if (eno == ENOEXEC) { argv[-1] = "sh"; execve("/bin/sh", argv - 1, environ); } - } else { + } else if (eno == ENOEXEC) { for (t0 = 0; t0 != ct; t0++) if (!execvebuf[t0]) break; |