[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feature request: more complete set -e
From: |
Chet Ramey |
Subject: |
Re: feature request: more complete set -e |
Date: |
Mon, 29 Jun 2009 09:55:25 -0400 |
> > echo `expr $var - 1`
> shrug. I didn't knew that either.
> I think that this is bad. expr should do some calculation. If the
> calculation fails (eg devision by zero) the return value should be non
> zero.
It depends on what you mean by `fail'. expr certainly returns a non-zero
result for things like division by zero, but it also returns a non-zero
exit status if the result of the expression is 0. (This is like the bash
`let' builtin and the (( ... )) compound command.)
To do otherwise would have made expr much less useful. Idioms such as
var=10
while var=`expr $var - 1`
do
echo $var
done
would have been impossible to express directly.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, ITS, CWRU chet@case.edu http://tiswww.tis.case.edu/~chet/
- feature request: more complete set -e, Marc Weber, 2009/06/22
- Re: feature request: more complete set -e, Chet Ramey, 2009/06/23
- Re: feature request: more complete set -e, Marc Weber, 2009/06/24
- Re: feature request: more complete set -e, Chet Ramey, 2009/06/25
- Re: feature request: more complete set -e, Marc Weber, 2009/06/28
- Re: feature request: more complete set -e, Greg Wooledge, 2009/06/29
- Re: feature request: more complete set -e,
Chet Ramey <=
- Re: feature request: more complete set -e, Bob Proulx, 2009/06/29
- Re: feature request: more complete set -e, Marc Weber, 2009/06/30
- Re: feature request: more complete set -e, Greg Wooledge, 2009/06/30
- Re: feature request: more complete set -e, Chet Ramey, 2009/06/30