zsh-workers
 help / color / mirror / code / Atom feed
From: "David Aspinwall" <aspin@my-deja.com>
To: zsh-workers@math.gatech.edu
Subject: execve bug
Date: Tue, 15 Jun 1999 10:16:19 -0700	[thread overview]
Message-ID: <OGEFKFHDEIKAEAAA@my-deja.com> (raw)

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.


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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-15 17:16 David Aspinwall [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-06-14 20:13 David Aspinwall
1999-06-16  6:42 ` Bart Schaefer

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=OGEFKFHDEIKAEAAA@my-deja.com \
    --to=aspin@my-deja.com \
    --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).