On Sun, Oct 13, 2024, 14:58 Chet Ramey <chet.ra...@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.

>

Reply via email to