bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arithmetic expression: recursive VAR evaluation suppresses desired V


From: Chet Ramey
Subject: Re: Arithmetic expression: recursive VAR evaluation suppresses desired VAR assignment
Date: Thu, 11 Aug 2022 11:03:33 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.1.2

On 8/11/22 10:00 AM, Steffen Nurpmeso wrote:
.
Can you also explain this:

   $ bash -c ' I1=I2=10 I2=5 I3=I2+=1; echo "<$(( I1*=1?I1:I3 ))>";echo 
"<$I1><$I2><$I3>"'
   <100>
   <100><10><I2+=1>

I1 *= 1?I1:I3
I1 *= I1
I1 = I1 * I1
I1 = (I2=10) * (I2=10)
I1 = 10 * 10
I1 = 100

Along the way, I2 is set to 10. Twice.

   $ bash -c ' I1=I2=10 I2=5 I3=I2+=1; echo "<$(( I1=1?I1:I3 ))>";echo 
"<$I1><$I2><$I3>"'

I1 = 1?I1:I3
I1 = I1
I1 = (I2 = 10)
I1 = 10

Ditto about I2, but once.

--
``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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]