Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh exec format error with empty files



On Dec 23,  6:01pm, Christian Neukirchen wrote:
}
} % ./empty 
} zsh: exec format error: ./empty
} 
} For consistency, this should just run /bin/sh as well and return 0,
} like in bash, dash, busybox sh, tcsh, mksh, ksh93, posh, Byron's rc
} and every tool using execvp.

Hm.


diff --git a/Src/exec.c b/Src/exec.c
index acc867c..c4dc8e3 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -471,9 +471,10 @@ zexecve(char *pth, char **argv, char **newenvp)
 	if ((fd = open(pth, O_RDONLY|O_NOCTTY)) >= 0) {
 	    argv0 = *argv;
 	    *argv = pth;
+	    execvbuf[0] = '\0';
 	    ct = read(fd, execvebuf, POUNDBANGLIMIT);
 	    close(fd);
-	    if (ct > 0) {
+	    if (ct >= 0) {
 		if (execvebuf[0] == '#') {
 		    if (execvebuf[1] == '!') {
 			for (t0 = 0; t0 != ct; t0++)



Messages sorted by: Reverse Date, Date, Thread, Author