OILS / spec / smoke.test.sh View on Github | oilshell.org

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