On Wed, 27 Oct 2021 21:09:29 +0200
Toralf Förster <toralf.foers...@gmx.de> 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 a post-increment operator. The evaluated number is 0.

> 
> i is always set to 0, the result is always non-zero, but the return code
> differs.

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.

-- 
Kerin Millar

Reply via email to