diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-10-10 16:03:01 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-10-10 16:03:01 +0000 |
commit | 621bcdd7671d7463910afe24fada85792d803a8c (patch) | |
tree | bf8542a22719de9ade5b1536b248f1ff13ce506f | |
parent | bb71f141bf2884f1edbe1771cd3ca2393f24627e (diff) | |
download | zsh-621bcdd7671d7463910afe24fada85792d803a8c.tar.gz zsh-621bcdd7671d7463910afe24fada85792d803a8c.tar.xz zsh-621bcdd7671d7463910afe24fada85792d803a8c.zip |
zsh-workers/8187
-rw-r--r-- | Src/exec.c | 15 | ||||
-rw-r--r-- | Src/glob.c | 2 |
2 files changed, 13 insertions, 4 deletions
diff --git a/Src/exec.c b/Src/exec.c index 0670148c7..6d504e52d 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1908,14 +1908,23 @@ execcmd(Cmd cmd, int input, int output, int how, int last1) case MERGEOUT: if(fn->fd2 < 10) closemn(mfds, fn->fd2); - fil = dup(fn->fd2); + if(fn->fd2 > 9) { + fil = -1; + errno = EBADF; + } else { + int fd = fn->fd2; + if(fd == -2) + fd = (fn->type == MERGEOUT) ? coprocout : coprocin; + fil = dup(fd); + } if (fil == -1) { char fdstr[4]; closemnodes(mfds); fixfds(save); - sprintf(fdstr, "%d", fn->fd2); - zerr("%s: %e", fdstr, errno); + if(fn->fd2 != -2) + sprintf(fdstr, "%d", fn->fd2); + zerr("%s: %e", fn->fd2 == -2 ? "coprocess" : fdstr, errno); execerr(); } addfd(forked, save, mfds, fn->fd1, fil, fn->type == MERGEOUT); diff --git a/Src/glob.c b/Src/glob.c index 07336986d..d8cfc6a6a 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -1580,7 +1580,7 @@ xpandredir(struct redir *fn, LinkList tab) if (s[0] == '-' && !s[1]) fn->type = CLOSE; else if (s[0] == 'p' && !s[1]) - fn->fd2 = (fn->type == MERGEOUT) ? coprocout : coprocin; + fn->fd2 = -2; else { while (idigit(*s)) s++; |