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