diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-12-08 22:43:55 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-12-08 22:43:55 +0000 |
commit | f97c20e0f658aac03886b36b2ccbd1c9d5ed2eb2 (patch) | |
tree | 57b8f90457f613239fdcfe6dbda318a77c9b494f | |
parent | df2441f77a9130d784fdeba12e6c2c65586c4630 (diff) |
Treat a file name of "-" as either stdin or stdout, depending on position.
-rw-r--r-- | usr.bin/uniq/uniq.1 | 8 | ||||
-rw-r--r-- | usr.bin/uniq/uniq.c | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/uniq/uniq.1 b/usr.bin/uniq/uniq.1 index 4d12faeebfe..94cef59794a 100644 --- a/usr.bin/uniq/uniq.1 +++ b/usr.bin/uniq/uniq.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: uniq.1,v 1.5 2000/03/11 21:40:07 aaron Exp $ +.\" $OpenBSD: uniq.1,v 1.6 2002/12/08 22:43:54 millert Exp $ .\" $NetBSD: uniq.1,v 1.5 1994/12/06 07:51:15 jtc Exp $ .\" .\" Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ .\" .\" @(#)uniq.1 8.1 (Berkeley) 6/6/93 .\" -.Dd June 6, 1993 +.Dd December 8, 2002 .Dt UNIQ 1 .Os .Sh NAME @@ -113,6 +113,10 @@ Don't output lines that are repeated in the input. If additional arguments are specified on the command line, the first such argument is used as the name of an input file, the second is used as the name of an output file. +A file name of +.Ql - +denotes the standard input or the standard output (depending on its position +on the command line. .Pp The .Nm diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c index 5592c378d37..6437e8bfc7c 100644 --- a/usr.bin/uniq/uniq.c +++ b/usr.bin/uniq/uniq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uniq.c,v 1.11 2002/12/08 06:40:44 millert Exp $ */ +/* $OpenBSD: uniq.c,v 1.12 2002/12/08 22:43:54 millert Exp $ */ /* $NetBSD: uniq.c,v 1.7 1995/08/31 22:03:48 jtc Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)uniq.c 8.3 (Berkeley) 5/4/95"; #endif -static char rcsid[] = "$OpenBSD: uniq.c,v 1.11 2002/12/08 06:40:44 millert Exp $"; +static char rcsid[] = "$OpenBSD: uniq.c,v 1.12 2002/12/08 22:43:54 millert Exp $"; #endif /* not lint */ #include <errno.h> @@ -200,6 +200,8 @@ file(char *name, char *mode) { FILE *fp; + if (strcmp(name, "-") == 0) + return(*mode == 'r' ? stdin : stdout); if ((fp = fopen(name, mode)) == NULL) err(1, "%s", name); return(fp); |