svn commit: r245381 - in head: bin/sh tools/regression/bin/sh/expansion
Jilles Tjoelker
jilles at FreeBSD.org
Sun Jan 13 19:19:41 UTC 2013
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;
+
+`
More information about the svn-src-head
mailing list