Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Aug 2015 12:57:18 +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: r286826 - in head/bin/sh: . tests/builtins
Message-ID:  <201508161257.t7GCvI7c062536@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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" ]



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