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

PATCH: Re: execve bug



(I inadvertently sent another copy of this though math.gatech.edu because
that's where David sent the mail to which I replied.  My other doesn't have
the word "PATCH" in the header, and hasn't come back to me yet, so on the
chance that it's been hung out in limbo I'm sending this one.)

On Jun 14,  1:13pm, David Aspinwall wrote:
} Subject: execve bug
}
} If you have a script called 'dog' whose first line is '#!/bin/sh '
} (i.e., has at least one space after the interpreter name), and
} the OS doesn't support #!, zsh will wind up calling execve with
} an argv of ("/bin/sh", "", "dog").

Thanks for pointing this out.  The same problem happens with a trailing
tab, so I think the following patch is better.  There was also no reason
for the old code wandereding all the way to t0 == ct clobbering newlines
once the first one was found.

Index: Src/exec.c
==========================================================================
@@ -251,7 +251,9 @@
 		    if (execvebuf[1] == '!') {
 			for (t0 = 0; t0 != ct; t0++)
 			    if (execvebuf[t0] == '\n')
-				execvebuf[t0] = '\0';
+				break;
+			while (inblank(execvebuf[t0]))
+			    execvebuf[t0--] = '\0';
 			execvebuf[POUNDBANGLIMIT] = '\0';
 			for (ptr = execvebuf + 2; *ptr && *ptr == ' '; ptr++);
 			for (ptr2 = ptr; *ptr && *ptr != ' '; ptr++);

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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