On Sun, May 24, 2026 at 12:47:12PM +0200, Emanuele Torre wrote:
> On Sun, May 24, 2026 at 11:31:51AM +0200, Emanuele Torre wrote:
> > The current order of these cases does not seem logical to me; it is
> > probably incorrect: I would expect the PF_ASSIGNRHS case not to care
> > about whether the expansion is quoted, and thus also to take precedence
> > over the case for double quoted expansions outside of assignments.
> >
> > Unless I am missing something, reordering those two cases seems to fix
> > the regression; so, the fix probably looks similar to something like
> > this:
>
> I will point out that this patch also changes the behaviour of [@]@k
> in assignments, and maybe also that of some other @OP expansions, to
> one which I would think is more correct:
>
> bash-5.3.9
> $ IFS=+ a=(a b) b=${a[*]@k}; declare -p b
> declare -- b="0+a+1+b"
> $ IFS=+ a=(a b) b=${a[@]@k}; declare -p b
> declare -- b="0+a+1+b"
> $ IFS= a=(a b) b=${a[*]@k}; declare -p b
> declare -- b="0a1b"
> $ IFS= a=(a b) b=${a[@]@k}; declare -p b
> declare -- b="0 a 1 b"
>
> devel (2d4ba0c618584d3554165b9484d921ec8c4e4523) with the patch applied
> $ IFS=+ a=(a b) b=${a[*]@k}; declare -p b
> declare -- b="0+a+1+b"
> $ IFS=+ a=(a b) b=${a[@]@k}; declare -p b
> declare -- b="0 a 1 b"
> $ IFS= a=(a b) b=${a[*]@k}; declare -p b
> declare -- b="0a1b"
> $ IFS= a=(a b) b=${a[@]@k}; declare -p b
> declare -- b="0 a 1 b"
>
> That is, [@] → " " and [*] → IFS as opposed to the current IFS for
> both unless IFS='', in which case [@] → " ", [*] → "".
>
> o/
> emanuele6
Sorry; this was inaccurate. It seems that devel's behaviour was already
different from bash-5.3.9's before my patch with regards to b=${a[@]@k}.
However, my patch does change the behaviour of b="${a[@]@k}" which had
the same issue as b="${!a[@]}"
bash-5.3.9
$ IFS=+ a=(a b) b=${a[@]@k} c="${a[@]@k}"; declare -p b c
declare -- b="0+a+1+b"
declare -- c="0+a+1+b"
devel (2d4ba0c618584d3554165b9484d921ec8c4e4523)
$ IFS=+ a=(a b) b=${a[@]@k} c="${a[@]@k}"; declare -p b c
declare -- b="0 a 1 b"
declare -- c="0+a+1+b"
devel (2d4ba0c618584d3554165b9484d921ec8c4e4523) with my patch applied
$ IFS=+ a=(a b) b=${a[@]@k} c="${a[@]@k}"; declare -p b c
declare -- b="0 a 1 b"
declare -- c="0 a 1 b"
o/
emanuele6