1 |
#
|
2 |
# Some shell errors are unrecoverable! Like divide by zero (except in bash.
|
3 |
#
|
4 |
# Any others?
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
$SH -c '
|
10 |
echo hi > file$(( 42 / 0 )) in
|
11 |
echo inside=$?
|
12 |
'
|
13 |
echo outside=$?
|
14 |
|
15 |
## STDOUT:
|
16 |
outside=1
|
17 |
## END
|
18 |
|
19 |
## OK dash/ash STDOUT:
|
20 |
outside=2
|
21 |
## END
|
22 |
|
23 |
# bash makes the command fail
|
24 |
## OK bash STDOUT:
|
25 |
inside=1
|
26 |
outside=0
|
27 |
## END:
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
$SH -c '
|
33 |
if test foo$(( 42 / 0 )) = foo; then
|
34 |
echo true
|
35 |
else
|
36 |
echo false
|
37 |
fi
|
38 |
echo inside=$?
|
39 |
'
|
40 |
echo outside=$?
|
41 |
|
42 |
echo ---
|
43 |
|
44 |
$SH -c '
|
45 |
if test foo$(( 42 / 0 )) = foo; then
|
46 |
echo true
|
47 |
fi
|
48 |
echo inside=$?
|
49 |
'
|
50 |
echo outside=$?
|
51 |
|
52 |
## STDOUT:
|
53 |
outside=1
|
54 |
---
|
55 |
outside=1
|
56 |
## END
|
57 |
|
58 |
## OK dash/ash STDOUT:
|
59 |
outside=2
|
60 |
---
|
61 |
outside=2
|
62 |
## END
|
63 |
|
64 |
# bash makes the command fail
|
65 |
## OK bash STDOUT:
|
66 |
inside=1
|
67 |
outside=0
|
68 |
---
|
69 |
inside=1
|
70 |
outside=0
|
71 |
## END:
|
72 |
|
73 |
# weird difference in zsh!
|
74 |
|
75 |
## BUG zsh STDOUT:
|
76 |
outside=1
|
77 |
---
|
78 |
outside=0
|
79 |
## END
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
$SH -c '
|
85 |
case $(( 42 / 0 )) in
|
86 |
(*) echo hi ;;
|
87 |
esac
|
88 |
echo inside=$?
|
89 |
'
|
90 |
echo outside=$?
|
91 |
|
92 |
echo ---
|
93 |
|
94 |
$SH -c '
|
95 |
case foo in
|
96 |
( $(( 42 / 0 )) )
|
97 |
echo hi
|
98 |
;;
|
99 |
esac
|
100 |
echo inside=$?
|
101 |
'
|
102 |
echo outside=$?
|
103 |
|
104 |
## STDOUT:
|
105 |
outside=1
|
106 |
---
|
107 |
outside=1
|
108 |
## END
|
109 |
|
110 |
## OK dash/ash STDOUT:
|
111 |
outside=2
|
112 |
---
|
113 |
outside=2
|
114 |
## END
|
115 |
|
116 |
## OK bash STDOUT:
|
117 |
inside=1
|
118 |
outside=0
|
119 |
---
|
120 |
inside=1
|
121 |
outside=0
|
122 |
## END:
|
123 |
|
124 |
## BUG zsh STDOUT:
|
125 |
outside=0
|
126 |
---
|
127 |
outside=0
|
128 |
## END
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
$SH -c '
|
134 |
echo ${undef?message}
|
135 |
echo inside=$?
|
136 |
'
|
137 |
echo outside=$?
|
138 |
|
139 |
$SH -c '
|
140 |
case ${undef?message} in
|
141 |
(*) echo hi ;;
|
142 |
esac
|
143 |
echo inside=$?
|
144 |
'
|
145 |
echo outside=$?
|
146 |
|
147 |
## STDOUT:
|
148 |
outside=1
|
149 |
outside=1
|
150 |
## END
|
151 |
## OK dash STDOUT:
|
152 |
outside=2
|
153 |
outside=2
|
154 |
## END
|
155 |
## OK bash STDOUT:
|
156 |
outside=127
|
157 |
outside=127
|
158 |
## END
|
159 |
|
160 |
|
161 |
|
162 |
$SH -c '
|
163 |
set -o nounset
|
164 |
case ${undef} in
|
165 |
(*) echo hi ;;
|
166 |
esac
|
167 |
echo inside=$?
|
168 |
'
|
169 |
echo outside=$?
|
170 |
|
171 |
## STDOUT:
|
172 |
outside=1
|
173 |
## END
|
174 |
|
175 |
## OK dash STDOUT:
|
176 |
outside=2
|
177 |
## END
|
178 |
|
179 |
## OK bash STDOUT:
|
180 |
outside=127
|
181 |
## END
|
182 |
|
183 |
## BUG zsh STDOUT:
|
184 |
outside=0
|
185 |
## END
|
186 |
|