Andreas Schwab wrote in <[email protected]>: |On Jul 09 2022, Steffen Nurpmeso wrote: |> $ bash -c 'I=3; echo "$((1?(I*=I):I+=I))";echo $I' | |The third operand of ?: cannot contain an assignment expression, thus, |like in C, this is parsed as `(1?(I*=I):I)+=I'. .. --End of <[email protected]>
Chet Ramey wrote in <[email protected]>: |On 7/9/22 5:58 PM, Steffen Nurpmeso wrote: ... |> $ bash -c 'I=3; echo "$((1?(I*=I):(I+=I)))";echo $I' | |The parens override precedence. | |> $ bash -c 'I=3; echo "$((1?(I*=I):I+=I))";echo $I' |> bash: line 1: 1?(I*=I):I+=I: attempted assignment to non-variable \ |> (error token is "+=I") | |The normal rules of precedence apply, and the conditional expression on the |rhs of the `:' can't contain an assignment, since the assignment operator |has higher precedence. | | |> $ bash -c 'I=3; echo "$((1?I*=I:(I+=I)))";echo $I' | |The parens override precedence. Sorry for the noise then. And thanks for the explanation. (Assignment has lower.) --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)
