Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Strange bug with or without quotes



On Sun, Apr 5, 2026 at 1:18 PM Klaus Ethgen <Klaus@xxxxxxxxx> 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




Messages sorted by: Reverse Date, Date, Thread, Author