Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Oct 2014 13:12:06 +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: r272983 - in head/bin/sh: . tests/builtins
Message-ID:  <201410121312.s9CDC6V9044630@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sun Oct 12 13:12:06 2014
New Revision: 272983
URL: https://svnweb.freebsd.org/changeset/base/272983

Log:
  sh: Fix break/continue/return in multiline eval.
  
  Example:
    eval $'return\necho bad'

Added:
  head/bin/sh/tests/builtins/eval7.0   (contents, props changed)
  head/bin/sh/tests/builtins/eval8.7   (contents, props changed)
Modified:
  head/bin/sh/eval.c
  head/bin/sh/tests/builtins/Makefile

Modified: head/bin/sh/eval.c
==============================================================================
--- head/bin/sh/eval.c	Sun Oct 12 11:22:25 2014	(r272982)
+++ head/bin/sh/eval.c	Sun Oct 12 13:12:06 2014	(r272983)
@@ -168,6 +168,8 @@ evalstring(char *s, int flags)
 			else
 				evaltree(n, flags);
 			any = 1;
+			if (evalskip)
+				break;
 		}
 		popstackmark(&smark);
 		setstackmark(&smark);

Modified: head/bin/sh/tests/builtins/Makefile
==============================================================================
--- head/bin/sh/tests/builtins/Makefile	Sun Oct 12 11:22:25 2014	(r272982)
+++ head/bin/sh/tests/builtins/Makefile	Sun Oct 12 13:12:06 2014	(r272983)
@@ -72,6 +72,8 @@ FILES+=		eval3.0
 FILES+=		eval4.0
 FILES+=		eval5.0
 FILES+=		eval6.0
+FILES+=		eval7.0
+FILES+=		eval8.7
 FILES+=		exec1.0
 FILES+=		exec2.0
 FILES+=		exit1.0

Added: head/bin/sh/tests/builtins/eval7.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/sh/tests/builtins/eval7.0	Sun Oct 12 13:12:06 2014	(r272983)
@@ -0,0 +1,9 @@
+# $FreeBSD$
+# Assumes that break can break out of a loop outside eval.
+
+while :; do
+	eval "break
+echo bad1"
+	echo bad2
+	exit 3
+done

Added: head/bin/sh/tests/builtins/eval8.7
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/sh/tests/builtins/eval8.7	Sun Oct 12 13:12:06 2014	(r272983)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+f() {
+	eval "return 7
+echo bad2"
+}
+f



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