> > 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    c...@case.edu    http://tiswww.tis.case.edu/~chet/


Reply via email to