Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486'
-DCONF_OSTYPE='linu
x-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc'
-DLOCALEDIR='/usr/
share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash
-I../bas
h/include -I../bash/lib -g -O2 -Wall
uname output: Linux rdiff-backup1 2.6.32-26-generic-pae #48-Ubuntu SMP
Wed Nov 2
4 10:31:20 UTC 2010 i686 GNU/Linux
Machine Type: i486-pc-linux-gnu
Bash Version: 4.1
Patch Level: 5
Release Status: release
Description:
$ val=0; let val++; echo $val,$?; unset val
1,1
see the error code 1. Setting any other start value (except undefined)
for val does not produce this error, the problem occurs for let val++
and let val-- if the start value is 0.
for let ++val and let --val the problem occurs if the result is 0. Also
for the
command:
$ val=10; let val=val+2*2-14; echo $val,$?; unset val
Repeat-By:
See the examples above
Why does this happen? Is it 'by design'? It makes arithmetic with bash
let very dangerous because it can throw unexpected errors (and break
scripts running with set -e).