OILS / ysh / testdata / sigil-pairs.sh View on Github | oilshell.org

43 lines, 17 significant
1# Demonstrate Oil sigil pairs.
2#
3# Usage:
4# bin/oil oil_lang/testdata/sigil-pairs.sh
5#
6# Summary:
7# $() command sub
8# %() string array
9# $[] expr sub
10#
11# Also used:
12# ${} for ${x %.3f} and ${x|html}
13#
14# Later:
15# @{} table literals
16
17# Helpers
18
19argv() {
20 python -c 'import sys;print(sys.argv[1:])' @ARGV
21}
22
23show() {
24 echo '====='
25 argv @ARGV
26 echo
27}
28
29
30var strarray = %(
31 bare words *.sh {a,b}@example.com 'sq' "dq ${x:-default}"
32)
33
34show @strarray
35
36var cmd_sub = $(
37 echo bare words *.sh {a,b}@example.com 'sq' "dq ${x:-default}"
38)
39
40show $cmd_sub
41
42show $['quoted ' ++ 'words ' ++ "dq ${x:-default}"]
43