Andreas Schwab wrote in <mvmpmiblsvn....@suse.de>: |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 <mvmpmiblsvn....@suse.de>
Chet Ramey wrote in <52011ddb-824b-73d0-f1c8-c295ffa1f...@case.edu>: |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)