Post by Peng Yu
I think that there is a mix of two purposes 1) just using the
numerical values, 2) conditional testing. They should not be mixed up.
For the case of ((a > b)), it is obviously a testing. Then it makes
sense to return 1.
But for ((i--)) or ((x)), it is only the numerical values that matter.
In the context of while ((i--)) and ((x)) && echo hi, they can be
written as while ((i--==0)) and ((x==0)) && echo hi to make elimintate
I'm not sure if having a special case for this is a good idea.
It follows the C syntax and like in C the assignment has the value of the
of the variable after the assignment.
For what it's worth some think that it is not a good idea and error prone
e.g. python doesn't allow this.
Moreover, other assignments in bash can exit with non 0 eg:
I personally prefer using: x=$(( )) rather than ((x=)), I find it more
natural and it doesn't exit with 1.