Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Aug 2011 21:33:50 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r224854 - in stable/8: bin/sh tools/regression/bin/sh/expansion
Message-ID:  <201108132133.p7DLXo3m033860@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sat Aug 13 21:33:50 2011
New Revision: 224854
URL: http://svn.freebsd.org/changeset/base/224854

Log:
  MFC r222716: sh: Fix $? in heredocs on simple commands.
  
  The patch is slightly different because redirected compound commands are
  handled differently in stable/8 (no separate function, redirection errors
  are fatal).
  
  PR:		bin/41410

Added:
  stable/8/tools/regression/bin/sh/expansion/heredoc2.0
     - copied unchanged from r222716, head/tools/regression/bin/sh/expansion/heredoc2.0
Modified:
  stable/8/bin/sh/eval.c
Directory Properties:
  stable/8/bin/sh/   (props changed)
  stable/8/tools/regression/bin/sh/   (props changed)

Modified: stable/8/bin/sh/eval.c
==============================================================================
--- stable/8/bin/sh/eval.c	Sat Aug 13 17:29:37 2011	(r224853)
+++ stable/8/bin/sh/eval.c	Sat Aug 13 21:33:50 2011	(r224854)
@@ -221,6 +221,7 @@ evaltree(union node *n, int flags)
 		evaltree(n->nbinary.ch2, flags);
 		break;
 	case NREDIR:
+		oexitstatus = exitstatus;
 		expredir(n->nredir.redirect);
 		redirect(n->nredir.redirect, REDIR_PUSH);
 		evaltree(n->nredir.n, flags);
@@ -400,6 +401,7 @@ evalsubshell(union node *n, int flags)
 	struct job *jp;
 	int backgnd = (n->type == NBACKGND);
 
+	oexitstatus = exitstatus;
 	expredir(n->nredir.redirect);
 	if ((!backgnd && flags & EV_EXIT && !have_traps()) ||
 			forkshell(jp = makejob(n, 1), n, backgnd) == 0) {
@@ -428,7 +430,6 @@ expredir(union node *n)
 	for (redir = n ; redir ; redir = redir->nfile.next) {
 		struct arglist fn;
 		fn.lastp = &fn.list;
-		oexitstatus = exitstatus;
 		switch (redir->type) {
 		case NFROM:
 		case NTO:

Copied: stable/8/tools/regression/bin/sh/expansion/heredoc2.0 (from r222716, head/tools/regression/bin/sh/expansion/heredoc2.0)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/8/tools/regression/bin/sh/expansion/heredoc2.0	Sat Aug 13 21:33:50 2011	(r224854, copy of r222716, head/tools/regression/bin/sh/expansion/heredoc2.0)
@@ -0,0 +1,15 @@
+# $FreeBSD$
+
+f() { return $1; }
+
+[ `f 42; cat <<EOF
+$?
+EOF
+` = 42 ] || echo simple command bad
+
+long=`printf %08192d 0`
+
+[ `f 42; cat <<EOF
+$long.$?
+EOF
+` = $long.42 ] || echo long simple command bad



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