[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Inconsistent arithmetic evaluation of parameters
From: |
Chet Ramey |
Subject: |
Re: Inconsistent arithmetic evaluation of parameters |
Date: |
Wed, 2 Sep 2015 10:06:28 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
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/
- Re: Inconsistent arithmetic evaluation of parameters, (continued)
- Re: Inconsistent arithmetic evaluation of parameters, Andreas Schwab, 2015/09/02
- Re: Inconsistent arithmetic evaluation of parameters, Dennis Williamson, 2015/09/02
- Re: Inconsistent arithmetic evaluation of parameters, Greg Wooledge, 2015/09/02
- Re: Inconsistent arithmetic evaluation of parameters, Chet Ramey, 2015/09/02
- Re: Inconsistent arithmetic evaluation of parameters, Greg Wooledge, 2015/09/02
- Re: Inconsistent arithmetic evaluation of parameters, Chet Ramey, 2015/09/03
- Re: Inconsistent arithmetic evaluation of parameters, Chet Ramey, 2015/09/02
- Re: Inconsistent arithmetic evaluation of parameters, Stephane Chazelas, 2015/09/03
- Re: Inconsistent arithmetic evaluation of parameters, Dennis Williamson, 2015/09/03
- Re: Inconsistent arithmetic evaluation of parameters, Chet Ramey, 2015/09/02
Re: Inconsistent arithmetic evaluation of parameters,
Chet Ramey <=