X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tests%2Fset-e-test;h=1fdf360d982f655a80136d4a68de33e611562add;hb=3185942a5234e26ab13fa02f9c51d340cec514f8;hp=ce3feb0681a8edcf34e5b98d5580995eb6b91b4c;hpb=726f63884db0132f01745f1fb4465e6621088ccf;p=platform%2Fupstream%2Fbash.git diff --git a/tests/set-e-test b/tests/set-e-test index ce3feb0..1fdf360 100644 --- a/tests/set-e-test +++ b/tests/set-e-test @@ -14,3 +14,92 @@ if : ; then done set +e fi + +( +set -e +false +echo bad +) +echo $? + +x=$( +set -e +false +echo bad +) +echo $? $x + +# command subst should not inherit -e +set -e +echo $(false; echo ok) + +if set +e +then + false +fi +echo hi + +set -e + +# a failing command in the compound list following a while, until, or +# if should not cause the shell to exit + +while false; do + echo hi +done +echo while succeeded + +x=1 +until (( x == 4 )); do + x=4 +done +echo until succeeded: $x + +if false; then + echo oops +fi +echo if succeeded + +# failing commands that are part of an AND or OR list should not +# cause the shell to exit +false && echo AND list failed +echo AND list succeeded + +false || echo OR list succeeded + +! false +echo ! succeeded + +# make sure eval preserves the state of the -e flag and `!' reserved word +set -e +if eval false; then + echo oops +fi +echo eval succeeded + +! eval false +echo ! eval succeeded -- 1 + +! eval '(exit 5)' +echo ! eval succeeded -- 2 + +set -e +until builtin false; do echo a; break; done +echo $? + +until eval false; do echo b; break; done +echo $? + +: ${TMPDIR:=/tmp} +FN=$TMPDIR/set-e-$$ +cat > $FN << EOF +false +echo after 1 +false +EOF + +set -e +until . $FN; do echo a; break; done +echo $? + +rm -f $FN