diff options
Diffstat (limited to '')
-rw-r--r-- | src/redir.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/redir.c b/src/redir.c index 33dbc88..ce34db0 100644 --- a/src/redir.c +++ b/src/redir.c @@ -295,18 +295,25 @@ err: STATIC int openhere(union node *redir) { + char *p; int pip[2]; size_t len = 0; if (pipe(pip) < 0) sh_error("Pipe call failed"); - if (redir->type == NHERE) { - len = strlen(redir->nhere.doc->narg.text); - if (len <= PIPESIZE) { - xwrite(pip[1], redir->nhere.doc->narg.text, len); - goto out; - } + + p = redir->nhere.doc->narg.text; + if (redir->type == NXHERE) { + expandarg(redir->nhere.doc, NULL, EXP_QUOTED); + p = stackblock(); + } + + len = strlen(p); + if (len <= PIPESIZE) { + xwrite(pip[1], p, len); + goto out; } + if (forkshell((struct job *)NULL, (union node *)NULL, FORK_NOJOB) == 0) { close(pip[0]); signal(SIGINT, SIG_IGN); @@ -316,10 +323,7 @@ openhere(union node *redir) signal(SIGTSTP, SIG_IGN); #endif signal(SIGPIPE, SIG_DFL); - if (redir->type == NHERE) - xwrite(pip[1], redir->nhere.doc->narg.text, len); - else - expandhere(redir->nhere.doc, pip[1]); + xwrite(pip[1], p, len); _exit(0); } out: |