Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall uname output: Linux andrewm-Satellite-P50-A 4.4.0-72-generic #93-Ubuntu SMP Fri Mar 31 14:07:41 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.3 Patch Level: 42 Release Status: release Description: The return code from ((i++)) operation is different when i has an initial value of 0. This problem was discovered when running run a bash script with "set -ue" and having "((i++))" as the last command in a loop. Repeat-By: The following script will quit with an error after the first iteration due to the return code errantly being 1. #!/bin/bash set -eu i=0 for a in a b c do echo "${a}" ((i++)) done NB: If i starts as 1, the script works as expected. Also, using ((i+=1)) works fine, but I prefer the ((i++)) format. Proof outside a loop: $ c=0;((c++));echo $? 1 $ c=1;((c++));echo $? 0