2642b8
diff -up ksh-20120801/src/cmd/ksh93/sh/lex.c.heresub ksh-20120801/src/cmd/ksh93/sh/lex.c
2642b8
--- ksh-20120801/src/cmd/ksh93/sh/lex.c.heresub	2014-05-21 16:48:42.635700984 +0200
2642b8
+++ ksh-20120801/src/cmd/ksh93/sh/lex.c	2014-05-21 16:48:42.678700772 +0200
2642b8
@@ -1557,6 +1557,7 @@ static int comsub(register Lex_t *lp, in
2642b8
 {
2642b8
 	register int	n,c,count=1;
2642b8
 	register int	line=lp->sh->inlineno;
2642b8
+	struct ionod	*inheredoc = lp->heredoc;
2642b8
 	char *first,*cp=fcseek(0),word[5];
2642b8
 	int off, messages=0, assignok=lp->assignok, csub;
2642b8
 	struct lexstate	save;
2642b8
@@ -1683,7 +1684,7 @@ done:
2642b8
 	lp->lexd.dolparen--;
2642b8
 	lp->lex = save;
2642b8
 	lp->assignok = (endchar(lp)==RBRACT?assignok:0);
2642b8
-	if(lp->heredoc)
2642b8
+	if(lp->heredoc && !inheredoc)
2642b8
 		errormsg(SH_DICT,ERROR_exit(SYNBAD),e_lexsyntax5,lp->sh->inlineno,lp->heredoc->ioname);
2642b8
 	return(messages);
2642b8
 }
2642b8
diff -up ksh-20120801/src/cmd/ksh93/sh/macro.c.heresub ksh-20120801/src/cmd/ksh93/sh/macro.c
2642b8
--- ksh-20120801/src/cmd/ksh93/sh/macro.c.heresub	2014-05-21 16:48:42.650700910 +0200
2642b8
+++ ksh-20120801/src/cmd/ksh93/sh/macro.c	2014-05-21 16:48:42.678700772 +0200
2642b8
@@ -2085,7 +2085,7 @@ static void comsubst(Mac_t *mp,register
2642b8
 			}
2642b8
 			sfputc(stkp,c);
2642b8
 		}
2642b8
-		sfputc(stkp,' ');
2642b8
+		sfputc(stkp,'\n');
2642b8
 		c = stktell(stkp);
2642b8
 		str=stkfreeze(stkp,1);
2642b8
 		/* disable verbose and don't save in history file */