Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11460
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Inconsistent arithmetic evaluation of parameters |
| Date | 2015-09-02 10:06 -0400 |
| Message-ID | <mailman.391.1441202797.19560.bug-bash@gnu.org> (permalink) |
| References | <61895190-83A6-4D62-B90E-65023D5E966B@gmail.com> |
On 9/1/15 12:50 AM, Clint Hepner wrote: > Bash Version: 4.3 > Patch Level: 42 > Release Status: release > > Description: > > Parameter names are recursively evaluated in an arithmetic expression, but this > is not done consistently. Parameter names are expanded and treated as expressions where they need to be evaluated as a number, and as identifiers when they are the subject of assignment. This is the usual way to handle context-dependent evaluation. > Repeat-By: > > foo=bar > bar=5 > echo $(( foo )) # produces 5 > echo $(( foo++ )) # produces 5 > echo $foo # produces 6, not bar > echo $bar # produces 5, not 6 Consider this equivalent expression: oldfoo=foo,foo=foo+1,oldfoo Would you claim that the foo on the lhs of the assignment statement should be expanded to `bar'? How would assignments ever be performed if it were? -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: Inconsistent arithmetic evaluation of parameters Chet Ramey <chet.ramey@case.edu> - 2015-09-02 10:06 -0400
csiph-web