[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: arithmetic evaluation : no assignment
From: |
Chet Ramey |
Subject: |
Re: arithmetic evaluation : no assignment |
Date: |
Fri, 8 Nov 2024 09:20:58 -0500 |
User-agent: |
Mozilla Thunderbird |
On 11/8/24 5:32 AM, watael rocketmail via wrote:
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.
The (( compound command performs word expansions on the individual words
between the (( and closing )) before evaluating the result as an
expression. This is from the man page:
"The expression undergoes the same ex-
pansions as if it were within double quotes, but double quote
characters in expression are not treated specially and are re-
moved."
`(( expression ))' is just about equivalent to `let "expression"'.
--
``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/
OpenPGP_signature.asc
Description: OpenPGP digital signature