Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Apr 2013 15:19:36 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r249407 - in head: bin/sh tools/regression/bin/sh/execution
Message-ID:  <201304121519.r3CFJau6047700@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304121519.r3CFJau6047700>