summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2015-08-16 12:57:17 +0000
committerjilles <jilles@FreeBSD.org>2015-08-16 12:57:17 +0000
commit718cf25701716f09aa96832c64151fb8aa286279 (patch)
tree7c41f69ffd432061f9f8d27e82b41ee9801a1373 /bin
parentbc522110e39ea6c6e4335ea0315ad6872e6e0705 (diff)
downloadFreeBSD-src-718cf25701716f09aa96832c64151fb8aa286279.zip
FreeBSD-src-718cf25701716f09aa96832c64151fb8aa286279.tar.gz
sh: Backslash-newline should not affect field splitting in read builtin.
This was originally broken in r212339 in 2010.
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/miscbltin.c5
-rw-r--r--bin/sh/tests/builtins/Makefile1
-rw-r--r--bin/sh/tests/builtins/read8.017
3 files changed, 21 insertions, 2 deletions
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" ]
OpenPOWER on IntegriCloud