bug-bash
[Top][All Lists]
Advanced

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]