Re: Strange bug with or without quotes
Philippe Altherr <[email protected]> Sun, 5 Apr 2026 13:00:06 +0100
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAGdYchs3uPkqkP=S-iOUqSxAdQCewKN9ajMLeXppOu1DEuHVKg@mail.gmail.com> |
When you use quotes around an array parameter, joining happens first, so before the :# operation (or any other expansion operation). The (@) forces the :# operation to work on the array elements and only then join the result. Philippe On Sun, Apr 5, 2026 at 1:51 PM Klaus Ethgen <[email protected]> wrote: > Hi, > > Am So den 5. Apr 2026 um 12:36 schrieb Mikael Magnusson: > > > Assume: > > > local -a pcomps=('bzip2' 'lzip') > > > > > > Now try to keep matching parts: > > > echo "${(M)pcomps:#bzip2}" # -> "" > > > echo ${(M)pcomps:#bzip2} # -> "bzip2" > > > > an array in double quoted context will be joined by spaces, the > > following will do what you want: > > % echo "${(M@)pcomps:#bzip2}" > > bzip2 > > Well, I expected that and it should not matter in that situation as the > value "bzip2" is the only remaining value in the array so when joined > should be still _not_ "" (empty) > > Regards > Klaus > -- > Klaus Ethgen http://www.ethgen.ch/ > pub 4096R/4E20AF1C 2011-05-16 Klaus Ethgen <[email protected]> > Fingerprint: 85D4 CA42 952C 949B 1753 62B3 79D0 B06F 4E20 AF1C >