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