[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Arithmetic expression: recursive VAR evaluation suppresses desired V
Re: Arithmetic expression: recursive VAR evaluation suppresses desired VAR assignment
Thu, 11 Aug 2022 18:41:23 +0200
Chet Ramey wrote in
|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 *= 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 = 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!
Sorry for all the noise.
|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)