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

Re: error code for failure to execute



Clint Adams wrote:
> > Yes, I think so, but I don't really understand the question.
> > Are you asking about the following?
> 
> No, I'm confused by why it changes from 126 to 127 when stderr is
> redirected to /dev/null.

Ah.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.105
diff -u -u -r1.105 exec.c
--- Src/exec.c	6 Nov 2006 12:49:21 -0000	1.105
+++ Src/exec.c	19 Nov 2006 21:32:03 -0000
@@ -522,12 +522,12 @@
     }
     for (s = arg0; *s; s++)
 	if (*s == '/') {
-	    errno = zexecve(arg0, argv);
+	    int lerrno = zexecve(arg0, argv);
 	    if (arg0 == s || unset(PATHDIRS) ||
 		(arg0[0] == '.' && (arg0 + 1 == s ||
 				    (arg0[1] == '.' && arg0 + 2 == s)))) {
-		zerr("%e: %s", errno, arg0);
-		_exit((errno == EACCES || errno == ENOEXEC) ? 126 : 127);
+		zerr("%e: %s", lerrno, arg0);
+		_exit((lerrno == EACCES || lerrno == ENOEXEC) ? 126 : 127);
 	    }
 	    break;
 	}

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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