From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23225 invoked from network); 15 Jun 1999 23:31:05 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 15 Jun 1999 23:31:05 -0000 Received: (qmail 27611 invoked by alias); 15 Jun 1999 23:30:47 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6647 Received: (qmail 27588 invoked from network); 15 Jun 1999 23:30:46 -0000 To: zsh-workers@math.gatech.edu Date: Tue, 15 Jun 1999 10:16:19 -0700 From: "David Aspinwall" Message-ID: Mime-Version: 1.0 X-Sent-Mail: on X-Mailer: MailCity Service Subject: execve bug X-Sender-Ip: 207.214.82.146 Organization: My Deja Email (http://www.my-deja.com:80) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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.