Re: Strange bug with or without quotes

Mikael Magnusson <[email protected]> Sun, 5 Apr 2026 13:36:29 +0200
Newsgroups gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user
Message-ID <CAHYJk3RVPRCnKQJoqEPPvBxGu9rzJGTR3APXVMihiQOEGYmVEA@mail.gmail.com>
On Sun, Apr 5, 2026 at 1:18 PM Klaus Ethgen <[email protected]> wrote:
>
> Hi,
>
> actually I stumbled across the following bug:
>
> Assume:
> local -a pcomps=('bzip2' 'lzip')
>
> Now try to keep matching parts:
> echo "${(M)pcomps:#bzip2}" # -> ""
> echo ${(M)pcomps:#bzip2}   # -> "bzip2"
>
> For my understanding, there should be no differences between the quoted
> and the unquoted version.
>
> As I had exactly that in some checks, they was always false:
> if [[ -z "${(M)pcomps:#$i}" ]]
>
> By the way, I use zsh 5.9.
>
> Any thoughts about that?

an array in double quoted context will be joined by spaces, the
following will do what you want:
% echo "${(M@)pcomps:#bzip2}"
bzip2