Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Vanishing files ?



Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> 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



Messages sorted by: Reverse Date, Date, Thread, Author