${(g:opts:)…}: Process escape sequences

Without options, ${(g::)name}, processes escapes like the echo builtin.

Options o, c, and e enable processing of different forms of escape sequences.

Options

o
Octal escapes don’t take a leading zero
c
Sequences like ^X are also processed
e
Sequences like \M-t are also processed

Examples

Evaluate escape sequences
1
2
3
4
# \n and ^J and octal \12 are all "newline"
# \t and ^I are both "tab"
value='Name\tAge\n----\t---\12Adam^I42^JEve^I42'
echo "${(g:oc:)value}"
Output:
1
2
3
4
Name    Age
----    ---
Adam    42
Eve     42
BashSupport Pro is a Zsh IDE with support for ${(g)…}try it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal