${(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.

Examples

Split string using shell parsing
1
2
3
string="a value with 'single-quoted text' and \"double-quoted\" text\ content"
# split using shell parsing, then join with newline
echo ${(j:\n:)${(z)string}}
Output:
1
2
3
4
5
6
7
a
value
with
'single-quoted text'
and
"double-quoted"
text\ content
BashSupport Pro ist eine Zsh IDE mit Unterstützung für ${(z)…} - probieren Sie es jetzt aus!
© 2020–2024 Joachim Ansorg
Impressum
Datenschutz
Rechtliches