On Fri, Jun 26, 2020 at 09:28:00PM -0600, Todd C. Miller wrote: > On Fri, 26 Jun 2020 23:56:23 +0200, Klemens Nanni wrote: > > > How about adding something like "Therefore, FS should be set with -F or > > in a BEGIN block before input is read." as second sentence in this > > paragraph? > > That whole section is missing important details. I've tried to add > the missing info without being too repetitive. > > - todd > > Index: usr.bin/awk/awk.1 > =================================================================== > RCS file: /cvs/src/usr.bin/awk/awk.1,v > retrieving revision 1.54 > diff -u -p -u -r1.54 awk.1 > --- usr.bin/awk/awk.1 26 Jun 2020 21:50:06 -0000 1.54 > +++ usr.bin/awk/awk.1 27 Jun 2020 03:25:48 -0000 > @@ -129,27 +129,25 @@ and newlines are used as field separator > .Va FS ) . > This is convenient when working with multi-line records. > .Pp > -An input line is normally made up of fields separated by whitespace, > -or by the regular expression > -.Va FS . > +An input line is normally made up of fields split based on the value > +of the field separator > +.Va FS > +at the time the line is read.
i'm not sure it reads better when we switch the emphasis from whitespace to FS. i think it's better that people see how it normally works, then the gories about FS. so i'd have kept the first part of the sentence, but maybe reworked the FS bit. > The fields are denoted > .Va $1 , $2 , ... , > while > .Va $0 > refers to the entire line. > -If > .Va FS > -is null, the input line is split into one field per character. > -Lines are split into fields using the value of > +may be set to either a single character or a regular expression. > +As as special case, if > .Va FS > -at the time the line is read. > -Because of this, > +is a single space > +.Pq the default , > +fields will be split by one or more whitespace characters. > +If > .Va FS > -is usually set via the > -.Fl F > -option or inside of a > -.Ic BEGIN > -block. > +is null, the input line is split into one field per character. > .Pp > Normally, any number of blanks separate fields. > In order to set the field separator to a single blank, use the > @@ -171,6 +169,11 @@ as the field separator, use the > .Fl F > option with a value of > .Sq [t] . > +The field separator is usually set via the > +.Fl F > +option or from inside of a that sounds odd, but it may be a US/UK thing: i would say either "from inside a block" or "from the inside of a block". jmc > +.Ic BEGIN > +block so that it takes effect before the input is read. > .Pp > A pattern-action statement has the form: > .Pp > @@ -407,9 +410,9 @@ The name of the current input file. > .It Va FNR > Ordinal number of the current record in the current file. > .It Va FS > -Regular expression used to separate fields; also settable > -by option > -.Fl F Ar fs . > +Regular expression used to separate fields (default whitespace); > +also settable by option > +.Fl F Ar fs > .It Va NF > Number of fields in the current record. > .Va $NF >