1 |
# |
2 |
# For testing the Python sketch |
3 |
|
4 |
#### builtin |
5 |
echo hi |
6 |
## stdout: hi |
7 |
|
8 |
#### command sub |
9 |
echo $(expr 3) |
10 |
## stdout: 3 |
11 |
|
12 |
#### command sub with builtin |
13 |
echo $(echo hi) |
14 |
## stdout: hi |
15 |
|
16 |
#### pipeline |
17 |
hostname | wc -l |
18 |
## stdout: 1 |
19 |
|
20 |
#### pipeline with builtin |
21 |
echo hi | wc -l |
22 |
## stdout: 1 |
23 |
|
24 |
#### and-or chains |
25 |
echo 1 && echo 2 || echo 3 && echo 4 |
26 |
echo -- |
27 |
false || echo A |
28 |
false || false || echo B |
29 |
false || false || echo C && echo D || echo E |
30 |
## STDOUT: |
31 |
1 |
32 |
2 |
33 |
4 |
34 |
-- |
35 |
A |
36 |
B |
37 |
C |
38 |
D |
39 |
## END |
40 |
|
41 |
#### here doc with var |
42 |
v=one |
43 |
tac <<EOF |
44 |
$v |
45 |
"two |
46 |
EOF |
47 |
## stdout-json: "\"two\none\n" |
48 |
|
49 |
#### here doc without var |
50 |
tac <<"EOF" |
51 |
$v |
52 |
"two |
53 |
EOF |
54 |
## stdout-json: "\"two\n$v\n" |
55 |
|
56 |
#### here doc with builtin |
57 |
read var <<EOF |
58 |
value |
59 |
EOF |
60 |
echo "var = $var" |
61 |
## stdout: var = value |
62 |
|
63 |
#### Redirect external command |
64 |
expr 3 > $TMP/expr3.txt |
65 |
cat $TMP/expr3.txt |
66 |
## stdout: 3 |
67 |
## stderr-json: "" |
68 |
|
69 |
#### Redirect with builtin |
70 |
echo hi > _tmp/hi.txt |
71 |
cat _tmp/hi.txt |
72 |
## stdout: hi |
73 |
|
74 |
#### Here doc with redirect |
75 |
cat <<EOF >_tmp/smoke1.txt |
76 |
one |
77 |
two |
78 |
EOF |
79 |
wc -c _tmp/smoke1.txt |
80 |
## stdout: 8 _tmp/smoke1.txt |
81 |
|
82 |
#### "$@" "$*" |
83 |
fun () { |
84 |
argv.py "$@" "$*" |
85 |
} |
86 |
fun "a b" "c d" |
87 |
## stdout: ['a b', 'c d', 'a b c d'] |
88 |
|
89 |
#### $@ $* |
90 |
fun() { |
91 |
argv.py $@ $* |
92 |
} |
93 |
fun "a b" "c d" |
94 |
## stdout: ['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd'] |
95 |
|
96 |
#### failed command |
97 |
ls /nonexistent-zzZZ |
98 |
## status: 2 |
99 |
|
100 |
#### subshell |
101 |
(echo 1; echo 2) |
102 |
## status: 0 |
103 |
## STDOUT: |
104 |
1 |
105 |
2 |
106 |
## END |
107 |
|
108 |
#### for loop |
109 |
for i in a b c |
110 |
do |
111 |
echo $i |
112 |
done |
113 |
## status: 0 |
114 |
## STDOUT: |
115 |
a |
116 |
b |
117 |
c |
118 |
## END |
119 |
|
120 |
#### vars |
121 |
a=5 |
122 |
echo $a ${a} "$a ${a}" |
123 |
## stdout: 5 5 5 5 |