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    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to