Date:        Mon, 14 Jul 2025 15:22:35 -0400
    From:        Chet Ramey <chet.ra...@case.edu>
    Message-ID:  <90a41c5d-c407-4a36-b7b1-21a9201b4...@case.edu>

  | Say you have something like
  |
  | if command; then
  |     declare -i X
  |     X=some-random-expression
  | fi
  |
  | How does the parser determine the assignment should be parsed as an
  | arithmetic expression?

There is a much better example of the problem:

func() {
        if eval "$1"; then
                declare -i X=something
        else
                unset X
        fi
        X=whatever-you-like
}

Now work out how to parse things in a context dependent way.

What's more, all this needs to work, and to be consistent, and
logical for the user to understand.

And note that "whatever..." may contain any kind of expansion,
including $(( )) any kind of var reference, including to $X, including
using that as an index into some kind of array.

kre

Reply via email to