язык сканирования и обработки шаблонов (pattern scanning and processing language)
POSIX COMPATIBILITY
A primary goal for gawk is compatibility with the POSIX standard,
as well as with the latest version of Brian Kernighan's awk. To
this end, gawk incorporates the following user visible features
which are not described in the AWK book, but are part of the
Brian Kernighan's version of awk, and are in the POSIX standard.
The book indicates that command line variable assignment happens
when awk would otherwise open the argument as a file, which is
after the BEGIN
rule is executed. However, in earlier
implementations, when such an assignment appeared before any file
names, the assignment would happen before the BEGIN
rule was run.
Applications came to depend on this 'feature.' When awk was
changed to match its documentation, the -v
option for assigning
variables before program execution was added to accommodate
applications that depended upon the old behavior. (This feature
was agreed upon by both the Bell Laboratories developers and the
GNU developers.)
When processing arguments, gawk uses the special option '--' to
signal the end of arguments. In compatibility mode, it warns
about but otherwise ignores undefined options. In normal
operation, such arguments are passed on to the AWK program for it
to process.
The AWK book does not define the return value of srand()
. The
POSIX standard has it return the seed it was using, to allow
keeping track of random number sequences. Therefore srand()
in
gawk also returns its current seed.
Other features are: The use of multiple -f
options (from MKS
awk); the ENVIRON
array; the \a
, and \v
escape sequences (done
originally in gawk and fed back into the Bell Laboratories
version); the tolower()
and toupper()
built-in functions (from
the Bell Laboratories version); and the ISO C conversion
specifications in printf
(done first in the Bell Laboratories
version).