tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: sed -u option



In article <20140613.040312.453264829.yyamano%kt.rim.or.jp@localhost>,
Yuji Yamano  <yyamano%kt.rim.or.jp@localhost> wrote:
>Hi!
>
>I just found our sed supports -l option.
>How about adding -u option for GNU and OpenBSD compatibility?

OpenBSD:
-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
setbuf(3) for a more detailed explanation.

GNU:

-u
--unbuffered
Buffer both input and output as minimally as practical. (This is
particularly useful if the input is coming from the likes of `tail
-f', and you wish to see the transformed output as soon as possible.)

I think we should go the GNU way, since this is more mnemonic and
useful.

christos

>
>-- Yuji Yamano
>
>Index: main.c
>===================================================================
>RCS file: /cvsroot/src/usr.bin/sed/main.c,v
>retrieving revision 1.24
>diff -u -r1.24 main.c
>--- main.c     6 Jun 2014 12:46:54 -0000       1.24
>+++ main.c     12 Jun 2014 18:52:34 -0000
>@@ -137,7 +137,7 @@
>       fflag = 0;
>       inplace = NULL;
> 
>-      while ((c = getopt(argc, argv, "EI::ae:f:i::lnr")) != -1)
>+      while ((c = getopt(argc, argv, "EI::ae:f:i::lnru")) != -1)
>               switch (c) {
>               case 'r':               /* Gnu sed compat */
>               case 'E':
>@@ -165,6 +165,7 @@
>                       inplace = optarg ? optarg : __UNCONST("");
>                       ispan = 0;      /* don't span across input files */
>                       break;
>+              case 'u':               /* Gnu and OpenBSD sed compat */
>               case 'l':
> #ifdef _IOLBF
>                       c = setvbuf(stdout, NULL, _IOLBF, 0);
>@@ -209,8 +210,8 @@
> usage(void)
> {
>       (void)fprintf(stderr, "%s\n%s\n",
>-              "usage: sed script [-Ealn] [-i extension] [file ...]",
>-              "       sed [-Ealn] [-i extension] [-e script] ... [-f 
>script_file]
>... [file ...]");
>+              "usage: sed script [-Ealnru] [-i extension] [file ...]",
>+              "       sed [-Ealnru] [-i extension] [-e script] ... [-f 
>script_file]
>... [file ...]");
>       exit(1);
> }
> 
>Index: sed.1
>===================================================================
>RCS file: /cvsroot/src/usr.bin/sed/sed.1,v
>retrieving revision 1.34
>diff -u -r1.34 sed.1
>--- sed.1      6 Jun 2014 14:36:38 -0000       1.34
>+++ sed.1      12 Jun 2014 18:52:34 -0000
>@@ -40,11 +40,11 @@
> .Nd stream editor
> .Sh SYNOPSIS
> .Nm
>-.Op Fl Ealnr
>+.Op Fl Ealnru
> .Ar command
> .Op Ar
> .Nm
>-.Op Fl Ealnr
>+.Op Fl Ealnru
> .Op Fl e Ar command
> .Op Fl f Ar command_file
> .Op Fl I Op Ar extension
>@@ -149,6 +149,10 @@
> Same as
> .Fl E
> for compatibility with GNU sed.
>+.It Fl u
>+Same as
>+.Fl l
>+for compatibility with GNU sed.
> .El
> .Pp
> The form of a
>@@ -599,9 +603,9 @@
> specification.
> .Pp
> The
>-.Fl E , I , a
>+.Fl E , I , a , i , l , r
> and
>-.Fl i
>+.Fl u 
> options, the prefixing
> .Dq \&+
> in the second member of an address range,
>
>





Home | Main Index | Thread Index | Old Index