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

Re: check exit code



sac sent me the following 0.7K:

> > I want to check exit code of some command through
> > the $? variable
> > (putting command into 'if' statement is not
> > acceptable).
> > I found currently two ways to do so:
> > if (( $? == 0 )); then; echo true; else; echo false;
> > fi
> > if  ( exit $? ) ; then; echo true; else; echo false;
> > fi
> > 
> > Neither of them seems to be elegant. Maybe there is a builtin which
> > takes number as argument and returns it? Or what would you suggest?
> 
> if [ $? -eq 0 ]; then; echo "ture"; fi

Or try the print builtin:

   print -P '%(?.true.false)'

-- 
Chris Johnson
cjohnson@xxxxxxxxxx
http://www.cs.utk.edu/~cjohnson



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