about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/exec.c15
2 files changed, 16 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 7211ac92a..aed8496b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-29  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 10343: Src/exec.c: make bad #! interpreters print a more
+	informative message.
+
 2006-05-28  Clint Adams  <clint@zsh.org>
 
 	* 22469: R. Ramkumar: Completion/Unix/Command/_mount: use
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;