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

(z) expansion flag do not always return an array



Hey!

The (z) expansion flag is documented to return an array, but this is not
the case if we have only one word:

 16:24 ❱ print -l ${${(z)${:-word1}}[1]}
w
 16:24 ❱ print -l ${${(z)${:-word1 word2}}[1]}
word1

This can be worked around with A:

 16:29 ❱ print -l ${${(Az)${:-word1}}[1]}
word1
 16:29 ❱ print -l ${${(Az)${:-word1 word2}}[1]}
word1

But older versions of Zsh does not have that. Is there another way? Is
there an easy way to know if something is an array or a string? I am
using subscripting for that but maybe there are better ways.

-- 
Don't over-comment.
            - The Elements of Programming Style (Kernighan & Plauger)




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