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: Steffen Nurpmeso
Subject: Re: Arithmetic expression: recursive VAR evaluation suppresses desired VAR assignment
Date: Thu, 11 Aug 2022 18:41:23 +0200
User-agent: s-nail v14.9.24-285-gae76455589

Chet Ramey wrote in
 <a33a5106-8ffc-d7d4-a17d-454f108b1ff9@case.edu>:
 |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.

Yes, thank you.  I had a

  fix $(()) precedence bug in "X=A?B:C" (it is _not_ "(X=A)?..)"

enlightenment in the meantime (it was a simple precedence bug,
a single line fix, i should have sat down and let it rest for
a while, for weeks i was looking at myriads of Dijkstra stack pop
debug messages, maybe that explains a bit).  And it was all my
fault.  bash is absolutely on the correct side -- luckily there
was a fully fledged parser i could use to test against!
Thank you.

Sorry for all the noise.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



reply via email to

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