Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16680
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: set -u not working as expected |
| Date | 2020-08-02 16:51 -0400 |
| Organization | ITS, Case Western Reserve University |
| Message-ID | <mailman.589.1596401494.2739.bug-bash@gnu.org> (permalink) |
| References | (1 earlier) <F4821044-5F8D-4B6D-A266-BAC88AE3DC2C@larryv.me> <1867D8FC-85DD-4406-A239-3002913493AB@larryv.me> <CAH7i3Lr7ZCYJVpPZdc9xQMuF_yc_C2q0S9px+NY4prEUkU+24w@mail.gmail.com> <61B2CB9D-3978-4872-B88A-1542CF95B5B9@larryv.me> <43c4daba-4ec4-bf54-6674-8e29d86d8de3@case.edu> |
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 chet@case.edu http://tiswww.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: set -u not working as expected Chet Ramey <chet.ramey@case.edu> - 2020-08-02 16:51 -0400
csiph-web