diff options
author | steve <steve@FreeBSD.org> | 1996-12-14 06:20:03 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 1996-12-14 06:20:03 +0000 |
commit | c58aca035e2c61510b619368861598623eb95e52 (patch) | |
tree | 049d84189a59de29d49254b609a318b17ee59387 /bin/sh/redir.c | |
parent | a958416f1b4a022c358b94db0b8e6bcc6cb54ee0 (diff) | |
download | FreeBSD-src-c58aca035e2c61510b619368861598623eb95e52.zip FreeBSD-src-c58aca035e2c61510b619368861598623eb95e52.tar.gz |
Merge in NetBSD mods and -Wall cleaning.
Obtained from: NetBSD, me
Diffstat (limited to 'bin/sh/redir.c')
-rw-r--r-- | bin/sh/redir.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/bin/sh/redir.c b/bin/sh/redir.c index ae2d335..89e68d3 100644 --- a/bin/sh/redir.c +++ b/bin/sh/redir.c @@ -33,11 +33,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: redir.c,v 1.4 1995/10/21 00:47:31 joerg Exp $ + * $Id: redir.c,v 1.5 1996/09/01 10:21:36 peter Exp $ */ #ifndef lint -static char sccsid[] = "@(#)redir.c 8.2 (Berkeley) 5/4/95"; +static char const sccsid[] = "@(#)redir.c 8.2 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/types.h> @@ -103,7 +103,7 @@ redirect(redir, flags) struct redirtab *sv = NULL; int i; int fd; - char memory[10]; /* file descriptors to write to memory */ + char memory[10]; /* file descriptors to write to memory */ for (i = 10 ; --i >= 0 ; ) memory[i] = 0; @@ -119,7 +119,7 @@ redirect(redir, flags) fd = n->nfile.fd; if ((n->nfile.type == NTOFD || n->nfile.type == NFROMFD) && n->ndup.dupfd == fd) - continue; /* redirect from/to myself */ + continue; /* redirect from/to same file descriptor */ if ((flags & REDIR_PUSH) && sv->renamed[fd] == EMPTY) { INTOFF; if ((i = copyfd(fd, 10)) != EMPTY) { @@ -335,16 +335,18 @@ clearredir() { */ int -copyfd(from, to) +copyfd(from, to) int from; int to; { int newfd; newfd = fcntl(from, F_DUPFD, to); - if (newfd < 0 && errno == EMFILE) - return EMPTY; - if (newfd < 0) - error("%d: %s", from, strerror(errno)); + if (newfd < 0) { + if (errno == EMFILE) + return EMPTY; + else + error("%d: %s", from, strerror(errno)); + } return newfd; } |