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

Re: (z) expansion flag do not always return an array



On Mon, Nov 29, 2021, at 10:31 AM, Vincent Bernat wrote:
> The (z) expansion flag is documented to return an array

Is it?  The 5.8 man page does not mention "array" even once.

    z   Split the result of the expansion into words using shell
        parsing to find the words, i.e. taking into account any
        quoting in the value.  Comments are not treated specially but
        as ordinary strings, similar to interactive shells with the
        INTERACTIVE_COMMENTS option unset (however, see the Z flag
        below for related options)

        Note that this is done very late, even later than the `(s)'
        flag.  So to access single words in the result use nested
        expansions as in `${${(z)foo}[2]}'.  Likewise, to remove the
        quotes in the resulting words use `${(Q)${(z)foo}}'.

-- 
vq




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