Module Name:    src
Committed By:   kre
Date:           Sun May  8 20:14:27 UTC 2016

Modified Files:
        src/bin/sh: redir.c

Log Message:
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@


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/bin/sh/redir.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/sh/redir.c
diff -u src/bin/sh/redir.c:1.44 src/bin/sh/redir.c:1.45
--- src/bin/sh/redir.c:1.44	Sun May  8 03:51:15 2016
+++ src/bin/sh/redir.c	Sun May  8 20:14:27 2016
@@ -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 @@ redirect(union node *redir, int flags)
 				(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 @@ openredirect(union node *redir, char mem
 			else
 				copyfd(redir->ndup.dupfd, fd, 1,
 				    (flags & REDIR_PUSH) != 0);
-		}
+		} else
+			close(fd);
 		INTON;
 		return;
 	case NHERE:

Reply via email to