Re: CVS commit: src/external/historical/nawk/bin
On Wed, Jul 06, 2022 at 20:59:43 -, Christos Zoulas wrote: > >> Thanks uwe! Are you planning to upstream all these changes? > > > >This is our mdocified bin/awk.1, upstream is dist/awk.1 that is > >-man-old, so I'm not sure how to proceed. Also most of the changes I > >made are strictly mdoc related. POSIX has quite a bit more elaborate > >awk man page that spells out many details, importing some more of that > >might be good but it's somewhat heavy, prescriptive prose and requires > >some editing for better readibility, IMHO - not something I feel > >qualified to do. > > Ok thanks. I will check with upstream on replacing theirs with ours. Not without some editorial efforts. OpenBSD has their own additions to the man page, e.g. documenting that literal space as FS value (the default) is magic, etc. It would be nice to collate those. I don't have a fresh FreBSD tree handy to check their version. -uwe
re: CVS commit: src/external/historical/nawk/bin
Christos Zoulas writes: > In article <20220705184003.aa082f...@cvs.netbsd.org>, > Valeriy E. Ushakov wrote: > >-=-=-=-=-=- > > > >Module Name: src > >Committed By:uwe > >Date:Tue Jul 5 18:40:03 UTC 2022 > > > >Modified Files: > > src/external/historical/nawk/bin: awk.1 > > > >Log Message: > >awk(1): consistent Capitalization. > > > > Thanks uwe! Are you planning to upstream all these changes? this version is our mandoc. the upstream version is old mdoc macros and you're the source of the original non-dist/ awk.1 :-) revision 1.1 date: 2010-08-26 07:57:16 -0700; author: christos; state: Exp; awk glue (there's no vendor branch for this file etc.) .mrg.
Re: CVS commit: src/external/historical/nawk/bin
In article , Valery Ushakov wrote: >On Tue, Jul 05, 2022 at 20:20:09 -, Christos Zoulas wrote: > >> In article <20220705184003.aa082f...@cvs.netbsd.org>, >> Valeriy E. Ushakov wrote: >> >-=-=-=-=-=- >> > >> >Module Name:src >> >Committed By: uwe >> >Date: Tue Jul 5 18:40:03 UTC 2022 >> > >> >Modified Files: >> >src/external/historical/nawk/bin: awk.1 >> > >> >Log Message: >> >awk(1): consistent Capitalization. >> >> Thanks uwe! Are you planning to upstream all these changes? > >This is our mdocified bin/awk.1, upstream is dist/awk.1 that is >-man-old, so I'm not sure how to proceed. Also most of the changes I >made are strictly mdoc related. POSIX has quite a bit more elaborate >awk man page that spells out many details, importing some more of that >might be good but it's somewhat heavy, prescriptive prose and requires >some editing for better readibility, IMHO - not something I feel >qualified to do. Ok thanks. I will check with upstream on replacing theirs with ours. christos
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 22:50:43 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Fix incomplete edit. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 22:50:43 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Fix incomplete edit. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.31 src/external/historical/nawk/bin/awk.1:1.32 --- src/external/historical/nawk/bin/awk.1:1.31 Tue Jul 5 22:20:55 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 22:50:43 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.31 2022/07/05 22:20:55 rillig Exp $ +.\" $NetBSD: awk.1,v 1.32 2022/07/05 22:50:43 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -22,7 +22,7 @@ .\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF .\" THIS SOFTWARE. .\" -.Dd December 19, 2019 +.Dd July 5, 2022 .Dt AWK 1 .Os .Sh NAME @@ -129,9 +129,9 @@ version on standard output and exit. .El .Pp An input line is normally made up of fields separated by white space, -or by the regular expression +or by the regular expression the built-in variable .Va FS -the built-in variable is set to. +is set to. If .Va FS is null, the input line is split into one field per character.
Re: CVS commit: src/external/historical/nawk/bin
On Tue, Jul 05, 2022 at 20:20:09 -, Christos Zoulas wrote: > In article <20220705184003.aa082f...@cvs.netbsd.org>, > Valeriy E. Ushakov wrote: > >-=-=-=-=-=- > > > >Module Name: src > >Committed By:uwe > >Date:Tue Jul 5 18:40:03 UTC 2022 > > > >Modified Files: > > src/external/historical/nawk/bin: awk.1 > > > >Log Message: > >awk(1): consistent Capitalization. > > Thanks uwe! Are you planning to upstream all these changes? This is our mdocified bin/awk.1, upstream is dist/awk.1 that is -man-old, so I'm not sure how to proceed. Also most of the changes I made are strictly mdoc related. POSIX has quite a bit more elaborate awk man page that spells out many details, importing some more of that might be good but it's somewhat heavy, prescriptive prose and requires some editing for better readibility, IMHO - not something I feel qualified to do. PS: $ nroff -C -man-old man/1/charon Hashtag TrueStory, hashtag NewOptimism -uwe
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: rillig Date: Tue Jul 5 22:20:55 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk.1: add articles, remove 'shall' To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.30 src/external/historical/nawk/bin/awk.1:1.31 --- src/external/historical/nawk/bin/awk.1:1.30 Tue Jul 5 22:07:20 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 22:20:55 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.30 2022/07/05 22:07:20 rillig Exp $ +.\" $NetBSD: awk.1,v 1.31 2022/07/05 22:20:55 rillig Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -129,9 +129,9 @@ version on standard output and exit. .El .Pp An input line is normally made up of fields separated by white space, -or by regular expression +or by the regular expression .Va FS -built-in variable is set to. +the built-in variable is set to. If .Va FS is null, the input line is split into one field per character. @@ -344,17 +344,17 @@ and .Ar expr may be literal names or parenthesized expressions; identical string values in different statements denote the same open file. -For that purpose file names +For that purpose the file names .Pa /dev/stdin , .Pa /dev/stdout , and .Pa /dev/stderr -refer to program's +refer to the program's .Va stdin , .Va stdout , and .Va stderr -respecively (and are unrelated to +respectively (and are unrelated to the .Xr fd 4 devices of the same names). .Ss Mathematical and Numeric Functions @@ -687,7 +687,7 @@ and the .Ic BEGIN action contains no .Ic getline -statement, awk shall exit without reading its input when the last +statement, awk exits without reading its input when the last statement in the last .Ic BEGIN action is executed. @@ -697,7 +697,7 @@ or only actions with the patterns .Ic BEGIN and .Ic END , -the input shall be read before the statements in the +the input is read before the statements in the .Ic END actions are executed. .Ss Built-in Variables
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: rillig Date: Tue Jul 5 22:20:55 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk.1: add articles, remove 'shall' To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: rillig Date: Tue Jul 5 22:07:20 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk.1: fix typo To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.29 src/external/historical/nawk/bin/awk.1:1.30 --- src/external/historical/nawk/bin/awk.1:1.29 Tue Jul 5 18:40:03 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 22:07:20 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.29 2022/07/05 18:40:03 uwe Exp $ +.\" $NetBSD: awk.1,v 1.30 2022/07/05 22:07:20 rillig Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -763,7 +763,7 @@ Print lines longer than 72 characters. .Fn length defaults to .Li $ Ns Va 0 -and the empty parens can aslo be omitted in this case: +and the empty parens can also be omitted in this case: .Pp .Dl length > 72 .Pp
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: rillig Date: Tue Jul 5 22:07:20 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk.1: fix typo To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/external/historical/nawk/bin
In article <20220705184003.aa082f...@cvs.netbsd.org>, Valeriy E. Ushakov wrote: >-=-=-=-=-=- > >Module Name: src >Committed By: uwe >Date: Tue Jul 5 18:40:03 UTC 2022 > >Modified Files: > src/external/historical/nawk/bin: awk.1 > >Log Message: >awk(1): consistent Capitalization. > Thanks uwe! Are you planning to upstream all these changes? Best, christos
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 18:40:03 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): consistent Capitalization. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.28 src/external/historical/nawk/bin/awk.1:1.29 --- src/external/historical/nawk/bin/awk.1:1.28 Tue Jul 5 18:18:48 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 18:40:03 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.28 2022/07/05 18:18:48 uwe Exp $ +.\" $NetBSD: awk.1,v 1.29 2022/07/05 18:40:03 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -479,7 +479,7 @@ and .Fn gsub return the number of replacements. .It Fn index s t -the position in +The position in .Ar s where the string .Ar t @@ -491,13 +491,13 @@ occurs, or 0 if it does not. .Fa string .Oc Ns \&) .Oc Xc -the length of its argument +The length of its argument taken as a string, or of .Li $ Ns Va 0 if no argument. .It Fn match s r -the position in +The position in .Ar s where the regular expression .Ar r @@ -511,7 +511,7 @@ are set to the position and length of th .Fa s a\| .Oo Fa fs .Oc Fc Xc -splits the string +Splits the string .Ar s into array elements .Ar a Ns Li [1] , @@ -540,7 +540,7 @@ format .Fa r s\| .Oo Fa t .Oc Fc Xc -substitutes +Substitutes .Ar s for the first occurrence of the regular expression .Ar r @@ -568,12 +568,12 @@ is omitted, the rest of .Ar s is returned. .It Fn tolower str -returns a copy of +Returns a copy of .Ar str with all upper-case characters translated to their corresponding lower-case equivalents. .It Fn toupper str -returns a copy of +Returns a copy of .Ar str with all lower-case characters translated to their corresponding upper-case equivalents. @@ -616,9 +616,9 @@ for the format conversions which are sup .Ss Other built-in functions .Bl -tag -width Fn .It Fn system cmd -executes +Executes .Ar cmd -and returns its exit status +and returns its exit status. .El .Ss Patterns Patterns are arbitrary Boolean combinations @@ -736,11 +736,11 @@ output record separator (default newline .It Va RS input record separator (default newline) .It Va RSTART -Position of the first character matched by +position of the first character matched by .Fn match ; -0 if not match. +0 if no match. .It Va RLENGTH -Length of the string matched by +length of the string matched by .Fn match ; \-1 if no match. .It Va SUBSEP
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 18:40:03 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): consistent Capitalization. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 18:18:48 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Empty parens of length() be omitted. Mark up length[([string])] description accordingly (like POSIX does). Adjust the length example to demonstrate this. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.27 src/external/historical/nawk/bin/awk.1:1.28 --- src/external/historical/nawk/bin/awk.1:1.27 Tue Jul 5 17:58:47 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 18:18:48 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.27 2022/07/05 17:58:47 uwe Exp $ +.\" $NetBSD: awk.1,v 1.28 2022/07/05 18:18:48 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -484,9 +484,13 @@ the position in where the string .Ar t occurs, or 0 if it does not. -.It Xo Fo length -.Oo Fa string -.Oc Fc Xc +.\" .Fn cannot be told to omit parens, so piece this together manually +.\" to mark empty parens optional too +.It Xo Ic length\^ Ns Oo \&( Ns +.Oo Ns +.Fa string +.Oc Ns \&) +.Oc Xc the length of its argument taken as a string, or of @@ -755,9 +759,13 @@ Parameters are local to the function; al Thus local variables may be created by providing excess parameters in the function definition. .Sh EXAMPLES -Print lines longer than 72 characters: +Print lines longer than 72 characters. +.Fn length +defaults to +.Li $ Ns Va 0 +and the empty parens can aslo be omitted in this case: .Pp -.Dl length($0) > 72 +.Dl length > 72 .Pp Print first two fields in opposite order: .Pp
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 18:18:48 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Empty parens of length() be omitted. Mark up length[([string])] description accordingly (like POSIX does). Adjust the length example to demonstrate this. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 17:58:47 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Another echo(1) example that demonstrates field assignment To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.26 src/external/historical/nawk/bin/awk.1:1.27 --- src/external/historical/nawk/bin/awk.1:1.26 Tue Jul 5 16:59:41 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 17:58:47 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.26 2022/07/05 16:59:41 uwe Exp $ +.\" $NetBSD: awk.1,v 1.27 2022/07/05 17:58:47 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -788,6 +788,12 @@ BEGIN { } .Ed .Pp +Another way to do the same that demonstrates field assignment and +.Li $ Ns Va 0 +re-evaluation: +.Pp +.Dl BEGIN { for (i = 1; i < ARGC; ++i) $i = ARGV[i]; print } +.Pp Print an error message to standard error: .Bd -literal -offset indent { print "error!" > "/dev/stderr" }
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 17:58:47 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Another echo(1) example that demonstrates field assignment To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 16:59:41 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Use .It Xo Fo trick to format optional arguments correctly To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.25 src/external/historical/nawk/bin/awk.1:1.26 --- src/external/historical/nawk/bin/awk.1:1.25 Tue Jul 5 16:21:35 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 16:59:41 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.25 2022/07/05 16:21:35 uwe Exp $ +.\" $NetBSD: awk.1,v 1.26 2022/07/05 16:59:41 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -407,7 +407,10 @@ and returns the previous seed. .Ss String Functions AWK has the following string functions built-in: .Bl -tag -width Fn -.It Fn gensub r s h [t] +.It Xo Fo gensub +.Fa r s h\| +.Oo Fa t +.Oc Fc Xc Search the target string .Ar t for matches of the regular expression @@ -463,7 +466,10 @@ supported by GNU are .Em not supported at this moment. -.It Fn gsub r s "[t]" +.It Xo Fo gsub +.Fa r s\| +.Oo Fa t +.Oc Fc Xc Same as .Fn sub except that all occurrences of the regular expression @@ -478,7 +484,9 @@ the position in where the string .Ar t occurs, or 0 if it does not. -.It Fn length "[string]" +.It Xo Fo length +.Oo Fa string +.Oc Fc Xc the length of its argument taken as a string, or of @@ -495,7 +503,10 @@ The variables and .Va RLENGTH are set to the position and length of the matched string. -.It Fn split s a "[fs]" +.It Xo Fo split +.Fa s a\| +.Oo Fa fs +.Oc Fc Xc splits the string .Ar s into array elements @@ -521,7 +532,10 @@ according to the .Xr printf 3 format .Ar fmt . -.It Fn sub r s "[t]" +.It Xo Fo sub +.Fa r s\| +.Oo Fa t +.Oc Fc Xc substitutes .Ar s for the first occurrence of the regular expression @@ -533,7 +547,10 @@ If is not given, .Li $ Ns Va 0 is used. -.It Fn substr s m [n] +.It Xo Fo substr +.Fa s m\| +.Oo Fa n +.Oc Fc Xc Returns the at most .Ar n\^ Ns No -character substring of @@ -568,7 +585,11 @@ Returns the value of time in seconds sin Unix Epoch (midnight, January 1, 1970, Coordinated Universal Time). See also .Xr time 3 . -.It Fn strftime "[format [, timestamp]]" +.\"It Fn strftime "[format [, timestamp]]" +.It Xo Fo strftime +.Oo Fa format\| +.Oo Fa timestamp\| +.Oc Oc Fc Xc Formats the time .Ar timestamp according to the string
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 16:59:41 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Use .It Xo Fo trick to format optional arguments correctly To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 16:21:35 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Document /dev/stdin magic names (NB: unrelated to fd(4)) To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.24 src/external/historical/nawk/bin/awk.1:1.25 --- src/external/historical/nawk/bin/awk.1:1.24 Tue Jul 5 15:56:42 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 16:21:35 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.24 2022/07/05 15:56:42 uwe Exp $ +.\" $NetBSD: awk.1,v 1.25 2022/07/05 16:21:35 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -344,6 +344,19 @@ and .Ar expr may be literal names or parenthesized expressions; identical string values in different statements denote the same open file. +For that purpose file names +.Pa /dev/stdin , +.Pa /dev/stdout , +and +.Pa /dev/stderr +refer to program's +.Va stdin , +.Va stdout , +and +.Va stderr +respecively (and are unrelated to +.Xr fd 4 +devices of the same names). .Ss Mathematical and Numeric Functions AWK has the following mathematical and numerical functions built-in: .Bl -tag -width Fn
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 16:21:35 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Document /dev/stdin magic names (NB: unrelated to fd(4)) To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 15:56:42 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Factor out output redirection for print and printf. This makes the description way less cluttered and explicitly shows "| expr" (that was mentioned, but not written out) and ">> file" (that was not even mentioned at all). Adapted from the POSIX wording, but doesn't bring over all the detailed verbiage. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.23 src/external/historical/nawk/bin/awk.1:1.24 --- src/external/historical/nawk/bin/awk.1:1.23 Tue Jul 5 15:35:53 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 15:56:42 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.23 2022/07/05 15:35:53 uwe Exp $ +.\" $NetBSD: awk.1,v 1.24 2022/07/05 15:56:42 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -313,33 +313,37 @@ each call of .Ic getline returns the next line of output from .Ar expr . -.It Ic print Oo Ar expr-list Oc Op Ic > Ar file -The -.Ic print -statement prints its arguments on the standard output (or to a file -if -.Ic \*[Gt] file -or to a pipe if -.Ic \&| Ar expr -is present), -separated by the current output field separator +.It Ic print Oo Ar expr-list Oc Op Ar redirection +Print arguments separated by the current output field separator .Va OFS , and terminated by the output record separator .Va ORS . -Both -.Ar file -and -.Ar expr -may be literal names or parenthesized expressions; identical string values in -different statements denote the same open file. -.It Ic printf Ar format\| Ns Oo Ic \&, Ar expr-list Oc Op Ic \*[Gt] Ar file +.It Ic printf Ar format\| Ns Oo Ic \&, Ar expr-list Oc Op Ar redirection Format and print its expression list according to .Ar format . See .Xr printf 3 for list of supported formats and their meaning. .El +.Pp +Both +.Ic print +and +.Ic printf +statements write to standard output by default. +The output is written to the file or pipe specified by +.Ar redirection +if one is supplied, as follows: +.Ic \&> Ar file , "" +.Ic \&>> Ar file , No or +.Ic \&| Ar expr . +Both +.Ar file +and +.Ar expr +may be literal names or parenthesized expressions; identical string values in +different statements denote the same open file. .Ss Mathematical and Numeric Functions AWK has the following mathematical and numerical functions built-in: .Bl -tag -width Fn
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 15:56:42 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Factor out output redirection for print and printf. This makes the description way less cluttered and explicitly shows "| expr" (that was mentioned, but not written out) and ">> file" (that was not even mentioned at all). Adapted from the POSIX wording, but doesn't bring over all the detailed verbiage. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 15:35:53 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): A few more formatting tweaks to inlibe code bits and pieces To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.22 src/external/historical/nawk/bin/awk.1:1.23 --- src/external/historical/nawk/bin/awk.1:1.22 Tue Jul 5 15:28:02 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 15:35:53 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.22 2022/07/05 15:28:02 uwe Exp $ +.\" $NetBSD: awk.1,v 1.23 2022/07/05 15:35:53 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -167,7 +167,7 @@ An empty stands for .Li $ Ns Va 0 . String constants are quoted -.Em \&"\ \&" , +.Li \(dq\(dq , with the usual C escapes recognized within. Expressions take on string or numeric values as appropriate, and are built using the @@ -175,14 +175,14 @@ and are built using the (see next subsection). Variables may be scalars, array elements (denoted -.Va x[i] ) +.Va x\| Ns Li [ Ns Va i\^ Ns Li ] ) or fields. Variables are initialized to the null string. Array subscripts may be any string, not necessarily numeric; this allows for a form of associative memory. Multiple subscripts such as -.Va [i,j,k] +.Li [ Ns Ar i Ns Li \&, Ns Ar j Ns Li \&, Ns Ar k Ns Li ] are permitted; the constituents are concatenated, separated by the value of .Va SUBSEP . @@ -199,9 +199,9 @@ Field reference Increment and decrement, can be used either as postfix or prefix. .It Ic ^ Exponentiation (the -.Ic ** +.Ic **\^ form is also supported, and -.Ic **= +.Ic **\^= for the assignment operator). .It + \- \&! Unary plus, unary minus and logical negation.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 15:35:53 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): A few more formatting tweaks to inlibe code bits and pieces To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 15:28:02 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Fix editing accident in one of the previous commits. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.21 src/external/historical/nawk/bin/awk.1:1.22 --- src/external/historical/nawk/bin/awk.1:1.21 Tue Jul 5 15:27:14 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 15:28:02 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.21 2022/07/05 15:27:14 uwe Exp $ +.\" $NetBSD: awk.1,v 1.22 2022/07/05 15:28:02 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -609,7 +609,7 @@ A relational expression is one of the fo .It Ar expression matchop regular-expression .It Ar expression relop expression .It Ar expression Ic in Ar array-name -.It Ic \&( Ns Ar expr Ns Ic \&, Ar expr Ns Ic \&, No Ar ... Ic \&) in Ar array-name +.It Ic \&( Ns Ar expr Ns Ic \&, Ar expr Ns Ic \&, Ar ... Ic \&) in Ar array-name .El .Pp where a
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 15:28:02 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Fix editing accident in one of the previous commits. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 15:27:14 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Drop whitespace between initials P.J. requires thin space, for other - V and W has enough natural space near the bottom (the intervening dot prevents kerning). To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 15:27:14 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Drop whitespace between initials P.J. requires thin space, for other - V and W has enough natural space near the bottom (the intervening dot prevents kerning). To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.20 src/external/historical/nawk/bin/awk.1:1.21 --- src/external/historical/nawk/bin/awk.1:1.20 Tue Jul 5 15:21:39 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 15:27:14 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.20 2022/07/05 15:21:39 uwe Exp $ +.\" $NetBSD: awk.1,v 1.21 2022/07/05 15:27:14 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -44,7 +44,7 @@ is the Bell Labs' implementation of the described in the .Em The AWK Programming Language by -A. V. Aho, B. W. Kernighan, and P. J. Weinberger. +A.V.\~Aho, B.W.\~Kernighan, P.\^J.\~Weinberger. .Pp .Nm scans each input @@ -767,7 +767,7 @@ Print an error message to standard error .Xr strftime 3 , .Xr time 3 .Pp -A. V. Aho, B. W. Kernighan, P. J. Weinberger, +A.\^V.\~Aho, B.\^W.\~Kernighan, P.\^J.\~Weinberger, .Em The AWK Programming Language , Addison-Wesley, 1988. ISBN 0-201-07981-X
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 15:21:39 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): more formatting nits To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.19 src/external/historical/nawk/bin/awk.1:1.20 --- src/external/historical/nawk/bin/awk.1:1.19 Tue Jul 5 14:36:33 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 15:21:39 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.19 2022/07/05 14:36:33 uwe Exp $ +.\" $NetBSD: awk.1,v 1.20 2022/07/05 15:21:39 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -282,25 +282,25 @@ Returns zero on success; otherwise nonze Flushes any buffered output for the file or pipe .Ar expr . Returns zero on success; otherwise nonzero. -.It Ic getline Bq Va var +.It Ic getline Op Ar var Set -.Va var +.Ar var (or .Li $ Ns Va 0 if -.Va var +.Ar var is not specified) to the next input record from the current input file. .Ic getline returns 1 for a successful input, 0 for end of file, and \-1 for an error. -.It Ic getline Bo Va var Bc Ic \*[Lt] Ar file +.It Ic getline Oo Ar var Oc Ic < Ar file Set -.Va var +.Ar var (or .Li $ Ns Va 0 if -.Va var +.Ar var is not specified) to the next input record from the specified file .Ar file . @@ -313,7 +313,7 @@ each call of .Ic getline returns the next line of output from .Ar expr . -.It Ic print Bo Ar expr-list Bc Bq Ic \*[Gt] Ar file +.It Ic print Oo Ar expr-list Oc Op Ic > Ar file The .Ic print statement prints its arguments on the standard output (or to a file @@ -333,7 +333,7 @@ and .Ar expr may be literal names or parenthesized expressions; identical string values in different statements denote the same open file. -.It Ic printf Ar format Bo Ic \&, Ar expr-list Bc Bq Ic \*[Gt] Ar file +.It Ic printf Ar format\| Ns Oo Ic \&, Ar expr-list Oc Op Ic \*[Gt] Ar file Format and print its expression list according to .Ar format . See @@ -398,9 +398,9 @@ for matches of the regular expression If .Ar h is a string beginning with -.Ic g +.Ql g or -.Ic G , +.Ql G , then replace all matches of .Ar r with @@ -438,7 +438,7 @@ and the original target is .Em not changed. Note that the -.Ar \en +.Ql \en sequences within replacement string .Ar s supported by GNU @@ -482,12 +482,12 @@ are set to the position and length of th splits the string .Ar s into array elements -.Va a[1] , -.Va a[2] , +.Ar a Ns Li [1] , +.Ar a Ns Li [2] , \&..., -.Va a[n] , +.Ar a Ns Li \&[ Ns Ar n Ns Li \&] , and returns -.Va n . +.Ar n . The separation is done with the regular expression .Ar fs or with the field separator @@ -518,7 +518,7 @@ is not given, is used. .It Fn substr s m [n] Returns the at most -.Ar n Ns No -character +.Ar n\^ Ns No -character substring of .Ar s starting at position @@ -548,8 +548,7 @@ stamps and formatting them: .Bl -tag -width Fn .It Fn systime Returns the value of time in seconds since the start of -.Tn Unix -Epoch (Midnight, January 1, 1970, Coordinated Universal Time). +Unix Epoch (midnight, January 1, 1970, Coordinated Universal Time). See also .Xr time 3 . .It Fn strftime "[format [, timestamp]]"
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 15:21:39 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): more formatting nits To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 14:36:33 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): drop POSIX prescriptive "shall" from the otherwise descriptive passage To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.18 src/external/historical/nawk/bin/awk.1:1.19 --- src/external/historical/nawk/bin/awk.1:1.18 Tue Jul 5 14:10:09 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 14:36:33 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.18 2022/07/05 14:10:09 uwe Exp $ +.\" $NetBSD: awk.1,v 1.19 2022/07/05 14:36:33 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -145,7 +145,7 @@ Setting any other field causes the re-ev .Li $ Ns Va 0 Assigning to .Li $ Ns Va 0 -shall reset the values of all other fields and the +resets the values of all other fields and the .Va NF built-in variable. .Pp
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 14:36:33 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): drop POSIX prescriptive "shall" from the otherwise descriptive passage To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 14:10:09 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Fix mark up of inline code, the easy cases for now. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.17 src/external/historical/nawk/bin/awk.1:1.18 --- src/external/historical/nawk/bin/awk.1:1.17 Tue Jul 5 13:48:07 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 14:10:09 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.17 2022/07/05 13:48:07 uwe Exp $ +.\" $NetBSD: awk.1,v 1.18 2022/07/05 14:10:09 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -151,9 +151,10 @@ built-in variable. .Pp A pattern-action statement has the form .Lp -.Dl pattern \&{ action \&} +.D1 Ar pattern Li \&{ Ar action Li \&} .Lp -A missing \&{ action \&} +A missing +.Li \&{ Ar action Li \&} means print the line; a missing pattern always matches. Pattern-action statements are separated by newlines or semicolons. @@ -190,7 +191,7 @@ separated by the value of operators, in order of decreasing precedence, are: .Pp .Bl -tag -width Ic -compact -.It Ic (...) +.It Ic \&( Ns No ... Ns Ic \&) Grouping .It Ic $ Field reference @@ -202,16 +203,16 @@ Exponentiation (the form is also supported, and .Ic **= for the assignment operator). -.It + - \&! +.It + \- \&! Unary plus, unary minus and logical negation. .It * / % Multiplication, division and modulus. -.It + - +.It + \- Addition and subtraction. -.It Ar space +.It Em space String concatenation. .It Ic \*[Lt] \*[Gt] -.It Ic \*[Le] \*[Ge] +.It Ic <= >= .It Ic != == Regular relational operators .It Ic ~ !~ @@ -244,27 +245,29 @@ Assignment and Operator-Assignment .Ss Control Statements The control statements are as follows: .Bl -tag -width Fn -.It Ic if \&( Ar expression Ic \&) Ar statement Bq Ic else Ar statement -.It Ic while \&( Ar expression Ic \&) Ar statement -.It Ic for \&( Ar expression Ic \&; Ar expression Ic \&; \ -Ar expression Ic \&) Ar statement -.It Ic for \&( Va var Ic in Ar array Ic \&) Ar statement -.It Ic do Ar statement Ic while \&( Ar expression Ic \&) +.It Ic if \&( Ns Ar expression\^ Ns Ic \&) Ar statement Bq Ic else Ar statement +.It Ic while \&( Ns Ar expression\^ Ns Ic \&) Ar statement +.It Ic for \&( Ns Ar expression\^ Ns Ic \&; \ + Ar expression\^ Ns Ic \&; \ + Ar expression\^ Ns Ic \&) Ar statement +.It Ic for \&( Ns Ar var Ic in Ar array\^ Ns Ic \&) Ar statement +.It Ic do Ar statement Ic while \&( Ns Ar expression\^ Ns Ic \&) .It Ic break .It Ic continue -.It Ic \&{ Ar [ statement ... ] Ic \&} +.It Ic \&{ Oo Ar statement ... Oc Ic \&} .It Ar expression -Commonly var = expression -.It Ic return Bq Ar expression +Commonly +.Ar var Ic = Ar expression +.It Ic return Op Ar expression .It Ic next Skip remaining patterns on this input line .It Ic nextfile Skip rest of this file, open next, start at top -.It Ic delete Va array Bq Ar expression +.It Ic delete Ar array\| Ns Cm \&[ Ns Ar expression\^ Ns Cm \&] Delete an array element -.It Ic delete Va array +.It Ic delete Ar array Delete all elements of an array -.It Ic exit Bq Ar expression +.It Ic exit Op Ar expression Exit immediately; status is .Ar expression .El @@ -342,7 +345,7 @@ AWK has the following mathematical and n .Bl -tag -width Fn .It Fn atan2 x y Returns the arctangent of -.Ar x Ic / Ar y +.Ar x\| Ns Li / Ns Ar y in radians. See also .Xr atan2 3 . @@ -380,8 +383,8 @@ Computes the non-negative square root of See also .Xr sqrt 3 . .It Fn srand [expr] -Sets seed for random number generator ( -.Fn rand ) +Sets seed for random number generator +.Pq Fn rand and returns the previous seed. .El .Ss String Functions @@ -591,7 +594,7 @@ relational expressions, using the operat .Ic ~ and .Ic !~ . -.Ic / re / +.Ic / Ns Ar re Ns Ic / is a constant regular expression; any string (constant or variable) may be used as a regular expression, except in the position of an isolated regular expression @@ -607,7 +610,7 @@ A relational expression is one of the fo .It Ar expression matchop regular-expression .It Ar expression relop expression .It Ar expression Ic in Ar array-name -.It ( Ar expr , expr,\&... Ic ") in" Ar array-name +.It Ic \&( Ns Ar expr Ns Ic \&, Ar expr Ns Ic \&, No Ar ... Ic \&) in Ar array-name .El .Pp where a @@ -667,7 +670,7 @@ non-null members are taken as filenames .It Va CONVFMT conversion format used when converting numbers (default -.Qq %.6g ) +.Li \(dq%.6g\(dq ) .It Va ENVIRON array of environment variables; subscripts are names. .It Va FILENAME @@ -684,8 +687,7 @@ number of fields in the current record ordinal number of the current record .It Va OFMT
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 14:10:09 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Fix mark up of inline code, the easy cases for now. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 13:48:07 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): mark up $ properly - '$' is an unary op, not part of the name To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.16 src/external/historical/nawk/bin/awk.1:1.17 --- src/external/historical/nawk/bin/awk.1:1.16 Tue Jul 5 13:29:18 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 13:48:07 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.16 2022/07/05 13:29:18 uwe Exp $ +.\" $NetBSD: awk.1,v 1.17 2022/07/05 13:48:07 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -136,10 +136,10 @@ If .Va FS is null, the input line is split into one field per character. The fields are denoted -.Va $1 , -.Va $2 , +.Li $ Ns Va 1 , +.Li $ Ns Va 2 , \&..., while -.Va $0 +.Li $ Ns Va 0 refers to the entire line. Setting any other field causes the re-evaluation of .Li $ Ns Va 0 @@ -164,7 +164,7 @@ semicolons, newlines or right braces. An empty .Ar expression-list stands for -.Va $0 . +.Li $ Ns Va 0 . String constants are quoted .Em \&"\ \&" , with the usual C escapes recognized within. @@ -283,7 +283,8 @@ Returns zero on success; otherwise nonze Set .Va var (or -.Va $0 if +.Li $ Ns Va 0 +if .Va var is not specified) to the next input record from the current input file. @@ -294,7 +295,8 @@ returns 1 for a successful input, Set .Va var (or -.Va $0 if +.Li $ Ns Va 0 +if .Va var is not specified) to the next input record from the specified file @@ -408,7 +410,7 @@ to replace. If no .Ar t is supplied, -.Va $0 +.Li $ Ns Va 0 is used instead. .\"Within the replacement text .\".Ar s , @@ -460,7 +462,7 @@ occurs, or 0 if it does not. the length of its argument taken as a string, or of -.Va $0 +.Li $ Ns Va 0 if no argument. .It Fn match s r the position in @@ -509,7 +511,7 @@ in the target string If .Ar t is not given, -.Va $0 +.Li $ Ns Va 0 is used. .It Fn substr s m [n] Returns the at most
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 13:48:07 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): mark up $ properly - '$' is an unary op, not part of the name To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 13:29:18 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): document programs that only has BEGIN and/or END pattern-actions. Copied from POSIX, except "getline" is a statement, not a function, so call it that. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.15 src/external/historical/nawk/bin/awk.1:1.16 --- src/external/historical/nawk/bin/awk.1:1.15 Tue Jul 5 13:21:38 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 13:29:18 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.15 2022/07/05 13:21:38 uwe Exp $ +.\" $NetBSD: awk.1,v 1.16 2022/07/05 13:29:18 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -634,6 +634,26 @@ and after the last. and .Ic END do not combine with other patterns. +.Pp +If an awk program consists of only actions with the pattern +.Ic BEGIN , +and the +.Ic BEGIN +action contains no +.Ic getline +statement, awk shall exit without reading its input when the last +statement in the last +.Ic BEGIN +action is executed. +If an awk program consists of only actions with the pattern +.Ic END +or only actions with the patterns +.Ic BEGIN +and +.Ic END , +the input shall be read before the statements in the +.Ic END +actions are executed. .Ss Built-in Variables Variable names with special meanings: .Bl -hang -width Va
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 13:29:18 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): document programs that only has BEGIN and/or END pattern-actions. Copied from POSIX, except "getline" is a statement, not a function, so call it that. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 13:21:38 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): document what assigning to $0 and $ does To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 13:21:38 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): document what assigning to $0 and $ does To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.14 src/external/historical/nawk/bin/awk.1:1.15 --- src/external/historical/nawk/bin/awk.1:1.14 Tue Jul 5 13:05:20 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 13:21:38 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.14 2022/07/05 13:05:20 uwe Exp $ +.\" $NetBSD: awk.1,v 1.15 2022/07/05 13:21:38 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -130,16 +130,24 @@ version on standard output and exit. .Pp An input line is normally made up of fields separated by white space, or by regular expression -.Va FS . +.Va FS +built-in variable is set to. +If +.Va FS +is null, the input line is split into one field per character. The fields are denoted .Va $1 , .Va $2 , \&..., while .Va $0 refers to the entire line. -If -.Va FS -is null, the input line is split into one field per character. +Setting any other field causes the re-evaluation of +.Li $ Ns Va 0 +Assigning to +.Li $ Ns Va 0 +shall reset the values of all other fields and the +.Va NF +built-in variable. .Pp A pattern-action statement has the form .Lp
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 13:05:20 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): mark up var=value properly To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 13:05:20 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): mark up var=value properly To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.13 src/external/historical/nawk/bin/awk.1:1.14 --- src/external/historical/nawk/bin/awk.1:1.13 Tue Jul 5 12:59:01 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 13:05:20 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.13 2022/07/05 12:59:01 uwe Exp $ +.\" $NetBSD: awk.1,v 1.14 2022/07/05 13:05:20 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -31,7 +31,7 @@ .Sh SYNOPSIS .Nm .Op Fl F Ar fs -.Op Fl v Ar var=value +.Op Fl v Ar var\| Ns Cm \&= Ns Ar value .Op Fl safe .Op Fl d Ns Op Ar N .Op Ar prog | Fl f Ar progfile @@ -68,13 +68,13 @@ means the standard input. Any .Ar file of the form -.Ar var=value +.Ar var\| Ns Cm \&= Ns Ar value is treated as an assignment, not a filename, and is executed at the time it would have been opened if it were a filename. The option .Fl v followed by -.Ar var=value +.Ar var\| Ns Cm \&= Ns Ar value is an assignment to be done before .Ar prog is executed; any number of @@ -111,11 +111,11 @@ fields number. Potentially unsafe functions such as .Fn system make the program abort (with a warning message). -.It Fl v Ar var Ns = Ns Ar value +.It Fl v Ar var\| Ns Cm \&= Ns Ar value Assign the value .Ar value to the variable -.Va var +.Ar var before .Ar prog is executed.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 12:59:01 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Fix -width. "indent" (or misspelings thereof) is not a magic value for -width. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.12 src/external/historical/nawk/bin/awk.1:1.13 --- src/external/historical/nawk/bin/awk.1:1.12 Tue Jul 5 12:46:48 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 12:59:01 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.12 2022/07/05 12:46:48 uwe Exp $ +.\" $NetBSD: awk.1,v 1.13 2022/07/05 12:59:01 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -86,7 +86,7 @@ option defines the input field separator .Ar fs . .Pp The options are as follows: -.Bl -tag -width indent +.Bl -tag -width Fl .It Fl d Ns Op Ar N Set debug level to specified number .Ar N . @@ -181,7 +181,7 @@ separated by the value of .Nm operators, in order of decreasing precedence, are: .Pp -.Bl -tag -width ident -compact +.Bl -tag -width Ic -compact .It Ic (...) Grouping .It Ic $ @@ -235,7 +235,7 @@ Assignment and Operator-Assignment .El .Ss Control Statements The control statements are as follows: -.Bl -tag -width indent +.Bl -tag -width Fn .It Ic if \&( Ar expression Ic \&) Ar statement Bq Ic else Ar statement .It Ic while \&( Ar expression Ic \&) Ar statement .It Ic for \&( Ar expression Ic \&; Ar expression Ic \&; \ @@ -262,7 +262,7 @@ Exit immediately; status is .El .Ss I/O Statements The input/output statements are as follows: -.Bl -tag -width indent +.Bl -tag -width Fn .It Fn close expr Closes the file or pipe .Ar expr . @@ -329,7 +329,7 @@ for list of supported formats and their .El .Ss Mathematical and Numeric Functions AWK has the following mathematical and numerical functions built-in: -.Bl -tag -width indent +.Bl -tag -width Fn .It Fn atan2 x y Returns the arctangent of .Ar x Ic / Ar y @@ -376,7 +376,7 @@ and returns the previous seed. .El .Ss String Functions AWK has the following string functions built-in: -.Bl -tag -width indent +.Bl -tag -width Fn .It Fn gensub r s h [t] Search the target string .Ar t @@ -532,7 +532,7 @@ This .Nm provides the following two functions for obtaining time stamps and formatting them: -.Bl -tag -width indent +.Bl -tag -width Fn .It Fn systime Returns the value of time in seconds since the start of .Tn Unix @@ -560,7 +560,7 @@ See the specification of ANSI C for the format conversions which are supported. .El .Ss Other built-in functions -.Bl -tag -width indent +.Bl -tag -width Fn .It Fn system cmd executes .Ar cmd @@ -593,7 +593,7 @@ from an occurrence of the first pattern though an occurrence of the second. .Pp A relational expression is one of the following: -.Bl -tag -offset indent -width indent -compact +.Bl -tag -offset indent -width Fn -compact .It Ar expression matchop regular-expression .It Ar expression relop expression .It Ar expression Ic in Ar array-name @@ -628,7 +628,7 @@ and do not combine with other patterns. .Ss Built-in Variables Variable names with special meanings: -.Bl -hang -width FILENAMES +.Bl -hang -width Va .It Va ARGC argument count, assignable .It Va ARGV
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 12:59:01 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): Fix -width. "indent" (or misspelings thereof) is not a magic value for -width. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 12:46:48 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): g/c extraneous space in an example To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.11 src/external/historical/nawk/bin/awk.1:1.12 --- src/external/historical/nawk/bin/awk.1:1.11 Tue Jul 5 00:47:32 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 12:46:48 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.11 2022/07/05 00:47:32 uwe Exp $ +.\" $NetBSD: awk.1,v 1.12 2022/07/05 12:46:48 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -702,7 +702,7 @@ BEGIN { FS = ",[ \et]*|[ \et]+" } Add up first column, print sum and average: .Bd -literal -offset indent { s += $1 } -END { print "sum is", s, " average is", s/NR } +END { print "sum is", s, "average is", s/NR } .Ed .Pp Print all lines between start/stop pairs:
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 12:46:48 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): g/c extraneous space in an example To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/external/historical/nawk/bin
Am 05.07.2022 um 02:16 schrieb Valery Ushakov: Posix has the echo example as: BEGIN { for (i = 1; i < ARGC; ++i) printf("%s%s", ARGV[i], i==ARGC-1?"\n":" ") } which I would still consider ugly :). I would rather use instead: BEGIN { for (i = 1; i < ARGC; ++i) $i = ARGV[i]; print } that, as a bonus, demonstrates $var field references (that the current man page doesn't mention at all) and the magic $0 "reassembly". Now that looks clean and idiomatic. Anyway, I was wrong about POSIX - I somehow managed to screw up my search and missed the passage that specifies it: If an awk program consists of only actions with the pattern BEGIN, and the BEGIN action contains no getline function, awk shall exit without reading its input when the last statement in the last BEGIN action is executed. If an awk program consists of only actions with the pattern END or only actions with the patterns BEGIN and END, the input shall be read before the statements in the END actions are executed. Hmmm, strange that we both missed this part on the first reading, even though it seems obvious now. I remember having searched for BEGIN, which would have led me to this paragraph, but I somehow skipped it when trying to prove my point. Roland
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 00:47:33 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): use official echo example from POSIX To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.10 src/external/historical/nawk/bin/awk.1:1.11 --- src/external/historical/nawk/bin/awk.1:1.10 Mon Jul 4 18:07:41 2022 +++ src/external/historical/nawk/bin/awk.1 Tue Jul 5 00:47:32 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.10 2022/07/04 18:07:41 rillig Exp $ +.\" $NetBSD: awk.1,v 1.11 2022/07/05 00:47:32 uwe Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -711,10 +711,10 @@ Print all lines between start/stop pairs .Pp Simulate echo(1): .Bd -literal -offset indent -BEGIN { # Simulate echo(1) -for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i] -printf "\en" -exit } +BEGIN { +for (i = 1; i < ARGC; ++i) +printf("%s%s", ARGV[i], i==ARGC-1?"\en":" ") +} .Ed .Pp Print an error message to standard error:
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: uwe Date: Tue Jul 5 00:47:33 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk(1): use official echo example from POSIX To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/external/historical/nawk/bin
On Mon, Jul 04, 2022 at 20:06:45 +0200, Roland Illig wrote: > Am 04.07.2022 um 13:14 schrieb Valery Ushakov: > > On Mon, Jul 04, 2022 at 08:04:57 +0200, Roland Illig wrote: > > > > > 04.07.2022 01:54:16 Valery Ushakov : > > > > On Mon, Jul 04, 2022 at 00:07:23 +0200, Roland Illig wrote: > > > > > > > > > Am 03.07.2022 um 21:55 schrieb Valery Ushakov: > > > > > > On Sun, Jul 03, 2022 at 10:56:22 +, Roland Illig wrote: > > > > > > > > > > > > > Module Name: src > > > > > > > Committed By: rillig > > > > > > > Date: Sun Jul 3 10:56:22 UTC 2022 > > > > > > > > > > > > > > Modified Files: > > > > > > > src/external/historical/nawk/bin: awk.1 > > > > > > > > > > > > > > Log Message: > > > > > > > awk.1: remove trailing space in output of 'echo' example program > > > > > > > > > > > > This is cure worse than the desease. Please revert. > > > > > > > > > > Why is it worse? > > > > > > > > It's ugly > > > > > > Why is it ugly? > > > > > > > and complicated (for an example), > > > > > > Why is it complicated? It's still only 3 lines of code. > > > > > > > it obscures the point this example tries to make. > > > > > > What is this (single?) point this example tries to make? To me, it > > > was how to write a BEGIN program that uses ARGV, and my rewritten > > > code still illustrates this. > > > > You have turned a trivial for loop that requires no mental bandwidth > > to skim over into a code review errand with complex case analysis and > > ugly inverted 1 < ARGC to boot. > > I intentionally wrote '1 < ARGC' instead of 'ARGC > 1' to make the > condition as close as possible to the condition in the 'for' loop. If > it weren't for this symmetry, I would of course have written it in the > subject-first manner. [...] > > but this case is not > > about code doing something specified with aesthetic considerations > > being secondary to its actually doing the job. Here taste is an > > important factor b/c it's not code, but a man page - a literally work > > really. > > That's exactly my point. The manual page is our reference > documentation, and as such, it should demonstrate and teach best > practices. Presenting a program that is _almost correct_ misses this > point, and I don't want to see any code derived from an _almost correct_ > example. Mixing such code with other _almost correct_ example code will > quickly lead to programs with bugs everywhere. > > An example for this would be the common usage of functions, > which really many people get wrong, either by reading sloppily produced > teaching material or incomplete documentation or by copying code > snippets that seem to work. So this needs the symmetry with the next line and the reader needs to register and process that symmetry. Then the fun part comes, the reader needs to match the two bodies (if and for) and figure out if and how they differ and find that visually elusive whitespace. And this has already snowballed into quite a code review errand. ctype and the C integer promotion rules that it touches (often inappropriately) go to some pretty dark corners of the C standard. Proper examples of correct use are essential for that man page and those examples are kinda the focal point of it. Here the point of the example is a BEGIN-only program that doesn't process any input. Any content of that BEGIN action is rather unimportant, a kind of "lorem ipsum" filler almost. So turning it into an exercise in correct re-implementation of echo(1) draws attention to the wrong thing. Consider that extra space in the output to be poetic license. Posix has the echo example as: BEGIN { for (i = 1; i < ARGC; ++i) printf("%s%s", ARGV[i], i==ARGC-1?"\n":" ") } which I would still consider ugly :). I would rather use instead: BEGIN { for (i = 1; i < ARGC; ++i) $i = ARGV[i]; print } that, as a bonus, demonstrates $var field references (that the current man page doesn't mention at all) and the magic $0 "reassembly". > > PS: BTW, you also eliminated the "exit" at the end of the BEGIN > > action. This is not specified by POSIX and happens to work on all > > major three - nawk, mawk, gawk, though only gawk seems to document > > this and only in the info file, not its man page (though its man page > > has exampes that rely on this behaviour). > > > > E.g. solaris /usr/bin/awk will still wait for input to consume and > > discard it. > > Ouch, thanks for telling me. I was so sure that POSIX had specified > this that I didn't bother to look it up again. Now I did, and I will > revert my changes. Your g/c'ing the "exit" actually piqued my curiosity, b/c that's not how I remeber my awk. I verified that 2.9BSD has awk that always processes its input so that explains why I remember it that way. Of course it doesn't support ARGC/ARGV. Anyway, I was wrong about POSIX - I somehow managed to screw up my search and missed the passage that specifies it: If an awk program consists of only actions with
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: rillig Date: Mon Jul 4 18:07:41 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk.1: revert changes to example 'echo' program I had removed the exit statement in the strong belief that POSIX had specified that an AWK program consisting of only a BEGIN block would implicitly exit after the BEGIN block. This assumption was wrong. There are several implementations that implement this special case though. https://mail-index.netbsd.org/source-changes-d/2022/07/03/msg013718.html To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.9 src/external/historical/nawk/bin/awk.1:1.10 --- src/external/historical/nawk/bin/awk.1:1.9 Sun Jul 3 10:56:22 2022 +++ src/external/historical/nawk/bin/awk.1 Mon Jul 4 18:07:41 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.9 2022/07/03 10:56:22 rillig Exp $ +.\" $NetBSD: awk.1,v 1.10 2022/07/04 18:07:41 rillig Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -22,7 +22,7 @@ .\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF .\" THIS SOFTWARE. .\" -.Dd July 3, 2022 +.Dd December 19, 2019 .Dt AWK 1 .Os .Sh NAME @@ -711,11 +711,10 @@ Print all lines between start/stop pairs .Pp Simulate echo(1): .Bd -literal -offset indent -BEGIN { - if (1 < ARGC) printf "%s", ARGV[1] - for (i = 2; i < ARGC; i++) printf " %s", ARGV[i] - printf "\en" -} +BEGIN { # Simulate echo(1) +for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i] +printf "\en" +exit } .Ed .Pp Print an error message to standard error:
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: rillig Date: Mon Jul 4 18:07:41 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk.1: revert changes to example 'echo' program I had removed the exit statement in the strong belief that POSIX had specified that an AWK program consisting of only a BEGIN block would implicitly exit after the BEGIN block. This assumption was wrong. There are several implementations that implement this special case though. https://mail-index.netbsd.org/source-changes-d/2022/07/03/msg013718.html To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/external/historical/nawk/bin
Am 04.07.2022 um 13:14 schrieb Valery Ushakov: On Mon, Jul 04, 2022 at 08:04:57 +0200, Roland Illig wrote: 04.07.2022 01:54:16 Valery Ushakov : On Mon, Jul 04, 2022 at 00:07:23 +0200, Roland Illig wrote: Am 03.07.2022 um 21:55 schrieb Valery Ushakov: On Sun, Jul 03, 2022 at 10:56:22 +, Roland Illig wrote: Module Name: src Committed By: rillig Date: Sun Jul 3 10:56:22 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk.1: remove trailing space in output of 'echo' example program This is cure worse than the desease. Please revert. Why is it worse? It's ugly Why is it ugly? and complicated (for an example), Why is it complicated? It's still only 3 lines of code. it obscures the point this example tries to make. What is this (single?) point this example tries to make? To me, it was how to write a BEGIN program that uses ARGV, and my rewritten code still illustrates this. You have turned a trivial for loop that requires no mental bandwidth to skim over into a code review errand with complex case analysis and ugly inverted 1 < ARGC to boot. I intentionally wrote '1 < ARGC' instead of 'ARGC > 1' to make the condition as close as possible to the condition in the 'for' loop. If it weren't for this symmetry, I would of course have written it in the subject-first manner. I realize this is de gustibus and if you don't see this new code that way I probably cannot make you see it that way, That's a tough assumption. I precisely asked 'Why' because I couldn't guess your reasons for calling this code bad and ugly, and I wanted to understand them. but this case is not about code doing something specified with aesthetic considerations being secondary to its actually doing the job. Here taste is an important factor b/c it's not code, but a man page - a literally work really. That's exactly my point. The manual page is our reference documentation, and as such, it should demonstrate and teach best practices. Presenting a program that is _almost correct_ misses this point, and I don't want to see any code derived from an _almost correct_ example. Mixing such code with other _almost correct_ example code will quickly lead to programs with bugs everywhere. An example for this would be the common usage of functions, which really many people get wrong, either by reading sloppily produced teaching material or incomplete documentation or by copying code snippets that seem to work. Well, what *was* your goal? To be "technically correct, the best kind of correct"? Yes, exactly that. The comment above that snippet mentions echo(1), which does not print a space after its last argument, so I chose to make this example snippet implement this as well. After all, it was just one more line of code, demonstrating an 'if' condition, something that's not yet in the other examples. I'm pretty sure that whoever wrote that example did know how to write a "proper" echo in awk, but chose not to deliberately. Maybe, maybe not. I don't know who wrote that example and when, and what the motivation was back then. That argument of "did know" does not hold always though. PS: BTW, you also eliminated the "exit" at the end of the BEGIN action. This is not specified by POSIX and happens to work on all major three - nawk, mawk, gawk, though only gawk seems to document this and only in the info file, not its man page (though its man page has exampes that rely on this behaviour). E.g. solaris /usr/bin/awk will still wait for input to consume and discard it. Ouch, thanks for telling me. I was so sure that POSIX had specified this that I didn't bother to look it up again. Now I did, and I will revert my changes. Roland
Re: CVS commit: src/external/historical/nawk/bin
On Sun, Jul 03, 2022 at 22:55:48 +0300, Valery Ushakov wrote: > On Sun, Jul 03, 2022 at 10:56:22 +, Roland Illig wrote: > > > Module Name:src > > Committed By: rillig > > Date: Sun Jul 3 10:56:22 UTC 2022 > > > > Modified Files: > > src/external/historical/nawk/bin: awk.1 > > > > Log Message: > > awk.1: remove trailing space in output of 'echo' example program > > This is cure worse than the desease. Please revert. PS: BTW, you also eliminated the "exit" at the end of the BEGIN action. This is not specified by POSIX and happens to work on all major three - nawk, mawk, gawk, though only gawk seems to document this and only in the info file, not its man page (though its man page has exampes that rely on this behaviour). E.g. solaris /usr/bin/awk will still wait for input to consume and discard it. -uwe
Re: CVS commit: src/external/historical/nawk/bin
On Mon, Jul 04, 2022 at 08:04:57 +0200, Roland Illig wrote: > 04.07.2022 01:54:16 Valery Ushakov : > > On Mon, Jul 04, 2022 at 00:07:23 +0200, Roland Illig wrote: > > > >> Am 03.07.2022 um 21:55 schrieb Valery Ushakov: > >>> On Sun, Jul 03, 2022 at 10:56:22 +, Roland Illig wrote: > >>> > Module Name: src > Committed By: rillig > Date: Sun Jul 3 10:56:22 UTC 2022 > > Modified Files: > src/external/historical/nawk/bin: awk.1 > > Log Message: > awk.1: remove trailing space in output of 'echo' example program > >>> > >>> This is cure worse than the desease. Please revert. > >> > >> Why is it worse? > > > > It's ugly > > Why is it ugly? > > > and complicated (for an example), > > Why is it complicated? It's still only 3 lines of code. > > > it obscures the point this example tries to make. > > What is this (single?) point this example tries to make? To me, it > was how to write a BEGIN program that uses ARGV, and my rewritten > code still illustrates this. You have turned a trivial for loop that requires no mental bandwidth to skim over into a code review errand with complex case analysis and ugly inverted 1 < ARGC to boot. I realize this is de gustibus and if you don't see this new code that way I probably cannot make you see it that way, but this case is not about code doing something specified with aesthetic considerations being secondary to its actually doing the job. Here taste is an important factor b/c it's not code, but a man page - a literally work really. > > The point is not to write a perfect echo(1) clone in awk. > > If that had been my goal, I would have implemented the -n option as > well, at which point the code would have grown large enough to be > extracted into a separate file. I didn't do that though. Well, what *was* your goal? To be "technically correct, the best kind of correct"? I'm pretty sure that whoever wrote that example did know how to write a "proper" echo in awk, but chose not to deliberately. -uwe
Re: CVS commit: src/external/historical/nawk/bin
04.07.2022 01:54:16 Valery Ushakov : > On Mon, Jul 04, 2022 at 00:07:23 +0200, Roland Illig wrote: > >> Am 03.07.2022 um 21:55 schrieb Valery Ushakov: >>> On Sun, Jul 03, 2022 at 10:56:22 +, Roland Illig wrote: >>> Module Name: src Committed By: rillig Date: Sun Jul 3 10:56:22 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk.1: remove trailing space in output of 'echo' example program >>> >>> This is cure worse than the desease. Please revert. >> >> Why is it worse? > > It's ugly Why is it ugly? > and complicated (for an example), Why is it complicated? It's still only 3 lines of code. > it obscures the point this example tries to make. What is this (single?) point this example tries to make? To me, it was how to write a BEGIN program that uses ARGV, and my rewritten code still illustrates this. > The point is not to write a perfect echo(1) clone in awk. If that had been my goal, I would have implemented the -n option as well, at which point the code would have grown large enough to be extracted into a separate file. I didn't do that though. Roland
Re: CVS commit: src/external/historical/nawk/bin
On Mon, Jul 04, 2022 at 00:07:23 +0200, Roland Illig wrote: > Am 03.07.2022 um 21:55 schrieb Valery Ushakov: > > On Sun, Jul 03, 2022 at 10:56:22 +, Roland Illig wrote: > > > > > Module Name: src > > > Committed By: rillig > > > Date: Sun Jul 3 10:56:22 UTC 2022 > > > > > > Modified Files: > > > src/external/historical/nawk/bin: awk.1 > > > > > > Log Message: > > > awk.1: remove trailing space in output of 'echo' example program > > > > This is cure worse than the desease. Please revert. > > Why is it worse? It's ugly, and complicated (for an example), and it obscures the point this example tries to make. The point is not to write a perfect echo(1) clone in awk. -uwe
Re: CVS commit: src/external/historical/nawk/bin
Am 03.07.2022 um 21:55 schrieb Valery Ushakov: On Sun, Jul 03, 2022 at 10:56:22 +, Roland Illig wrote: Module Name:src Committed By: rillig Date: Sun Jul 3 10:56:22 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk.1: remove trailing space in output of 'echo' example program This is cure worse than the desease. Please revert. Why is it worse?
Re: CVS commit: src/external/historical/nawk/bin
On Sun, Jul 03, 2022 at 10:56:22 +, Roland Illig wrote: > Module Name: src > Committed By: rillig > Date: Sun Jul 3 10:56:22 UTC 2022 > > Modified Files: > src/external/historical/nawk/bin: awk.1 > > Log Message: > awk.1: remove trailing space in output of 'echo' example program This is cure worse than the desease. Please revert. -uwe
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: rillig Date: Sun Jul 3 10:56:22 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk.1: remove trailing space in output of 'echo' example program To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/historical/nawk/bin/awk.1 diff -u src/external/historical/nawk/bin/awk.1:1.8 src/external/historical/nawk/bin/awk.1:1.9 --- src/external/historical/nawk/bin/awk.1:1.8 Sat Dec 21 09:11:59 2019 +++ src/external/historical/nawk/bin/awk.1 Sun Jul 3 10:56:22 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: awk.1,v 1.8 2019/12/21 09:11:59 wiz Exp $ +.\" $NetBSD: awk.1,v 1.9 2022/07/03 10:56:22 rillig Exp $ .\" .\" Copyright (C) Lucent Technologies 1997 .\" All Rights Reserved @@ -22,7 +22,7 @@ .\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF .\" THIS SOFTWARE. .\" -.Dd December 19, 2019 +.Dd July 3, 2022 .Dt AWK 1 .Os .Sh NAME @@ -711,10 +711,11 @@ Print all lines between start/stop pairs .Pp Simulate echo(1): .Bd -literal -offset indent -BEGIN { # Simulate echo(1) -for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i] -printf "\en" -exit } +BEGIN { + if (1 < ARGC) printf "%s", ARGV[1] + for (i = 2; i < ARGC; i++) printf " %s", ARGV[i] + printf "\en" +} .Ed .Pp Print an error message to standard error:
CVS commit: src/external/historical/nawk/bin
Module Name:src Committed By: rillig Date: Sun Jul 3 10:56:22 UTC 2022 Modified Files: src/external/historical/nawk/bin: awk.1 Log Message: awk.1: remove trailing space in output of 'echo' example program To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/historical/nawk/bin/awk.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
re: CVS commit: src/external/historical/nawk/bin
Module Name: src Committed By: christos Date: Sun Dec 12 19:01:04 UTC 2010 Modified Files: src/external/historical/nawk/bin: Makefile Log Message: Don't build awk.info because matt removed it. oh, that was a mistake then. it should have been moved into the external gpl directory, i guess. i'll fix it. .mrg.