On Mon, Oct 14, 2024 at 2:57 AM Chet Ramey wrote:
>
> I'll consider it, but I'm not eager to carve out more exceptions for
> `set -u'.
Checking for unbound_vars_is_error can be done earliest if you worry
about additional runtime weight. It makes the code for disabled `set
-u` instances optimal b
On Mon, Oct 21, 2024 at 11:08 AM Grisha Levit wrote:
>
> Maybe just adjusting the latter to also expand to the variable's attributes
> would suffice.
var[@] refers to all the elements and not the variable itself so I'll
find that painful to use. The solution to check want_attributes is
simpler.
On Sun, Oct 13, 2024, 14:58 Chet Ramey 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 b
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 o
Changing "c == '@'" to "c == '@' && !want_attributes" in line 10145 of
subst.c seems enough to fix it.
--
konsolebox
diff --git a/subst.c b/subst.c
index 251eafaf..9ee816e0 100644
--- a/subst.c
+++ b/subst.c
@@ -10142,7 +10142,7 @@ parameter_brace_expand (char *string, size_t *indexp, int quoted
# 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.
Same thing happens with `declare -A x=()`.
# bash --version
GNU bash, version 5.3.0(1)