Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: check exit code
- X-seq: zsh-users 11656
- From: Chris Johnson <cjohnson@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: check exit code
- Date: Wed, 18 Jul 2007 08:59:25 -0400
- In-reply-to: <589839.11493.qm@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20070718095930.GA4936@crematorium> <589839.11493.qm@xxxxxxxxxxxxxxxxxxxxxxxxx>
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