From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23335 invoked from network); 15 Jun 1999 23:36:34 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 15 Jun 1999 23:36:34 -0000 Received: (qmail 29630 invoked by alias); 15 Jun 1999 23:36:16 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6648 Received: (qmail 29622 invoked from network); 15 Jun 1999 23:36:15 -0000 To: amol@blarg.net, zsh-workers@math.gatech.edu Subject: execve bug X-Face: _s55Gf%Rq2OUH2t)0RDSD&[O}DEX/.!e@peMi]W+&,4~0j)$FBgMu;!E1FRiWerH6\fM\P3 %0VB`o%XIv,;Z4u[*u!=/B^:PbVx'eR5;g3Ljz!QPiS=|kw'r~&A( Date: 14 Jun 1999 13:13:07 -0700 Message-ID: User-Agent: Gnus/5.070083 (Pterodactyl Gnus v0.83) Emacs/20.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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++);