diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 0972b105a2ed..d3708b3bd140 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -279,6 +279,8 @@ evaltree(union node *n, int flags) break; case NNOT: evaltree(n->nnot.com, EV_TESTED); + if (evalskip) + goto out; exitstatus = !exitstatus; break; diff --git a/tools/regression/bin/sh/execution/not1.0 b/tools/regression/bin/sh/execution/not1.0 new file mode 100644 index 000000000000..12c6265a9282 --- /dev/null +++ b/tools/regression/bin/sh/execution/not1.0 @@ -0,0 +1,4 @@ +# $FreeBSD$ + +f() { ! return $1; } +f 0 && ! f 1 diff --git a/tools/regression/bin/sh/execution/not2.0 b/tools/regression/bin/sh/execution/not2.0 new file mode 100644 index 000000000000..1b128d096716 --- /dev/null +++ b/tools/regression/bin/sh/execution/not2.0 @@ -0,0 +1,6 @@ +# $FreeBSD$ + +while :; do + ! break + exit 3 +done