diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2007-03-20 06:07:58 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2007-03-20 06:07:58 +0000 |
commit | 061919b571196225aa964b3cdff1c5a56119e705 (patch) | |
tree | 1dd34ada51d99ede53ce7e34b9b48b41f1707059 /usr.bin | |
parent | 05b91e4c37b38750901b5d92041b5c985bbb51d5 (diff) |
Add line-buffering flag (-u).
OK deraadt@ and jmc@.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sed/main.c | 11 | ||||
-rw-r--r-- | usr.bin/sed/sed.1 | 21 |
2 files changed, 22 insertions, 10 deletions
diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index 5479917fd71..75fcbbf5e76 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.10 2006/10/09 00:23:57 tedu Exp $ */ +/* $OpenBSD: main.c,v 1.11 2007/03/20 06:07:57 ray Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -38,7 +38,7 @@ static const char copyright[] = "@(#) Copyright (c) 1992, 1993\n\ The Regents of the University of California. All rights reserved.\n"; /* from: static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/3/94"; */ -static const char rcsid[] = "$OpenBSD: main.c,v 1.10 2006/10/09 00:23:57 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: main.c,v 1.11 2007/03/20 06:07:57 ray Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -104,7 +104,7 @@ main(int argc, char *argv[]) int c, fflag; fflag = 0; - while ((c = getopt(argc, argv, "ae:f:n")) != -1) + while ((c = getopt(argc, argv, "ae:f:nu")) != -1) switch (c) { case 'a': aflag = 1; @@ -120,10 +120,13 @@ main(int argc, char *argv[]) case 'n': nflag = 1; break; + case 'u': + setlinebuf(stdout); + break; default: case '?': (void)fprintf(stderr, -"usage:\tsed script [-an] [file ...]\n\tsed [-an] [-e script] ... [-f script_file] ... [file ...]\n"); +"usage:\tsed script [-anu] [file ...]\n\tsed [-anu] [-e script] ... [-f script_file] ... [file ...]\n"); exit(1); } argc -= optind; diff --git a/usr.bin/sed/sed.1 b/usr.bin/sed/sed.1 index 3e26926d95c..4012330b73f 100644 --- a/usr.bin/sed/sed.1 +++ b/usr.bin/sed/sed.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sed.1,v 1.25 2006/10/26 20:19:12 jmc Exp $ +.\" $OpenBSD: sed.1,v 1.26 2007/03/20 06:07:57 ray Exp $ .\" .\" Copyright (c) 1992, 1993 .\" The Regents of the University of California. All rights reserved. @@ -40,11 +40,11 @@ .Nd stream editor .Sh SYNOPSIS .Nm sed -.Op Fl an +.Op Fl anu .Ar command .Op Ar file ... .Nm sed -.Op Fl an +.Op Fl anu .Op Fl e Ar command .Op Fl f Ar command_file .Op Ar file ... @@ -97,6 +97,14 @@ all of the commands have been applied to it. The .Fl n option suppresses this behavior. +.It Fl u +Force output to be line buffered, +printing each line as it becomes available. +By default, output is line buffered when standard output is a terminal +and block buffered otherwise. +See +.Xr setbuf 3 +for a more detailed explanation. .El .Pp The form of a @@ -497,6 +505,7 @@ option on the command line. .Xr ed 1 , .Xr grep 1 , .Xr regex 3 , +.Xr setbuf 3 , .Xr re_format 7 .Pp "SED \(em A Non-interactive Text Editor", @@ -508,9 +517,9 @@ utility is compliant with the .St -p1003.1-2004 specification. .Pp -The flag -.Op Fl a -is an extension to the specification. +The flags +.Op Fl au +are extensions to the specification. .Pp The use of newlines to separate multiple commands on the command line is non-portable; |