OILS / spec / ysh-expr-sub.test.sh View on Github | oilshell.org

42 lines, 23 significant
1## our_shell: ysh
2
3# Test YSH expressions within $[]
4
5#### $[f(x)]
6var a = %(a b c)
7echo $[len(a)]
8## STDOUT:
93
10## END
11
12#### $[d['key']]
13var d = {}
14setvar d['key'] = 42
15echo $[d['key']]
16## STDOUT:
1742
18## END
19
20#### $[d.key]
21var d = {}
22setvar d['key'] = 42
23echo $[d.key]
24## STDOUT:
2542
26## END
27
28#### In Double quotes
29var a = %(a b c)
30var obj = /d+/
31var d = {}
32setvar d['key'] = 42
33echo "func $[len(a)]"
34echo "key $[d['key']]"
35echo "key $[d.key]"
36echo "dq $[d["key"]]"
37## STDOUT:
38func 3
39key 42
40key 42
41dq 42
42## END