${(p)…}: Enable escape sequences in flags

(p) enables escape sequences and variable substitution for options of the following flags.

By default, options are taken literally, for example ${(s:\t:)name} splits words at a literal \t.

With (p), ${(ps:\t:)name} is splitting words at a TAB character and ${(ps:$sep:)name} splits using the value of variable sep.

Examples

Split string at TABs
1
2
tsv=$'a\tb\tc'
echo ${(ps:\t:)tsv}
Output:
1
a b c
BashSupport Pro is a Zsh IDE with support for ${(p)…}try it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal