zsh-workers
 help / color / mirror / code / Atom feed
From: David Aspinwall <aspinwall@TimesTen.com>
To: amol@blarg.net, zsh-workers@math.gatech.edu
Subject: execve bug
Date: 14 Jun 1999 13:13:07 -0700	[thread overview]
Message-ID: <un1y28rsc.fsf@TimesTen.com> (raw)

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++);


             reply	other threads:[~1999-06-15 23:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-14 20:13 David Aspinwall [this message]
1999-06-16  6:42 ` Bart Schaefer
1999-06-16  6:56 ` PATCH: " Bart Schaefer
1999-06-16  8:51   ` PATCH: pws-22: " Peter Stephenson
1999-06-15 17:16 David Aspinwall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=un1y28rsc.fsf@TimesTen.com \
    --to=aspinwall@timesten.com \
    --cc=amol@blarg.net \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).