Module Name: src Committed By: dholland Date: Sun Jun 6 04:51:13 UTC 2010
Modified Files: src/tests/util/sh: t_set_e.sh Log Message: Document the changes in the previous version of this file. If we're going to whitewash the test failures, we should at least keep track of what the "real" correct behavior/output is. Especially since a large portion of the tests in here were added specifically to illuminate points at issue in prior discussions. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/util/sh/t_set_e.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/util/sh/t_set_e.sh diff -u src/tests/util/sh/t_set_e.sh:1.7 src/tests/util/sh/t_set_e.sh:1.8 --- src/tests/util/sh/t_set_e.sh:1.7 Thu Jun 3 16:06:19 2010 +++ src/tests/util/sh/t_set_e.sh Sun Jun 6 04:51:13 2010 @@ -1,4 +1,4 @@ -# $NetBSD: t_set_e.sh,v 1.7 2010/06/03 16:06:19 christos Exp $ +# $NetBSD: t_set_e.sh,v 1.8 2010/06/06 04:51:13 dholland Exp $ # # Copyright (c) 2007 The NetBSD Foundation, Inc. # All rights reserved. @@ -106,6 +106,10 @@ # according to the standard, only failing *simple* commands # cause an exit under -e. () is not a simple command. + # Correct (per POSIX): + #dcheck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK OK' + #echeck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK OK' + # Wrong current behavior: dcheck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK' echeck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK' @@ -133,12 +137,18 @@ # is in effect and tested accordingly. # dcheck '(set -e; false || false; echo ERR); echo OK' 'OK' - dcheck '(set -e; false && false; echo ERR); echo OK' 'ERR OK' dcheck '(set -e; true && false; echo ERR); echo OK' 'OK' echeck '(set -e; false || false; echo ERR); echo OK' 'OK' - echeck '(set -e; false && false; echo ERR); echo OK' 'ERR OK' echeck '(set -e; true && false; echo ERR); echo OK' 'OK' + # correct: + #dcheck '(set -e; false && false; echo ERR); echo OK' 'OK' + #echeck '(set -e; false && false; echo ERR); echo OK' 'OK' + + # wrong current behavior: + dcheck '(set -e; false && false; echo ERR); echo OK' 'ERR OK' + echeck '(set -e; false && false; echo ERR); echo OK' 'ERR OK' + # A failure that is not reached because of short-circuit # evaluation should not cause an exit, however. dcheck '(set -e; true || false; echo OK); echo OK' 'OK OK' @@ -174,6 +184,10 @@ # combined case with () and &&; the inner expression is false # but does not itself exit, and the () should not cause an # exit even when failing. + # correct: + #dcheck '(set -e; (false && true); echo OK); echo OK' 'OK OK' + #echeck '(set -e; (false && true); echo OK); echo OK' 'OK OK' + # wrong current behavior: dcheck '(set -e; (false && true); echo OK); echo OK' 'OK' echeck '(set -e; (false && true); echo OK); echo OK' 'OK' @@ -198,13 +212,16 @@ # able to isolate set -e behavior inside ().) However, I'm # going to put these tests here to make sure the issue gets # dealt with sometime. + # + # XXX: the second set has been disabled in the name of making + # all tests "pass". # 1. error if the whole shell exits (current behavior) dcheck 'echo OK; (set -e; false); echo OK' 'OK OK' echeck 'echo OK; (set -e; false); echo OK' 'OK OK' # 2. error if the whole shell does not exit (dsl's suggested behavior) - dcheck 'echo OK; (set -e; false); echo ERR' 'OK ERR' - echeck 'echo OK; (set -e; false); echo ERR' 'OK ERR' + #dcheck 'echo OK; (set -e; false); echo ERR' 'OK' + #echeck 'echo OK; (set -e; false); echo ERR' 'OK' # The current behavior of the shell is that it exits out as # far as -e is set and then stops. This is probably a @@ -214,24 +231,45 @@ echeck '(set -e; (false; echo ERR); echo ERR); echo OK' 'OK' # backquote expansion (PR bin/17514) + + # correct + #dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK' + #dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK' + #dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK' + #dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK' + # wrong current behavior dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK' dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK' dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK' dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'ERR ERR OK' + dcheck '(set -e; x=`false`; echo ERR); echo OK' 'OK' dcheck '(set -e; x=$(false); echo ERR); echo OK' 'OK' dcheck '(set -e; x=`exit 3`; echo ERR); echo OK' 'OK' dcheck '(set -e; x=$(exit 3); echo ERR); echo OK' 'OK' + + # correct + #echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK' + #echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK' + #echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK' + #echeck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK' + + # wrong current behavior echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK' echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK' echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK' echeck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'ERR ERR OK' + echeck '(set -e; x=`false`; echo ERR); echo OK' 'OK' echeck '(set -e; x=$(false); echo ERR); echo OK' 'OK' echeck '(set -e; x=`exit 3`; echo ERR); echo OK' 'OK' echeck '(set -e; x=$(exit 3); echo ERR); echo OK' 'OK' # shift (PR bin/37493) + # correct + #dcheck '(set -e; shift || true; echo OK); echo OK' 'OK OK' + #echeck '(set -e; shift || true; echo OK); echo OK' 'OK OK' + # wrong current behavior dcheck '(set -e; shift || true; echo OK); echo OK' 'OK' echeck '(set -e; shift || true; echo OK); echo OK' 'OK'