1 |
## our_shell: ysh
|
2 |
## oils_failures_allowed: 0
|
3 |
|
4 |
|
5 |
var x = :| 1 2 3 |
|
6 |
write len=$[len(x)]
|
7 |
## STDOUT:
|
8 |
len=3
|
9 |
## END
|
10 |
|
11 |
|
12 |
shopt -s ysh:all
|
13 |
|
14 |
var x = 1
|
15 |
var a = :| $x $(write hi) 'sq' "dq $x" |
|
16 |
write len=$[len(a)]
|
17 |
write @a
|
18 |
## STDOUT:
|
19 |
len=4
|
20 |
1
|
21 |
hi
|
22 |
sq
|
23 |
dq 1
|
24 |
## END
|
25 |
|
26 |
|
27 |
|
28 |
var b = :|true| # this is a string
|
29 |
pp test_ (b)
|
30 |
|
31 |
# = b
|
32 |
|
33 |
var empty = :||
|
34 |
pp test_ (empty)
|
35 |
|
36 |
# = empty
|
37 |
|
38 |
## STDOUT:
|
39 |
(List) ["true"]
|
40 |
(List) []
|
41 |
## END
|
42 |
|
43 |
|
44 |
|
45 |
shopt -s parse_at
|
46 |
|
47 |
var x = :| 'a b' c |
|
48 |
|
49 |
declare -a array=( @x )
|
50 |
|
51 |
argv.py "${array[@]}" # should work
|
52 |
|
53 |
echo -$array- # fails because of strict_arraywith type error
|
54 |
|
55 |
echo -$x- # fails with type error
|
56 |
|
57 |
## status: 1
|
58 |
## STDOUT:
|
59 |
['a b', 'c']
|
60 |
## END
|
61 |
|
62 |
|
63 |
var l = list(1..3)
|
64 |
echo $[len(l)]
|
65 |
call l->extend(list(3..6))
|
66 |
echo $[len(l)]
|
67 |
## STDOUT:
|
68 |
2
|
69 |
5
|
70 |
## END
|
71 |
|
72 |
|
73 |
shopt -s ysh:all
|
74 |
var l = list(1..3)
|
75 |
|
76 |
var result = l->extend(list(3..6))
|
77 |
assert [null === result]
|
78 |
|
79 |
setvar result = l->append(6)
|
80 |
assert [null === result]
|
81 |
|
82 |
echo pass
|
83 |
## STDOUT:
|
84 |
pass
|
85 |
## END
|
86 |
|
87 |
|
88 |
shopt -s ysh:all
|
89 |
var l = list(1..5)
|
90 |
assert [4 === l->pop()]
|
91 |
assert [3 === l->pop()]
|
92 |
assert [2 === l->pop()]
|
93 |
assert [1 === l->pop()]
|
94 |
echo pass
|
95 |
## STDOUT:
|
96 |
pass
|
97 |
## END
|