1 |
|
2 |
|
3 |
# I suppose the logic is that string and array concat is ++
|
4 |
#
|
5 |
# I wonder if a ++= operator makes sense?
|
6 |
|
7 |
shopt -s parse_at simple_word_eval
|
8 |
var x = :| a 'b c' |
|
9 |
argv.py @x
|
10 |
|
11 |
setvar x += :| d e | # fatal error
|
12 |
argv.py @x
|
13 |
## status: 3
|
14 |
## STDOUT:
|
15 |
['a', 'b c']
|
16 |
## END
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
var x = '42'
|
22 |
setvar x += $(echo 3)
|
23 |
echo x=$x
|
24 |
|
25 |
setvar x += $(echo 3; false)
|
26 |
echo x=$x
|
27 |
|
28 |
## status: 1
|
29 |
## STDOUT:
|
30 |
x=45
|
31 |
## END
|
32 |
|
33 |
|
34 |
|
35 |
var x = 1 + 2 * 3
|
36 |
echo x=$x
|
37 |
|
38 |
setvar x += 4 * 1
|
39 |
echo x=$x
|
40 |
## STDOUT:
|
41 |
x=7
|
42 |
x=11
|
43 |
## END
|
44 |
|
45 |
|
46 |
|
47 |
var x = '42'
|
48 |
pp line (x)
|
49 |
|
50 |
setvar x += 4 * 1
|
51 |
pp line (x)
|
52 |
|
53 |
setvar x += '9'
|
54 |
pp line (x)
|
55 |
|
56 |
setvar x = '42'
|
57 |
setvar x /= 4
|
58 |
pp line (x)
|
59 |
|
60 |
## STDOUT:
|
61 |
(Str) "42"
|
62 |
(Int) 46
|
63 |
(Int) 55
|
64 |
(Float) 10.5
|
65 |
## END
|
66 |
|
67 |
|
68 |
|
69 |
var x = 42
|
70 |
|
71 |
setvar x += 1.5
|
72 |
echo $x
|
73 |
|
74 |
setvar x += '1.5'
|
75 |
echo $x
|
76 |
|
77 |
setvar x += '3'
|
78 |
echo $x
|
79 |
## STDOUT:
|
80 |
43.5
|
81 |
45.0
|
82 |
48.0
|
83 |
## END
|
84 |
|
85 |
|
86 |
|
87 |
var x = 0
|
88 |
|
89 |
setvar x = 10
|
90 |
setvar x -= 3
|
91 |
echo x=$x
|
92 |
|
93 |
setvar x = 10
|
94 |
setvar x *= 3
|
95 |
echo x=$x
|
96 |
|
97 |
var x = 0
|
98 |
setvar x = 10
|
99 |
setvar x /= 2
|
100 |
echo x=$x
|
101 |
|
102 |
## STDOUT:
|
103 |
x=7
|
104 |
x=30
|
105 |
x=5.0
|
106 |
## END
|
107 |
|
108 |
|
109 |
|
110 |
var x = 0
|
111 |
|
112 |
setvar x = 10
|
113 |
setvar x //= 3
|
114 |
echo x=$x
|
115 |
|
116 |
setvar x = 10
|
117 |
setvar x %= 3
|
118 |
echo x=$x
|
119 |
|
120 |
setvar x = 10
|
121 |
setvar x **= 3
|
122 |
echo x=$x
|
123 |
|
124 |
echo
|
125 |
echo bitwise
|
126 |
|
127 |
setvar x = 0b1111
|
128 |
setvar x &= 0b0101
|
129 |
echo x=$x
|
130 |
|
131 |
setvar x = 0b1000
|
132 |
setvar x |= 0b0111
|
133 |
echo x=$x
|
134 |
|
135 |
setvar x = 0b1010
|
136 |
setvar x ^= 0b1001
|
137 |
echo x=$x
|
138 |
|
139 |
echo
|
140 |
echo shift
|
141 |
|
142 |
setvar x = 0b1000
|
143 |
setvar x <<= 1
|
144 |
echo x=$x
|
145 |
|
146 |
setvar x = 0b1000
|
147 |
setvar x >>= 1
|
148 |
echo x=$x
|
149 |
|
150 |
## STDOUT:
|
151 |
x=3
|
152 |
x=1
|
153 |
x=1000
|
154 |
|
155 |
bitwise
|
156 |
x=5
|
157 |
x=15
|
158 |
x=3
|
159 |
|
160 |
shift
|
161 |
x=16
|
162 |
x=4
|
163 |
## END
|
164 |
|
165 |
|
166 |
|
167 |
var d = {x: 42}
|
168 |
|
169 |
setvar d['x'] += 1.5
|
170 |
echo $[d.x]
|
171 |
|
172 |
setvar d.x += '1.5'
|
173 |
echo $[d.x]
|
174 |
|
175 |
setvar d.x += '3'
|
176 |
echo $[d.x]
|
177 |
|
178 |
## STDOUT:
|
179 |
43.5
|
180 |
45.0
|
181 |
48.0
|
182 |
## END
|
183 |
|
184 |
|
185 |
|
186 |
shopt -s parse_at
|
187 |
|
188 |
var mylist = :| 32 42 |
|
189 |
|
190 |
setvar mylist[0] -= 1
|
191 |
echo @mylist
|
192 |
|
193 |
setvar mylist[1] //= 2
|
194 |
echo @mylist
|
195 |
|
196 |
setvar mylist[1] /= 2
|
197 |
echo @mylist
|
198 |
|
199 |
|
200 |
## STDOUT:
|
201 |
31 42
|
202 |
31 21
|
203 |
31 10.5
|
204 |
## END
|
205 |
|
206 |
|
207 |
|
208 |
var x = 3
|
209 |
var y = 4
|
210 |
setvar x, y += 2
|
211 |
echo $x $y
|
212 |
|
213 |
## status: 2
|
214 |
## STDOUT:
|
215 |
## END
|
216 |
|
217 |
|