From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28352 invoked from network); 16 Jun 1999 06:57:23 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 16 Jun 1999 06:57:23 -0000 Received: (qmail 20557 invoked by alias); 16 Jun 1999 06:56:44 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6652 Received: (qmail 20550 invoked from network); 16 Jun 1999 06:56:42 -0000 From: "Bart Schaefer" Message-Id: <990616065637.ZM25982@candle.brasslantern.com> Date: Wed, 16 Jun 1999 06:56:37 +0000 In-Reply-To: Comments: In reply to David Aspinwall "execve bug" (Jun 14, 1:13pm) References: X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk Subject: PATCH: Re: execve bug MIME-Version: 1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii (I inadvertently sent another copy of this though math.gatech.edu because that's where David sent the mail to which I replied. My other doesn't have the word "PATCH" in the header, and hasn't come back to me yet, so on the chance that it's been hung out in limbo I'm sending this one.) 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 -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com