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 |
|
19 | argv() {
|
20 | python -c 'import sys;print(sys.argv[1:])' @ARGV
|
21 | }
|
22 |
|
23 | show() {
|
24 | echo '====='
|
25 | argv @ARGV
|
26 | echo
|
27 | }
|
28 |
|
29 |
|
30 | var strarray = %(
|
31 | bare words *.sh {a,b}@example.com 'sq' "dq ${x:-default}"
|
32 | )
|
33 |
|
34 | show @strarray
|
35 |
|
36 | var cmd_sub = $(
|
37 | echo bare words *.sh {a,b}@example.com 'sq' "dq ${x:-default}"
|
38 | )
|
39 |
|
40 | show $cmd_sub
|
41 |
|
42 | show $['quoted ' ++ 'words ' ++ "dq ${x:-default}"]
|
43 |
|