According to the man page, the following should work: typeset -i i=0 i+=1 echo "i == $i" Expected output: "i == 1" Received output: ./t: line 3: i+=1: command not found i == 0 It works however with strings (output: "i == 11") or, in the above context with numbers, when preceding the statement with "let" ("let i +=1"). It works as expected with bash 3.2 (RHEL 5): [angenenr@shutdown ~]$typeset -i i=0 [angenenr@shutdown ~]$i+=1 [angenenr@shutdown ~]$echo "i == $i" i == 1 I have no idea if that might be an upstream bug upto patchlevel 19 (I cannot reach the bash homepage at the moment, patches on the gnu.org mirrors only go upt to 30-16).
According which paragraph and/or section of man page? In order to "turn on" arithmetic evaluation you should a) use `let' builtin (man let) b) use ((expression)) (man bash) Expected behavior as you mentioned is only in newer bash as feature not as fixed bug. Therefor this is expected behavior.
typeset -i i=0 ((i+=1)) echo "i == $i"
Okay, I don't see a difference between the manual pages of bash 3.2 and 3.0 regarding that. I was referencing declare [-afFirtx] [-p] [name[=value] ...] typeset [-afFirtx] [-p] [name[=value] ...] Declare variables and/or give them attributes. If no names are given then display the values of variables. The -p option will dis- play the attributes and values of each name. When -p is used, addi- tional options are ignored. The -F option inhibits the display of function definitions; only the function name and attributes are printed. If the extdebug shell option is enabled using shopt, the source file name and line number where the function is defined are displayed as well. The -F option implies -f. The following options can be used to restrict output to variables with the specified attribute or to give variables attributes: [...] -i The variable is treated as an integer; arithmetic evaluation (see ARITHMETIC EVALUATION ) is performed when the variable is assigned a value. But having rebuilt 3.0.16 from gnu.org, I see the same behaviour. The package name distracted me a bit, I thought we were on patchset 19 (not 15). Sorry.