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

Re: Parse errors don't cause a non-zero exit code?



On Fri, 1 Apr 2005 1:08pm  +0100, Peter Stephenson wrote:

> builtin/function returns status X" is a perfectly natural way of saying
> "returns the exit status X" given that the command doesn't actually exit
> (in the UNIX sense).  In other words, I don't think I want to play any
> more.

Hi Peter,

About this issue, I have a long-term question about the exit status of zsh 
when it gets passed an script as argument:

% zsh a
a: can't open input file: a
% print $?
1
% a
zsh: command not found: a
% print $?
127
%

I am aware that the standard isn't very clear in this respect, but most 
shells explicitly interpret both cases the same way, returning 127 when 
the shell gets a command as an argument.

$ ksh --version
  version         sh (AT&T Labs Research) 1993-12-28 q
$ ksh a
ksh: line 1: a: not found
$ echo $?
127
$

$ bash --version
GNU bash, version 3.00.0(1)-release (i586-pc-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
$ bash a
bash: a: No such file or directory
$ echo $?
127
$

I have recently talked with Michael Rendell about this issue on pdksh and 
he OK'ed the patch I sent to him, though he is not planning to make a new 
release of pdksh :-)

-- 
Felipe Kellermann



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