bug-bash
[Top][All Lists]
Advanced

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

Re: $(()): "?:": false "assignment to non-variable"


From: Dennis Williamson
Subject: Re: $(()): "?:": false "assignment to non-variable"
Date: Mon, 11 Jul 2022 12:15:32 -0500

On Mon, Jul 11, 2022 at 8:22 AM Chet Ramey <chet.ramey@case.edu> wrote:

> 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.
>
>
This excerpt from the Bash man page ARITHMETIC EVALUATION section:

       expr?expr:expr
              conditional operator
       = *= /= %= += -= <<= >>= &= ^= |=
              assignment

indicates that assignment has a lower precedence than the overall ternary
without specifying precedence of individual parts of it.

Interestingly, zsh requires both assignments to be parenthesized and ksh
doesn't require either. Bash is like C and ksh is like cpp.


reply via email to

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