svn commit: r273802 - in head/bin/sh: . tests/parameters

Jilles Tjoelker jilles at FreeBSD.org
Tue Oct 28 22:14:33 UTC 2014


Author: jilles
Date: Tue Oct 28 22:14:31 2014
New Revision: 273802
URL: https://svnweb.freebsd.org/changeset/base/273802

Log:
  Treat IFS separators in "$*" as quoted.
  
  This makes a difference if IFS starts with *, ?, [ or a CTL* byte.

Added:
  head/bin/sh/tests/parameters/positional6.0   (contents, props changed)
  head/bin/sh/tests/parameters/positional7.0   (contents, props changed)
Modified:
  head/bin/sh/expand.c
  head/bin/sh/tests/parameters/Makefile

Modified: head/bin/sh/expand.c
==============================================================================
--- head/bin/sh/expand.c	Tue Oct 28 21:06:04 2014	(r273801)
+++ head/bin/sh/expand.c	Tue Oct 28 22:14:31 2014	(r273802)
@@ -878,7 +878,7 @@ varvalue(const char *name, int quoted, i
 	int num;
 	char *p;
 	int i;
-	char sep;
+	char sep[2];
 	char **ap;
 
 	switch (*name) {
@@ -912,15 +912,18 @@ varvalue(const char *name, int quoted, i
 		/* FALLTHROUGH */
 	case '*':
 		if (ifsset())
-			sep = ifsval()[0];
+			sep[0] = ifsval()[0];
 		else
-			sep = ' ';
+			sep[0] = ' ';
+		sep[1] = '\0';
 		for (ap = shellparam.p ; (p = *ap++) != NULL ; ) {
 			strtodest(p, flag, subtype, quoted);
 			if (!*ap)
 				break;
-			if (sep || (flag & EXP_FULL && !quoted && **ap != '\0'))
-				STPUTC(sep, expdest);
+			if (sep[0])
+				strtodest(sep, flag, subtype, quoted);
+			else if (flag & EXP_FULL && !quoted && **ap != '\0')
+				STPUTC('\0', expdest);
 		}
 		return;
 	default:

Modified: head/bin/sh/tests/parameters/Makefile
==============================================================================
--- head/bin/sh/tests/parameters/Makefile	Tue Oct 28 21:06:04 2014	(r273801)
+++ head/bin/sh/tests/parameters/Makefile	Tue Oct 28 22:14:31 2014	(r273802)
@@ -18,6 +18,8 @@ FILES+=		positional2.0
 FILES+=		positional3.0
 FILES+=		positional4.0
 FILES+=		positional5.0
+FILES+=		positional6.0
+FILES+=		positional7.0
 FILES+=		pwd1.0
 FILES+=		pwd2.0
 

Added: head/bin/sh/tests/parameters/positional6.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/sh/tests/parameters/positional6.0	Tue Oct 28 22:14:31 2014	(r273802)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+IFS=?
+set p r
+v=pqrs
+r=${v#"$*"}
+[ "$r" = pqrs ]

Added: head/bin/sh/tests/parameters/positional7.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/sh/tests/parameters/positional7.0	Tue Oct 28 22:14:31 2014	(r273802)
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+set -- / ''
+IFS=*
+set -- "$*"
+IFS=:
+args="$*"
+[ "$#:$args" = "1:/*" ]


More information about the svn-src-head mailing list