On 8/2/20 3:34 AM, Lawrence Velázquez wrote: >>> % bash -c 'set -u; typeset -i v; v+=1; printf "<%s>\\n" "$v"' >>> <1> >>> % ksh -c 'set -u; typeset -i v; v+=1; printf "<%s>\\n" "$v"' >>> <1> >>> % zsh -c 'set -u; typeset -i v; v+=1; printf "<%s>\\n" "$v"' >>> <1> > > ...which contrasts with the behavior of let. Someone else will have > to explain this, as I don't know what to make of it.
The integer attribute means the rhs of the assignment operator is evaluated as an expression. It doesn't mean the assignment is performed in an arithmetic context, as with `let' or `$((...))'. The special case, which is done to conform to user expections, is that the result is added to the current value, if any, instead of being appended like the usual behavior of `+='. Note that there are no corresponding `name*=value' or `name-=value' variable assignment operators, and that `-u' isn't in effect for any use of `+=', whether the integer attribute is present or not. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/