* execve bug
@ 1999-06-15 17:16 David Aspinwall
0 siblings, 0 replies; 3+ messages in thread
From: David Aspinwall @ 1999-06-15 17:16 UTC (permalink / raw)
To: zsh-workers
This is a bug which shows up in the NT port (based on 3.0.5).
It isn't in the NT-specific code, though, and I think would happen on
any system which doesn't support #!, so I'm sending it to zsh-workers.
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"). You get an error like
: : No such file or directory
or if you have multiple spaces,
: : Permission denied
Here's a patch to exec.c against 3.0.5 (or at least the version
in the zshsrc file for the NT distribution).
*** ../../zsh-orig/Src/exec.c Wed May 19 16:16:26 1999
--- exec.c Fri Jun 11 13:45:06 1999
***************
*** 180,187 ****
if (execvebuf[0] == '#') {
if (execvebuf[1] == '!') {
for (t0 = 0; t0 != ct; t0++)
! if (execvebuf[t0] == '\n')
execvebuf[t0] = '\0';
execvebuf[POUNDBANGLIMIT] = '\0';
for (ptr = execvebuf + 2; *ptr && *ptr == ' '; ptr++);
for (ptr2 = ptr; *ptr && *ptr != ' '; ptr++);
--- 180,196 ----
if (execvebuf[0] == '#') {
if (execvebuf[1] == '!') {
for (t0 = 0; t0 != ct; t0++)
! if (execvebuf[t0] == '\n') {
execvebuf[t0] = '\0';
+ /* get rid of trailing spaces */
+ for (--t0; t0 > 1; --t0) {
+ if (execvebuf[t0] == ' ') {
+ execvebuf[t0] = '\0';
+ } else {
+ break;
+ }
+ }
+ }
execvebuf[POUNDBANGLIMIT] = '\0';
for (ptr = execvebuf + 2; *ptr && *ptr == ' '; ptr++);
for (ptr2 = ptr; *ptr && *ptr != ' '; ptr++);
--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.
^ permalink raw reply [flat|nested] 3+ messages in thread
* execve bug
@ 1999-06-14 20:13 David Aspinwall
1999-06-16 6:42 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: David Aspinwall @ 1999-06-14 20:13 UTC (permalink / raw)
To: amol, zsh-workers
This is a bug which shows up in the NT port (based no 3.0.5).
It isn't in the NT-specific code, though, and I think would happen on
any system which doesn't support #!, so I'm sending it to zsh-workers
too.
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"). You get an error like
: : No such file or directory
or if you have multiple spaces,
: : Permission denied
Here's a patch to exec.c against 3.0.5 (or at least the version
in the zshsrc file for the NT distribution).
*** ../../zsh-orig/Src/exec.c Wed May 19 16:16:26 1999
--- exec.c Fri Jun 11 13:45:06 1999
***************
*** 180,187 ****
if (execvebuf[0] == '#') {
if (execvebuf[1] == '!') {
for (t0 = 0; t0 != ct; t0++)
! if (execvebuf[t0] == '\n')
execvebuf[t0] = '\0';
execvebuf[POUNDBANGLIMIT] = '\0';
for (ptr = execvebuf + 2; *ptr && *ptr == ' '; ptr++);
for (ptr2 = ptr; *ptr && *ptr != ' '; ptr++);
--- 180,196 ----
if (execvebuf[0] == '#') {
if (execvebuf[1] == '!') {
for (t0 = 0; t0 != ct; t0++)
! if (execvebuf[t0] == '\n') {
execvebuf[t0] = '\0';
+ /* get rid of trailing spaces */
+ for (--t0; t0 > 1; --t0) {
+ if (execvebuf[t0] == ' ') {
+ execvebuf[t0] = '\0';
+ } else {
+ break;
+ }
+ }
+ }
execvebuf[POUNDBANGLIMIT] = '\0';
for (ptr = execvebuf + 2; *ptr && *ptr == ' '; ptr++);
for (ptr2 = ptr; *ptr && *ptr != ' '; ptr++);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: execve bug
1999-06-14 20:13 David Aspinwall
@ 1999-06-16 6:42 ` Bart Schaefer
0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1999-06-16 6:42 UTC (permalink / raw)
To: David Aspinwall, amol, zsh-workers
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1999-06-18 8:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-15 17:16 execve bug David Aspinwall
-- strict thread matches above, loose matches on Subject: below --
1999-06-14 20:13 David Aspinwall
1999-06-16 6:42 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).