1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-11 13:01:28 +02:00

zsh-workers/8187

This commit is contained in:
Tanaka Akira 1999-10-10 16:03:01 +00:00
parent bb71f141bf
commit 621bcdd767
2 changed files with 13 additions and 4 deletions

View file

@ -1908,14 +1908,23 @@ execcmd(Cmd cmd, int input, int output, int how, int last1)
case MERGEOUT: case MERGEOUT:
if(fn->fd2 < 10) if(fn->fd2 < 10)
closemn(mfds, fn->fd2); 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) { if (fil == -1) {
char fdstr[4]; char fdstr[4];
closemnodes(mfds); closemnodes(mfds);
fixfds(save); fixfds(save);
sprintf(fdstr, "%d", fn->fd2); if(fn->fd2 != -2)
zerr("%s: %e", fdstr, errno); sprintf(fdstr, "%d", fn->fd2);
zerr("%s: %e", fn->fd2 == -2 ? "coprocess" : fdstr, errno);
execerr(); execerr();
} }
addfd(forked, save, mfds, fn->fd1, fil, fn->type == MERGEOUT); addfd(forked, save, mfds, fn->fd1, fil, fn->type == MERGEOUT);

View file

@ -1580,7 +1580,7 @@ xpandredir(struct redir *fn, LinkList tab)
if (s[0] == '-' && !s[1]) if (s[0] == '-' && !s[1])
fn->type = CLOSE; fn->type = CLOSE;
else if (s[0] == 'p' && !s[1]) else if (s[0] == 'p' && !s[1])
fn->fd2 = (fn->type == MERGEOUT) ? coprocout : coprocin; fn->fd2 = -2;
else { else {
while (idigit(*s)) while (idigit(*s))
s++; s++;