1 |
|
2 |
#### echo keyword |
3 |
echo done |
4 |
## stdout: done |
5 |
|
6 |
#### if/else |
7 |
if false; then |
8 |
echo THEN |
9 |
else |
10 |
echo ELSE |
11 |
fi |
12 |
## stdout: ELSE |
13 |
|
14 |
#### Turn an array into an integer. |
15 |
a=(1 2 3) |
16 |
(( a = 42 )) |
17 |
echo $a |
18 |
## stdout: 42 |
19 |
## N-I dash/ash stdout-json: "" |
20 |
## N-I dash/ash status: 2 |
21 |
|
22 |
|
23 |
#### assign readonly -- one line |
24 |
readonly x=1; x=2; echo hi |
25 |
## status: 1 |
26 |
## OK dash/mksh/ash status: 2 |
27 |
## STDOUT: |
28 |
## END |
29 |
|
30 |
#### assign readonly -- multiple lines |
31 |
readonly x=1 |
32 |
x=2 |
33 |
echo hi |
34 |
## status: 1 |
35 |
## OK dash/mksh/ash status: 2 |
36 |
## STDOUT: |
37 |
## END |
38 |
## BUG bash status: 0 |
39 |
## BUG bash STDOUT: |
40 |
hi |
41 |
## END |
42 |
|
43 |
#### assign readonly -- multiple lines -- set -o posix |
44 |
set -o posix |
45 |
readonly x=1 |
46 |
x=2 |
47 |
echo hi |
48 |
## status: 1 |
49 |
## OK dash/mksh/ash status: 2 |
50 |
## STDOUT: |
51 |
## END |
52 |
|
53 |
#### unset readonly -- one line |
54 |
readonly x=1; unset x; echo hi |
55 |
## STDOUT: |
56 |
hi |
57 |
## END |
58 |
## OK dash/ash status: 2 |
59 |
## OK zsh status: 1 |
60 |
## OK dash/ash stdout-json: "" |
61 |
## OK zsh stdout-json: "" |
62 |
|
63 |
#### unset readonly -- multiple lines |
64 |
readonly x=1 |
65 |
unset x |
66 |
echo hi |
67 |
## OK dash/ash status: 2 |
68 |
## OK zsh status: 1 |
69 |
## OK dash/ash stdout-json: "" |
70 |
## OK zsh stdout-json: "" |
71 |
|
72 |
#### First word like foo$x() and foo$[1+2] (regression) |
73 |
|
74 |
# Problem: $x() func call broke this error message |
75 |
foo$identity('z') |
76 |
|
77 |
foo$[1+2] |
78 |
|
79 |
echo DONE |
80 |
|
81 |
## status: 2 |
82 |
## OK mksh/zsh status: 1 |
83 |
## STDOUT: |
84 |
## END |
85 |
## OK osh status: 0 |
86 |
## OK osh STDOUT: |
87 |
DONE |
88 |
## END |
89 |
|
90 |
#### Function names |
91 |
foo$x() { |
92 |
echo hi |
93 |
} |
94 |
|
95 |
foo $x() { |
96 |
echo hi |
97 |
} |
98 |
|
99 |
## status: 2 |
100 |
## OK mksh/zsh/osh status: 1 |
101 |
## BUG zsh status: 0 |
102 |
## STDOUT: |
103 |
## END |
104 |
|
105 |
|
106 |
#### file with NUL byte |
107 |
echo -e 'echo one \0 echo two' > tmp.sh |
108 |
$SH tmp.sh |
109 |
## STDOUT: |
110 |
one echo two |
111 |
## END |
112 |
## OK osh STDOUT: |
113 |
one |
114 |
## END |
115 |
## N-I dash stdout-json: "" |
116 |
## N-I dash status: 127 |
117 |
## OK bash stdout-json: "" |
118 |
## OK bash status: 126 |
119 |
## OK zsh stdout-json: "one \u0000echo two\n" |
120 |
|
121 |
#### fastlex: PS1 format string that's incomplete / with NUL byte |
122 |
case $SH in bash) exit ;; esac |
123 |
|
124 |
x=$'\\D{%H:%M' # leave off trailing } |
125 |
echo x=${x@P} |
126 |
|
127 |
## STDOUT: |
128 |
x=\D{%H:%M |
129 |
## END |
130 |
|
131 |
## bash just ignores the missing } |
132 |
## BUG bash stdout-json: "" |
133 |
|
134 |
# These shells don't understand @P |
135 |
|
136 |
## N-I dash/ash stdout-json: "" |
137 |
## N-I dash/ash status: 2 |
138 |
|
139 |
## N-I zsh stdout-json: "" |
140 |
## N-I zsh status: 1 |
141 |
|
142 |
|
143 |
#### 'echo' and printf to disk full |
144 |
|
145 |
# Inspired by https://blog.sunfishcode.online/bugs-in-hello-world/ |
146 |
|
147 |
echo hi > /dev/full |
148 |
echo status=$? |
149 |
printf '%s\n' hi > /dev/full |
150 |
echo status=$? |
151 |
|
152 |
## STDOUT: |
153 |
status=1 |
154 |
status=1 |
155 |
## END |