svn commit: r245422 - in head: bin/sh tools/regression/bin/sh/expansion

Jilles Tjoelker jilles at FreeBSD.org
Mon Jan 14 12:20:56 UTC 2013


Author: jilles
Date: Mon Jan 14 12:20:55 2013
New Revision: 245422
URL: http://svnweb.freebsd.org/changeset/base/245422

Log:
  sh: Pass $? to command substitution containing compound/multiple commands.
  
  Example:
    false; echo $(echo $?; :)

Added:
  head/tools/regression/bin/sh/expansion/cmdsubst17.0   (contents, props changed)
Modified:
  head/bin/sh/eval.c

Modified: head/bin/sh/eval.c
==============================================================================
--- head/bin/sh/eval.c	Mon Jan 14 12:12:56 2013	(r245421)
+++ head/bin/sh/eval.c	Mon Jan 14 12:20:55 2013	(r245422)
@@ -624,8 +624,8 @@ evalbackcmd(union node *n, struct backcm
 		exitstatus = 0;
 		goto out;
 	}
+	exitstatus = oexitstatus;
 	if (is_valid_fast_cmdsubst(n)) {
-		exitstatus = oexitstatus;
 		savelocalvars = localvars;
 		localvars = NULL;
 		forcelocal++;
@@ -649,7 +649,6 @@ evalbackcmd(union node *n, struct backcm
 		poplocalvars();
 		localvars = savelocalvars;
 	} else {
-		exitstatus = 0;
 		if (pipe(pip) < 0)
 			error("Pipe call failed: %s", strerror(errno));
 		jp = makejob(n, 1);

Added: head/tools/regression/bin/sh/expansion/cmdsubst17.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/expansion/cmdsubst17.0	Mon Jan 14 12:20:55 2013	(r245422)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+f() { return 3; }
+f
+[ `echo $?; :` = 3 ]


More information about the svn-src-head mailing list