Re: $(()): "?:": false "assignment to non-variable"
From:
Chet Ramey
Subject:
Re: $(()): "?:": false "assignment to non-variable"
Date:
Mon, 11 Jul 2022 09:22:25 -0400
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0
On 7/9/22 5:58 PM, Steffen Nurpmeso wrote:
Hey,
sorry to come back, but when banging against ?: implementation
i saw this bash 5.1.16 bug:
$ 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.
The parens override precedence.
--
``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/