From 718cf25701716f09aa96832c64151fb8aa286279 Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 16 Aug 2015 12:57:17 +0000 Subject: sh: Backslash-newline should not affect field splitting in read builtin. This was originally broken in r212339 in 2010. --- bin/sh/miscbltin.c | 5 +++-- bin/sh/tests/builtins/Makefile | 1 + bin/sh/tests/builtins/read8.0 | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 bin/sh/tests/builtins/read8.0 (limited to 'bin') diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c index 715e324..4575e96 100644 --- a/bin/sh/miscbltin.c +++ b/bin/sh/miscbltin.c @@ -191,9 +191,10 @@ readcmd(int argc __unused, char **argv __unused) CHECKSTRSPACE(1, p); if (backslash) { backslash = 0; - startword = 0; - if (c != '\n') + if (c != '\n') { + startword = 0; USTPUTC(c, p); + } continue; } if (!rflag && c == '\\') { diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile index ad39aac..f3c1dc7 100644 --- a/bin/sh/tests/builtins/Makefile +++ b/bin/sh/tests/builtins/Makefile @@ -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 diff --git a/bin/sh/tests/builtins/read8.0 b/bin/sh/tests/builtins/read8.0 new file mode 100644 index 0000000..fb786ff --- /dev/null +++ b/bin/sh/tests/builtins/read8.0 @@ -0,0 +1,17 @@ +# $FreeBSD$ + +read a b c <<\EOF +\ +A\ + \ + \ + \ +B\ + \ + \ +C\ + \ + \ + \ +EOF +[ "$a.$b.$c" = "A.B.C" ] -- cgit v1.1