On Wed, May 10, 2023, 19:45 Baumann, Moritz <moritz.baum...@sap.com> wrote:
> > 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 > [[ -v arr[\$var] ]] Anyway, thank you for the detailed reply and sorry for the bogus report. > > Best regards, > Moritz Baumann > >