I noticed a clear discrepancy in the return status of bash (( )) . Consider the following
$> A=0 $> ((A=A+1)) $> echo $? $A 0 1
However, using another known abbreviated increment, we get:
$> A=0 $> ((A++)) $> echo $? $A 1 1
If the script has a built-in set -e , then the second entry will end the script, since the exit status ((A++)) returned non-zero. This question has been more or less considered in this related question . But this does not seem to explain the difference in output status for the two designations ((A=A+1)) and ((A++))
((A++)) seems to return 1 if and only if A is 0 . (Disclaimer: I did not do exhaustive tests. Tested in bash 4.1.2 and 4.2.25). Therefore, the last question boils down to the following:
Why is A=0; ((A++)) A=0; ((A++)) returns 1 ?
bash
Pankrates
source share