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

Re: Odd behavior of quoted Zsh array subtraction



On 7/23/21, Zach Riggle <zachriggle@xxxxxxxxx> wrote:
> I'm sure there's a section of the manual that explains this.
>
> I'm also sure I don't know what section it is.

If you search for "brain damage" in the zshall manpage, you will find
it. You are in particular interested in the ordering relation between
item 5 and item 7.

>     $ a=( aa bb cc dd ee  )
>
>     $ b=( cc )
>
>     $ echo ${a:|b}
>     aa bb dd ee
>
>     $ echo "${a:|b}"
>     aa bb cc dd ee # <-- WHAT
>
>     $ echo "${(@)a:|b}"
>     aa bb dd ee
>
>     $ echo "${a[@]:|b}"
>     aa bb dd ee
>
> All results except the first quoted expression is the expected result.
>
> Why does the marked, quoted array-subtraction result in a different
> set of values?  I would expect that array operators have precedence
> over array-converted-to-scalar.  Maybe this is an "outward-in"
> expansion issue?

Your expectation is simply not matching what the code does, if the
current level is double quoted then words will be joined before
history modifiers are applied.

-- 
Mikael Magnusson




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