Module Name: src
Committed By: christos
Date: Sun Mar 13 00:52:05 UTC 2016
Modified Files:
src/bin/sh: redir.c
Log Message:
Test for REDIR_KEEP in the non-copy case:
$ cat other1
#!/bin/sh
./other2 3>out
$ cat other2
#!/bin/sh
echo other2 1>&3
$ ./other1
To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 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.40 src/bin/sh/redir.c:1.41
--- src/bin/sh/redir.c:1.40 Sat Mar 12 16:35:13 2016
+++ src/bin/sh/redir.c Sat Mar 12 19:52:05 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: redir.c,v 1.40 2016/03/12 21:35:13 christos Exp $ */
+/* $NetBSD: redir.c,v 1.41 2016/03/13 00:52:05 christos 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.40 2016/03/12 21:35:13 christos Exp $");
+__RCSID("$NetBSD: redir.c,v 1.41 2016/03/13 00:52:05 christos Exp $");
#endif
#endif /* not lint */
@@ -246,7 +246,7 @@ openredirect(union node *redir, char mem
if (f != fd) {
copyfd(f, fd, 1, fd > 2 && (flags & REDIR_KEEP) == 0);
close(f);
- } else if (f > 2)
+ } else if (f > 2 && (flags & REDIR_KEEP) == 0)
(void)fcntl(f, F_SETFD, FD_CLOEXEC);
INTON;