${(Z:opts)…}: Splitting with shell parsing and opts
(Z:opts:) is like (z) but takes additional settings to configure the parsing process.
Without any options ((Z::)) works in exactly the same way as (z).
It’s possible specify more than option, e.g. ${(Z:Cn:)name}.
It 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:opts:).
Options
c- Causes comments to be parsed and retained
C- Causes comments to be parsed and removed
n- Causes unquoted newlines to be treated as ordinary whitespace and not as command separators
Links
Examples
- Split string using shell parsing and drop comments
- Output:
1 2 3 4 5string="# simple embedded shell script echo -n hello echo world" # split using shell parsing and drop the comment line echo ${(Z:C:)string}1; echo -n hello ; echo world
BashSupport Pro 是一款支持 Z** 的 **Zsh 集成开发环境 - 立即试用!