From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1102 invoked from network); 30 May 2006 17:49:15 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.2 (2006-05-25) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.2 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 May 2006 17:49:15 -0000 Received: (qmail 79887 invoked from network); 30 May 2006 17:49:09 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 May 2006 17:49:09 -0000 Received: (qmail 17051 invoked by alias); 30 May 2006 17:49:06 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22473 Received: (qmail 17042 invoked from network); 30 May 2006 17:49:06 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 30 May 2006 17:49:06 -0000 Received: (qmail 79585 invoked from network); 30 May 2006 17:49:06 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 30 May 2006 17:49:05 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly19c.srv.mailcontrol.com (MailControl) with ESMTP id k4UHn0qm030472 for ; Tue, 30 May 2006 18:49:01 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Tue, 30 May 2006 18:48:04 +0100 Date: Tue, 30 May 2006 18:48:59 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: Vanishing files ? Message-Id: <20060530184859.1185ebdc.pws@csr.com> In-Reply-To: <200605291532.k4TFWueM011027@pwslaptop.csr.com> References: <20060529075722.GA28846@sci.fi> <200605291532.k4TFWueM011027@pwslaptop.csr.com> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 2.0.4 (GTK+ 2.6.7; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 May 2006 17:48:04.0517 (UTC) FILETIME=[33CF4550:01C68411] X-Scanned-By: MailControl A-07-00-01 (www.mailcontrol.com) on 10.67.0.129 Peter Stephenson wrote: > Anssi Saari wrote: > > bash: ./foo: /bin/foo: bad interpreter: No such file or directory > > This turns out to be easy; the function already does path look up and > even has code to search for the interpreter (to emulate #! on older > systems where it wasn't implemented natively). It relies on the error > being ENOENT (no such file or directory), not ENOEXEC (exec format > error); this is the case on all the systems I know about (haven't check > any relevant standards). Unfortunately this doesn't work very well in a case like the one we have where the interpreter name is strange, since the \r is interpreted literally and you end up with something like : no such file or directorybad interpreter: /bin/sh To fix this properly we need to be able to display two properly formatted strings in an error message: it's many, many years past the point where error messages should have used variable-length argument lists. This would be a nice, self-contained project for someone; we can probably assume stdarg is available now (since we seem to assume a lot of ISO C elsewhere). Until someone fixes that, the less bad alternative is probably to assume that the interpreter name is more likely to need special handling than the script name. I note that nicechar() and wcs_nicechar() print \n as \n, but \r as ^M. This isn't too bad, but it's a little inconsistent. We should probably handle at least the standard C codes, unless anyone can see why we shouldn't. Anyway, until then, you get things like zsh: /home/pws/tmp/noexec: bad interpreter: /bin/sh^M: no such file or directory (wrapped the line myself to avoid giving the pleasure to our mail software). Index: Src/exec.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/exec.c,v retrieving revision 1.99 diff -u -r1.99 exec.c --- Src/exec.c 29 May 2006 15:36:26 -0000 1.99 +++ Src/exec.c 30 May 2006 17:37:45 -0000 @@ -409,9 +409,12 @@ char *buf; if (*ptr) *ptr = '\0'; - buf = tricat("%s: bad interpreter: ", ptr2, - ": %e"); - zerr(buf, pth, eno); + /* + * TODO: needs variable argument handling + * in zerrmsg() etc. to do this properly. + */ + buf = dyncat(pth, ": bad interpreter: %s: %e"); + zerr(buf, ptr2, eno); } else if (*ptr) { *ptr = '\0'; argv[-2] = ptr2; To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php