zsh-users
 help / color / mirror / code / Atom feed
* (z) expansion flag do not always return an array
@ 2021-11-29 15:31 Vincent Bernat
  2021-11-29 16:34 ` Roman Perepelitsa
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Vincent Bernat @ 2021-11-29 15:31 UTC (permalink / raw)
  To: zsh-users

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)


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-11-29 19:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 15:31 (z) expansion flag do not always return an array Vincent Bernat
2021-11-29 16:34 ` Roman Perepelitsa
2021-11-29 17:44   ` Vincent Bernat
2021-11-29 16:50 ` Lawrence Velázquez
2021-11-29 17:03   ` Peter Stephenson
2021-11-29 17:43   ` Vincent Bernat
2021-11-29 17:45   ` Bart Schaefer
2021-11-29 19:43 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).