Permalink
Browse files

Add a spec test for syntax error in eval.

Both eval and source now return 2 on a parse error.  These errors can be
made fatal with 'set -o errexit'.
  • Loading branch information...
Andy Chu
Andy Chu committed Sep 1, 2018
1 parent 517ec2b commit e0cdb4af173996560642c78fe44cbe9a34b288b6
Showing with 13 additions and 0 deletions.
  1. +13 −0 spec/builtin-eval-source.test.sh
@@ -60,6 +60,9 @@ foo=
#### Source with syntax error
# TODO: We should probably use dash behavior of a fatal error.
# Although set-o errexit handles this. We don't want to break the invariant
# that a builtin like 'source' behaves like an external program. An external
# program can't halt the shell!
echo 'echo >' > $TMP/syntax-error.sh
. $TMP/syntax-error.sh
echo status=$?
@@ -68,3 +71,13 @@ echo status=$?
## OK zsh stdout: status=126
## OK dash stdout-json: ""
## OK dash status: 2
#### Eval with syntax error
eval 'echo >'
echo status=$?
## stdout: status=2
## OK bash/zsh stdout: status=1
## OK dash stdout-json: ""
## OK dash status: 2
## OK mksh stdout-json: ""
## OK mksh status: 1

0 comments on commit e0cdb4a

Please sign in to comment.