-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[oil-language] Expression errors produce error status 3 in a command.
So then errexit can take over. This fixes uncaught IndexError, KeyError, ZeroDivisionError, etc. We still don't have a good story for TypeError. There is a one-off around one EvalExpr. Addresses #942.
- Loading branch information
Andy C
committed
Apr 30, 2022
1 parent
a6e6d23
commit 10fefce
Showing
11 changed files
with
329 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
# | ||
# Some shell errors are unrecoverable! Like divide by zero (except in bash. | ||
# | ||
# Any others? | ||
|
||
|
||
#### Unrecoverable: divide by zero in redirect word | ||
|
||
$SH -c ' | ||
echo hi > file$(( 42 / 0 )) in | ||
echo inside=$? | ||
' | ||
echo outside=$? | ||
|
||
## STDOUT: | ||
outside=1 | ||
## END | ||
|
||
## OK dash/ash STDOUT: | ||
outside=2 | ||
## END | ||
|
||
# bash makes the command fail | ||
## OK bash STDOUT: | ||
inside=1 | ||
outside=0 | ||
## END: | ||
|
||
|
||
#### Unrecoverable: divide by zero in conditional word | ||
|
||
$SH -c ' | ||
if test foo$(( 42 / 0 )) = foo; then | ||
echo true | ||
else | ||
echo false | ||
fi | ||
echo inside=$? | ||
' | ||
echo outside=$? | ||
|
||
echo --- | ||
|
||
$SH -c ' | ||
if test foo$(( 42 / 0 )) = foo; then | ||
echo true | ||
fi | ||
echo inside=$? | ||
' | ||
echo outside=$? | ||
|
||
## STDOUT: | ||
outside=1 | ||
--- | ||
outside=1 | ||
## END | ||
|
||
## OK dash/ash STDOUT: | ||
outside=2 | ||
--- | ||
outside=2 | ||
## END | ||
|
||
# bash makes the command fail | ||
## OK bash STDOUT: | ||
inside=1 | ||
outside=0 | ||
--- | ||
inside=1 | ||
outside=0 | ||
## END: | ||
|
||
# weird difference in zsh! | ||
|
||
## BUG zsh STDOUT: | ||
outside=1 | ||
--- | ||
outside=0 | ||
## END | ||
|
||
|
||
#### Unrecoverable: divide by zero in case | ||
|
||
$SH -c ' | ||
case $(( 42 / 0 )) in | ||
(*) echo hi ;; | ||
esac | ||
echo inside=$? | ||
' | ||
echo outside=$? | ||
|
||
echo --- | ||
|
||
$SH -c ' | ||
case foo in | ||
( $(( 42 / 0 )) ) | ||
echo hi | ||
;; | ||
esac | ||
echo inside=$? | ||
' | ||
echo outside=$? | ||
|
||
## STDOUT: | ||
outside=1 | ||
--- | ||
outside=1 | ||
## END | ||
|
||
## OK dash/ash STDOUT: | ||
outside=2 | ||
--- | ||
outside=2 | ||
## END | ||
|
||
## OK bash STDOUT: | ||
inside=1 | ||
outside=0 | ||
--- | ||
inside=1 | ||
outside=0 | ||
## END: | ||
|
||
## BUG zsh STDOUT: | ||
outside=0 | ||
--- | ||
outside=0 | ||
## END | ||
|
||
|
||
#### Unrecoverable: ${undef?message} | ||
|
||
$SH -c ' | ||
echo ${undef?message} | ||
echo inside=$? | ||
' | ||
echo outside=$? | ||
|
||
$SH -c ' | ||
case ${undef?message} in | ||
(*) echo hi ;; | ||
esac | ||
echo inside=$? | ||
' | ||
echo outside=$? | ||
|
||
## STDOUT: | ||
outside=1 | ||
outside=1 | ||
## END | ||
## OK dash STDOUT: | ||
outside=2 | ||
outside=2 | ||
## END | ||
## OK bash STDOUT: | ||
outside=127 | ||
outside=127 | ||
## END | ||
|
||
#### ${undef} with nounset | ||
|
||
$SH -c ' | ||
set -o nounset | ||
case ${undef} in | ||
(*) echo hi ;; | ||
esac | ||
echo inside=$? | ||
' | ||
echo outside=$? | ||
|
||
## STDOUT: | ||
outside=1 | ||
## END | ||
|
||
## OK dash STDOUT: | ||
outside=2 | ||
## END | ||
|
||
## OK bash STDOUT: | ||
outside=127 | ||
## END | ||
|
||
## BUG zsh STDOUT: | ||
outside=0 | ||
## END | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ув