summaryrefslogtreecommitdiff
path: root/bin/ksh/eval.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-11-10 21:26:40 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-11-10 21:26:40 +0000
commitde8e8de6b77224e8b2ac3c698fbc2dabb934f77b (patch)
treed900abc4c52849fcd9a047dec413fa759453d5c3 /bin/ksh/eval.c
parent507ab8275b041b65d552f065abafff05c014342e (diff)
If "from fd" == "to fd" don't call dup2() or close "from fd".
Diffstat (limited to 'bin/ksh/eval.c')
-rw-r--r--bin/ksh/eval.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/ksh/eval.c b/bin/ksh/eval.c
index 8f998cf2283..cf29ff9fee4 100644
--- a/bin/ksh/eval.c
+++ b/bin/ksh/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.13 2003/04/16 23:11:52 tdeval Exp $ */
+/* $OpenBSD: eval.c,v 1.14 2003/11/10 21:26:39 millert Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -874,8 +874,10 @@ comsub(xp, cp)
openpipe(pv);
shf = shf_fdopen(pv[0], SHF_RD, (struct shf *) 0);
ofd1 = savefd(1, 0); /* fd 1 may be closed... */
- ksh_dup2(pv[1], 1, FALSE);
- close(pv[1]);
+ if (pv[1] != 1) {
+ ksh_dup2(pv[1], 1, FALSE);
+ close(pv[1]);
+ }
execute(t, XFORK|XXCOM|XPIPEO);
restfd(1, ofd1);
startlast();