svn commit: r249407 - in head: bin/sh tools/regression/bin/sh/execution

Jilles Tjoelker jilles at FreeBSD.org
Fri Apr 12 15:19:37 UTC 2013


Author: jilles
Date: Fri Apr 12 15:19:35 2013
New Revision: 249407
URL: http://svnweb.freebsd.org/changeset/base/249407

Log:
  sh: Don't modify exit status when break/continue/return passes !.
  
  This matches what would happen if  ! P  were to be replaced with
  if P; then false; else true; fi.
  
  Example:
    f() { ! return 0; }; f

Added:
  head/tools/regression/bin/sh/execution/not1.0   (contents, props changed)
  head/tools/regression/bin/sh/execution/not2.0   (contents, props changed)
Modified:
  head/bin/sh/eval.c

Modified: head/bin/sh/eval.c
==============================================================================
--- head/bin/sh/eval.c	Fri Apr 12 14:32:16 2013	(r249406)
+++ head/bin/sh/eval.c	Fri Apr 12 15:19:35 2013	(r249407)
@@ -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;
 

Added: head/tools/regression/bin/sh/execution/not1.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/execution/not1.0	Fri Apr 12 15:19:35 2013	(r249407)
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+f() { ! return $1; }
+f 0 && ! f 1

Added: head/tools/regression/bin/sh/execution/not2.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/execution/not2.0	Fri Apr 12 15:19:35 2013	(r249407)
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+while :; do
+	! break
+	exit 3
+done


More information about the svn-src-head mailing list