On 10/27/21 10:09 PM, Kerin Millar wrote:
This is to be expected. It works the same way as in other languages, such as C.
You should use the operator that reflects your intent.
Understood - thx for the explanation.
--
Toralf
On Wed, 27 Oct 2021 21:09:29 +0200
Toralf Förster wrote:
> Hi,
>
> expected:
> $ i=0; ((i = i + 1)); echo $?
> 0
>
> expected:
> $ i=0; ((++i)); echo $?
> 0
This makes use of a pre-increment operator. The evaluated number is 1.
>
> unexpected:
> $ i=0; ((i++)); echo $?
> 1
This makes use of
On Wed, Oct 27, 2021 at 09:09:29PM +0200, Toralf Förster wrote:
> unexpected:
> $ i=0; ((i++)); echo $?
> 1
https://mywiki.wooledge.org/BashFAQ/105
Hi,
expected:
$ i=0; ((i = i + 1)); echo $?
0
expected:
$ i=0; ((++i)); echo $?
0
unexpected:
$ i=0; ((i++)); echo $?
1
i is always set to 0, the result is always non-zero, but the return code
differs.
More info:
a stable hardened Gentoo Linux:
$ bash --version
GNU bash, version 5.1.8(1)-