From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16194 invoked from network); 23 Jun 2001 03:51:33 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 23 Jun 2001 03:51:33 -0000 Received: (qmail 16802 invoked by alias); 23 Jun 2001 03:50:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15050 Received: (qmail 16769 invoked from network); 23 Jun 2001 03:50:44 -0000 From: "Bart Schaefer" Message-Id: <1010623034918.ZM6314@candle.brasslantern.com> Date: Sat, 23 Jun 2001 03:49:18 +0000 In-Reply-To: <000601c0fae0$d819c640$21c9ca95@mow.siemens.ru> Comments: In reply to "Andrej Borsenkow" "RE: status codes on Dec OSF" (Jun 22, 10:01am) References: <000601c0fae0$d819c640$21c9ca95@mow.siemens.ru> X-Mailer: Z-Mail (5.0.0 30July97) To: Subject: PATCH: POSIX exit codes (not quite Re: status codes on Dec OSF) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jun 22, 10:01am, Andrej Borsenkow wrote: } Subject: RE: status codes on Dec OSF } } > >From the dec 4.0F machine } > % /opt/bcs/packages/zsh-4.0.1/bin/zsh -x foo } > +foo:1> FOO=+foo:1> jfkljfs } > foo:1: command not found: jfkljfs } > +foo:1> FOO= } > +foo:2> echo 0 } > 0 } } } Sigh, this is a bug :-( It's a bug on a particular operating system, and one which Sven was not able to reproduce. I'm made suspicious by "/opt/bcs/" in the command name. That smells of "binary compatibility standard" to me -- which could mean that zsh was not compiled for the operating system under which it is executing. Apparently quoting from the POSIX standard, Andrej goes on: } If there is a command name, execution will continue as described in Command } Search and Execution . If there is no command name, but the command } contained a command substitution, the command will complete with the exit } status of the last command substitution performed. Otherwise, the command } will complete with a zero exit status. } } If a command is not found, the exit status will be 127. If the command name } is found, but it is not an executable utility, the exit status will be 126. } Applications that invoke utilities without using the shell should use these } exit status values to report similar errors. Zsh already conforms to the first paragraph (or at least attempts to); the patch below deals with the second paragraph. Sample output: zagzig% foo=`stamp-h` zsh: command not found: stamp-h zagzig% echo $? 127 zagzig% foo=`./stamp-h` zsh: permission denied: ./stamp-h zagzig% echo $? 126 zagzig% echo foo=`./stamp-h` zsh: permission denied: ./stamp-h foo= zagzig% echo $? 0 Is there any possibility that anyone is relying explicitly upon (($? == 1)) as was formerly the case for both command-not-found and permission-denied? --- zsh-forge/current/Src/exec.c Wed Jun 20 08:57:01 2001 +++ zsh-4.0/Src/exec.c Fri Jun 22 20:04:31 2001 @@ -502,7 +502,7 @@ (arg0[0] == '.' && (arg0 + 1 == s || (arg0[1] == '.' && arg0 + 2 == s)))) { zerr("%e: %s", arg0, errno); - _exit(1); + _exit(errno == EACCES ? 126 : 127); } break; } @@ -556,7 +556,7 @@ zerr("%e: %s", arg0, eno); else zerr("command not found: %s", arg0, 0); - _exit(1); + _exit(eno == EACCES ? 126 : 127); } #define RET_IF_COM(X) { if (iscom(X)) return docopy ? dupstring(X) : arg0; } -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net