svn commit: r286826 - in head/bin/sh: . tests/builtins

Jilles Tjoelker jilles at FreeBSD.org
Sun Aug 16 12:57:19 UTC 2015


Author: jilles
Date: Sun Aug 16 12:57:17 2015
New Revision: 286826
URL: https://svnweb.freebsd.org/changeset/base/286826

Log:
  sh: Backslash-newline should not affect field splitting in read builtin.
  
  This was originally broken in r212339 in 2010.

Added:
  head/bin/sh/tests/builtins/read8.0   (contents, props changed)
Modified:
  head/bin/sh/miscbltin.c
  head/bin/sh/tests/builtins/Makefile

Modified: head/bin/sh/miscbltin.c
==============================================================================
--- head/bin/sh/miscbltin.c	Sun Aug 16 12:23:58 2015	(r286825)
+++ head/bin/sh/miscbltin.c	Sun Aug 16 12:57:17 2015	(r286826)
@@ -191,9 +191,10 @@ readcmd(int argc __unused, char **argv _
 		CHECKSTRSPACE(1, p);
 		if (backslash) {
 			backslash = 0;
-			startword = 0;
-			if (c != '\n')
+			if (c != '\n') {
+				startword = 0;
 				USTPUTC(c, p);
+			}
 			continue;
 		}
 		if (!rflag && c == '\\') {

Modified: head/bin/sh/tests/builtins/Makefile
==============================================================================
--- head/bin/sh/tests/builtins/Makefile	Sun Aug 16 12:23:58 2015	(r286825)
+++ head/bin/sh/tests/builtins/Makefile	Sun Aug 16 12:57:17 2015	(r286826)
@@ -121,6 +121,7 @@ FILES+=		read4.0 read4.0.stdout
 FILES+=		read5.0
 FILES+=		read6.0
 FILES+=		read7.0
+FILES+=		read8.0
 FILES+=		return1.0
 FILES+=		return2.1
 FILES+=		return3.1

Added: head/bin/sh/tests/builtins/read8.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/sh/tests/builtins/read8.0	Sun Aug 16 12:57:17 2015	(r286826)
@@ -0,0 +1,17 @@
+# $FreeBSD$
+
+read a b c <<\EOF
+\
+A\
+ \
+ \
+ \
+B\
+ \
+ \
+C\
+ \
+ \
+ \
+EOF
+[ "$a.$b.$c" = "A.B.C" ]


More information about the svn-src-head mailing list