${(z)…}: Splitting with shell parsing
z splits the expansion into words using shell parsing, i.e. as if the expansion was entered as a command.
The splitting is performed after other flags are applied. Use nesting to work with the resulting words of (z).
# comment words are treated as ordinary strings and not as comments.
Option (Z:opts:) allows to configure this.
Links
Examples
- Split string using shell parsing
- Output:
1 2 3string="a value with 'single-quoted text' and \"double-quoted\" text\ content" # split using shell parsing, then join with newline echo ${(j:\n:)${(z)string}}1 2 3 4 5 6 7a value with 'single-quoted text' and "double-quoted" text\ content
BashSupport Pro is a Zsh IDE with support for ${(z)…} – try it now!