Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Jan 2013 19:19:41 +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: r245381 - in head: bin/sh tools/regression/bin/sh/expansion
Message-ID:  <201301131919.r0DJJfNb061653@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sun Jan 13 19:19:40 2013
New Revision: 245381
URL: http://svnweb.freebsd.org/changeset/base/245381

Log:
  sh: Don't lose $? when backquoted command ends with semicolon or newline.
  
  An empty simple command was added and overwrote the exit status with 0.
  
  This affects `...` but not $(...).
  
  Example:
    v=`false;`; echo $?

Added:
  head/tools/regression/bin/sh/expansion/cmdsubst14.0   (contents, props changed)
  head/tools/regression/bin/sh/expansion/cmdsubst15.0   (contents, props changed)
Modified:
  head/bin/sh/parser.c

Modified: head/bin/sh/parser.c
==============================================================================
--- head/bin/sh/parser.c	Sun Jan 13 16:57:11 2013	(r245380)
+++ head/bin/sh/parser.c	Sun Jan 13 19:19:40 2013	(r245381)
@@ -286,7 +286,8 @@ list(int nlflag, int erflag)
 				tokpushback++;
 			}
 			checkkwd = CHKNL | CHKKWD | CHKALIAS;
-			if (!nlflag && !erflag && tokendlist[peektoken()])
+			if (!nlflag && (erflag ? peektoken() == TEOF :
+			    tokendlist[peektoken()]))
 				return ntop;
 			break;
 		case TEOF:

Added: head/tools/regression/bin/sh/expansion/cmdsubst14.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/expansion/cmdsubst14.0	Sun Jan 13 19:19:40 2013	(r245381)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+! v=`false
+
+`

Added: head/tools/regression/bin/sh/expansion/cmdsubst15.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/expansion/cmdsubst15.0	Sun Jan 13 19:19:40 2013	(r245381)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+! v=`false;
+
+`



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