bug-bash
[Top][All Lists]
Advanced

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

Re: inconsistent readonly error behavior


From: Oğuz
Subject: Re: inconsistent readonly error behavior
Date: Tue, 22 Dec 2020 23:32:51 +0200

22 Aralık 2020 Salı tarihinde Travis Everett <travis.a.everett@gmail.com>
yazdı:

> I don't understand what distinction you're trying to make; any example you
> can give?
>
> I added an extra near-copy of the script to the gist replacing the
> assignment with unset (https://gist.github.com/abathur/
> 8d18853e06f2a8cf3a97e45acda17f68#file-unset-sh-console), and
> corresponding output where you can see that it hits all of the lines
> skipped in the assignment example. (The behavior in this example is in line
> with what I see by replacing the assignment with other errors like a
> missing command, or a ${parameter:?word} expansion.)
>

I wouldn't expect `unset' to have that effect either. That an error that
can be detected during parse discards the entire input line or the
surrounding compound command makes sense though. I don't think a change is
needed, it wouldn't make sense to me if these two printed `reached`, and
the third printed `b=2'.

    if true; then
      : ${x!y}
      echo reached
    fi

    set -u
    if true; then
      : ${x}
      echo reached
    fi

    readonly a=1
    b=1
    if true; then
      (( a += 1, b += 1 ))
      echo b=$b
    fi


-- 
Oğuz


reply via email to

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