Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh PR bin/51123 - make >&- work in all cases, and while ...



details:   https://anonhg.NetBSD.org/src/rev/b796a27acfc1
branches:  trunk
changeset: 815267:b796a27acfc1
user:      kre <kre%NetBSD.org@localhost>
date:      Sun May 08 20:14:27 2016 +0000

description:
PR bin/51123 - make >&- work in all cases, and while doing that fix
things so that >/dev/stdout </dev/stdin (etc) work as well (in all cases).

ok christos@

diffstat:

 bin/sh/redir.c |  9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diffs (37 lines):

diff -r 33e995211e45 -r b796a27acfc1 bin/sh/redir.c
--- a/bin/sh/redir.c    Sun May 08 20:01:56 2016 +0000
+++ b/bin/sh/redir.c    Sun May 08 20:14:27 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: redir.c,v 1.44 2016/05/08 03:51:15 kre Exp $   */
+/*     $NetBSD: redir.c,v 1.45 2016/05/08 20:14:27 kre Exp $   */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)redir.c    8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: redir.c,v 1.44 2016/05/08 03:51:15 kre Exp $");
+__RCSID("$NetBSD: redir.c,v 1.45 2016/05/08 20:14:27 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -219,8 +219,6 @@
                                (void)fcntl(i, F_SETFD, FD_CLOEXEC);
                        fd_rename(sv, fd, i);
                        INTON;
-               } else {
-                       close(fd);
                }
                if (fd == 0)
                        fd0_redirected++;
@@ -306,7 +304,8 @@
                        else
                                copyfd(redir->ndup.dupfd, fd, 1,
                                    (flags & REDIR_PUSH) != 0);
-               }
+               } else
+                       close(fd);
                INTON;
                return;
        case NHERE:



Home | Main Index | Thread Index | Old Index