help-bash
[Top][All Lists]
Advanced

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

arithmetic evaluation : no assignment


From: watael rocketmail
Subject: arithmetic evaluation : no assignment
Date: Fri, 8 Nov 2024 11:32:07 +0100
User-agent: Mozilla Thunderbird

hi,

a=1; b=2 #no c
echo $(( c=$b-$a , $c>$a+$b ? $c-$a : $c+$b ))
bash: c=2-1 , >1+2 ? -1 : +2 : syntax error: operand expected (error token is ">1+2 ? -1 : +2 ")

I don't remember this didn't work.

when I let the evaluation as is, and assign c outside, then it's the "outer" value that is used

unset c
c=13
set -x; (( c=$b-$a , $c>$a+$b ? $c-$a : $c+$b )); set +x
+ ((  c=2-1 , 13>1+2 ? 13-1 : 13+2  ))

reply via email to

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