aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 7cc452d20..9f916b8a3 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4875,13 +4875,21 @@ dupredirect(union node *redir, int f)
4875 4875
4876 if (redir->nfile.type == NTOFD || redir->nfile.type == NFROMFD) { 4876 if (redir->nfile.type == NTOFD || redir->nfile.type == NFROMFD) {
4877 if (redir->ndup.dupfd >= 0) { /* if not ">&-" */ 4877 if (redir->ndup.dupfd >= 0) { /* if not ">&-" */
4878#ifdef __MINGW32__
4879 dup2(redir->ndup.dupfd, fd);
4880#else
4878 copyfd(redir->ndup.dupfd, fd); 4881 copyfd(redir->ndup.dupfd, fd);
4882#endif
4879 } 4883 }
4880 return; 4884 return;
4881 } 4885 }
4882 4886
4883 if (f != fd) { 4887 if (f >= 0 && f != fd) {
4888#ifdef __MINGW32__
4889 dup2(f, fd);
4890#else
4884 copyfd(f, fd); 4891 copyfd(f, fd);
4892#endif
4885 close(f); 4893 close(f);
4886 } 4894 }
4887} 4895}
@@ -4978,7 +4986,11 @@ popredir(int drop)
4978 if (rp->renamed[i] != EMPTY) { 4986 if (rp->renamed[i] != EMPTY) {
4979 if (!drop) { 4987 if (!drop) {
4980 close(i); 4988 close(i);
4989#ifdef __MINGW32__
4990 dup2(rp->renamed[i], i);
4991#else
4981 copyfd(rp->renamed[i], i); 4992 copyfd(rp->renamed[i], i);
4993#endif
4982 } 4994 }
4983 close(rp->renamed[i]); 4995 close(rp->renamed[i]);
4984 } 4996 }