diff --git a/bin/sh/parser.c b/bin/sh/parser.c index cc1860df22fd..192769b076c4 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -1513,10 +1513,12 @@ checkend: { p = line; for (q = eofmark + 1 ; *q && *p == *q ; p++, q++); - if (*p == '\n' && *q == '\0') { + if ((*p == '\0' || *p == '\n') && *q == '\0') { c = PEOF; - plinno++; - needprompt = doprompt; + if (*p == '\n') { + plinno++; + needprompt = doprompt; + } } else { pushstring(line, strlen(line), NULL); } diff --git a/tools/regression/bin/sh/parser/heredoc11.0 b/tools/regression/bin/sh/parser/heredoc11.0 new file mode 100644 index 000000000000..5839e46b36ce --- /dev/null +++ b/tools/regression/bin/sh/parser/heredoc11.0 @@ -0,0 +1,26 @@ +# $FreeBSD$ + +failures='' + +check() { + if eval "[ $* ]"; then + : + else + echo "Failed: $*" + failures=x$failures + fi +} + +check '`cat <