On 8/28/2020 1:00 AM, Gabriel Winkler wrot
> # Causes error
> test=0
> ((test++))
> echo $?
> 1
> echo $test
> 1
>
"((...))" is the "test form" for an integer expression. That means
it will return true if the value of the interior, "...", of "((...))"
is non-zero and return false if ((... == 0)). Remember "$?==0" == true
and "$?!=0" == false,
so if "..." is an expression then for:
... is 0 is non-0
then
((...)) is false is true
$? is 1 is 0
deciding that ((non-zero)) = true was consistent with most programmers'
expectations from other languages that 0 was false and non-zero was
true (which is opposite of the final value of "$?").
[Prev in Thread]
Current Thread
[Next in Thread]
Yup!: Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1,
L A Walsh<=