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

RE: status codes on Dec OSF



>
> The following script produces different results when run on a dec
> machine vs
> a solaris machine. It seems the dec doesn't see the status code
> of the command
> if your setting the output to a varible.
>
> %cat foo
> FOO=`jfkljfs`
> echo $?
> FOO=`pwd`
> echo $?
>
> jfkljfs
> echo $?
> pwd
> echo $?
>
>
> >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 :-(

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.


 Actually, zsh has long standing POSIX incompatibility w.r.t. exit codes; I
am not sure how diffecult it is to change it:

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.

-andrej



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