[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: nounset option: Error message points to the wrong variable when acce
From: |
Baumann, Moritz |
Subject: |
RE: nounset option: Error message points to the wrong variable when accessing associative arrays |
Date: |
Wed, 10 May 2023 17:44:54 +0000 |
> Anyway, that is still correct behaviour; the reason why that happens is
> that when you assign you perform an array expansion on a variable that
> is neither a -a nor a -A variable, the variable is treated as a -a
> (indexed array) variable.
Thank you for the explanation. I was immediately wondering about the reason
for the unfortunate order of evaluation, but you covered that, too:
> Also note that nounset does not report errors if you expand an array
> variable that is not set with @, or a [@]:start:length PE that does not
> have values, that is why the subscript is evaluated first.
So, the error message might be extremely confusing, but it cannot be fixed.
In the case that lead me to submit this report, the error even occurred
inside a check for the existence of an array key, which made the resulting
message even weirder:
if [[ -v "mistyped_array[$1]" ]]; then
...
fi
Anyway, thank you for the detailed reply and sorry for the bogus report.
Best regards,
Moritz Baumann
- nounset option: Error message points to the wrong variable when accessing associative arrays, Baumann, Moritz, 2023/05/10
- Re: nounset option: Error message points to the wrong variable when accessing associative arrays, Emanuele Torre, 2023/05/10
- Re: nounset option: Error message points to the wrong variable when accessing associative arrays, Emanuele Torre, 2023/05/10
- RE: nounset option: Error message points to the wrong variable when accessing associative arrays,
Baumann, Moritz <=
- Re: nounset option: Error message points to the wrong variable when accessing associative arrays, Emanuele Torre, 2023/05/10
- RE: nounset option: Error message points to the wrong variable when accessing associative arrays, Baumann, Moritz, 2023/05/10
- RE: nounset option: Error message points to the wrong variable when accessing associative arrays, Baumann, Moritz, 2023/05/11
- Re: nounset option: Error message points to the wrong variable when accessing associative arrays, Emanuele Torre, 2023/05/11
- Re: nounset option: Error message points to the wrong variable when accessing associative arrays, alex xmb ratchev, 2023/05/10
Re: nounset option: Error message points to the wrong variable when accessing associative arrays, Andreas Schwab, 2023/05/10