[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ${param@a} should bypass unbound variable check or be processed ahea
From: |
Grisha Levit |
Subject: |
Re: ${param@a} should bypass unbound variable check or be processed ahead of it. |
Date: |
Sun, 20 Oct 2024 23:08:38 -0400 |
On Sun, Oct 13, 2024, 14:58 Chet Ramey <chet.ramey@case.edu> wrote:
> On 10/1/24 3:54 AM, konsolebox wrote:
> > # declare -A x
> > # echo ${x@a}
> > A
> > # set -u
> > # echo ${x@a}
> > bash: x: unbound variable
> >
> > Obvious workaround would be to disable `set -u` temporarily or assign
> > a temporary array value but that shouldn't need to be done.
>
> I'll consider it, but I'm not eager to carve out more exceptions for
> `set -u'.
>
Using ${x[@]@a} at first seems to be a work around:
$ (set -u; declare -A x; echo :${x[@]@a})
:A
But, as a separate issue, the @a transformation doesn't expand to anything
here (regardless of set -u):
$ (set -u; declare -A x=(); echo :${x[@]@a})
:
Maybe just adjusting the latter to also expand to the variable's attributes
would suffice.
>