On Mon, 27 Nov 2017 10:41:05 +0000, Jason McIntyre wrote:
> On Sun, Nov 26, 2017 at 07:47:01PM +0000, kshe wrote:
> > Hi,
> >
> > I noticed a certain number of inaccuracies within the manual page for
> > sed.  The diff below corrects to most obvious ones, although further
> > improvements are certainly possible.
> >
> > Additionally, the script given in the EXAMPLES section being already
> > quite unnecessarily contrived (as it does in twelve commands what could
> > be done in merely two), I took the opportunity to make it slightly
> > simpler and easier to read.
>
> morning.
>
> this diff is too much for review (at least for me anyway). could you
> parcel it up into some logical parts and resend?

These changes fall into five different categories.  The manually split
diffs below include a succinct description of each, in the hope of
making review easier.

1.  Remove false claims about restrictions that do not exist in POSIX
nor in this implementation.  Also clarify that label names may be
terminated by semicolons, although not specified by the standard.

Index: sed.1
===================================================================
RCS file: /cvs/src/usr.bin/sed/sed.1,v
retrieving revision 1.50
diff -u -p -r1.50 sed.1
--- sed.1       19 Jul 2017 21:28:19 -0000      1.50
+++ sed.1       17 Nov 2017 02:50:36 -0000
@@ -57,10 +57,9 @@ utility reads the specified files, or th
 are specified, modifying the input as specified by a list of commands.
 The input is then written to the standard output.
 .Pp
-A single command may be specified as the first argument to
-.Nm sed .
-Multiple commands may be specified
-separated by newlines or semicolons,
+Commands are separated by newlines or semicolons and may be specified
+either as the first argument to
+.Nm
 or by using the
 .Fl e
 or
@@ -95,7 +94,6 @@ to the list of commands.
 Append the editing commands found in the file
 .Ar command_file
 to the list of commands.
-The editing commands should each be listed on a separate line.
 .It Fl i Ns Op Ar extension
 Edit files in place, saving backups with the specified
 .Ar extension .
@@ -264,23 +262,22 @@ Files are created
 before any input processing begins.
 .Pp
 The
-.Ic b ,
-.Ic r ,
-.Ic s ,
-.Ic t ,
-.Ic w ,
-.Ic y ,
+.Ar label
+argument to the
+.Ic \&: ,
+.Ic b
 and
-.Ic \&:
-functions all accept additional arguments.
-The synopses below indicate which arguments have to be separated from
+.Ic t
+commands may be terminated by either a newline or a semicolon,
+although the former should be prefered if portability is desired.
+.Pp
+For functions that accept additional arguments,
+the synopses below indicate which have to be separated from
 the function letters by whitespace characters.
 .Pp
 Functions can be combined to form a
-.Em function list ,
-a list of
-.Nm
-functions each followed by a newline, as follows:
+.Em function list
+as follows:
 .Bd -literal -offset indent
 { function
   function
@@ -569,12 +565,6 @@ specification.
 The flags
 .Op Fl aEiru
 are extensions to that specification.
-.Pp
-The use of newlines to separate multiple commands on the command line
-is non-portable;
-the use of newlines to separate multiple commands within a command file
-.Pq Fl f Ar command_file
-is portable.
 .Sh HISTORY
 A
 .Nm
@@ -583,8 +573,6 @@ command appeared in
 .Sh CAVEATS
 The use of semicolons to separate multiple commands
 is not permitted for the following commands:
-.Ic a , b , c ,
-.Ic i , r , t ,
-.Ic w , \&: ,
+.Ic a , c , i , r , w
 and
 .Ic # .

2.  Specifying a file name for commands reading from and writing to
files is obviously not optional.

        $ sed w
        sed: 1: "w": filename expected

Index: sed.1
===================================================================
RCS file: /cvs/src/usr.bin/sed/sed.1,v
retrieving revision 1.50
diff -u -p -r1.50 sed.1
--- sed.1       19 Jul 2017 21:28:19 -0000      1.50
+++ sed.1       17 Nov 2017 02:50:36 -0000
@@ -255,7 +253,7 @@ as well as the
 flag to the
 .Ic s
 function,
-take an optional
+take a
 .Ar file
 parameter,
 which should be separated from the function or flag by whitespace.

3.  Correct the description of the `y' command: a backslash only escapes
specific characters.

Index: sed.1
===================================================================
RCS file: /cvs/src/usr.bin/sed/sed.1,v
retrieving revision 1.50
diff -u -p -r1.50 sed.1
--- sed.1       19 Jul 2017 21:28:19 -0000      1.50
+++ sed.1       17 Nov 2017 02:50:36 -0000
@@ -486,10 +483,14 @@ Within
 .Ar string1
 and
 .Ar string2 ,
-a backslash followed by any character other than a newline is that literal
-character, and a backslash followed by an
+a backslash followed by another backslash
+is replaced by a single backslash,
+a backslash followed by an
 .Sq n
-is replaced by a newline character.
+is replaced by a newline character,
+and a backslash followed by the delimiting character
+is replaced by a that character,
+causing it to be treated literally.
 .It [0addr] Ns Ic \&: Ns Ar label
 This function does nothing; it bears a
 .Ar label

4.  Remove superfluous complexity from the example.

Index: sed.1
===================================================================
RCS file: /cvs/src/usr.bin/sed/sed.1,v
retrieving revision 1.50
diff -u -p -r1.50 sed.1
--- sed.1       19 Jul 2017 21:28:19 -0000      1.50
+++ sed.1       17 Nov 2017 02:50:36 -0000
@@ -538,20 +539,15 @@ $ sed -n '
 /./ {
     p
     d
-    }
+}
 # Write a single empty line, then look for more empty lines.
-/^$/    p
-# Get the next line, discard the held <newline> (empty line),
-# and look for more empty lines.
+p
 :Empty
-/^$/    {
-    N
-    s/.//
-    b Empty
-    }
+n
+/^$/b Empty
 # Write the non-empty line before going back to search
 # for the first in a set of empty lines.
-    p
+p
 \&'
 .Ed
 .Sh SEE ALSO

5.  Fluff.

Index: sed.1
===================================================================
RCS file: /cvs/src/usr.bin/sed/sed.1,v
retrieving revision 1.50
diff -u -p -r1.50 sed.1
--- sed.1       19 Jul 2017 21:28:19 -0000      1.50
+++ sed.1       17 Nov 2017 02:50:36 -0000
@@ -297,11 +294,11 @@ in which case they are applied only to l
 .Em not
 selected by the addresses.
 .Bl -tag -width Ds
-.It [2addr] Ar function-list
+.It [2addr] Ns Ar function-list
 Execute
 .Ar function-list
 only when the pattern space is selected.
-.It Xo [1 addr] Ic a Ns \e
+.It Xo [1addr] Ns Ic a Ns \e
 .br
 .Ar text
 .Xc
@@ -317,7 +314,7 @@ Branch to the
 function with the specified
 .Ar label .
 If the label is not specified, branch to the end of the script.
-.It Xo [2addr] Ic c Ns \e
+.It Xo [2addr] Ns Ic c Ns \e
 .br
 .Ar text
 .Xc
@@ -342,7 +339,7 @@ pattern space.
 .It [2addr] Ns Ic H
 Append a newline character followed by the contents of the pattern space
 to the hold space.
-.It Xo [1addr] Ic i Ns \e
+.It Xo [1addr] Ns Ic i Ns \e
 .br
 .Ar text
 .Xc
@@ -413,8 +410,8 @@ in the pattern space.
 Any character other than backslash or newline can be used instead of
 a slash to delimit the regular expression and the replacement.
 Within the regular expression and the replacement,
-the regular expression delimiter itself can be used as
-a literal character if it is preceded by a backslash.
+the delimiter itself can be used as a literal character
+if it is preceded by a backslash.
 .Pp
 An ampersand
 .Pq Ql &
@@ -522,7 +523,7 @@ output from the
 function is formatted to the given width in columns.
 Otherwise,
 .Nm
-defaults to the terminal with, or 80 columns if the output is not a terminal.
+defaults to the terminal width, or 80 columns if the output is not a terminal.
 .El
 .Sh EXIT STATUS
 .Ex -std sed

Regards,

kshe

Reply via email to