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