-->

Previous | Table of Contents | Next

Page 171

SEE ALSO


egrep(1), getpid(2), getppid(2), getpgrp(2), getuid(2), geteuid(2), getgid(2), getegid(2), get-groups(2)

The AWK Programming Language, Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger, Addison-Wesley, 1988. ISBN 0-201-07981-X.

The GAWK Manual, Edition 0.15, published by the Free Software Foundation, 1993.

POSIX COMPATIBILITY

A primary goal for gawk is compatibility with the standard, as well as with the latest version of awk. To this end, gawk incorporates the following user-visible features that are not described in the awk book, but are part of awk in System V Release 4, and are in the standard.

The _v option for assigning variables before program execution starts is new. The book indicates that command-line variable assignment happens when awk would otherwise open the argument as a file, which is after the BEGIN block is executed. However, in earlier implementations, when such an assignment appeared before any filenames, the assignment would happen before the BEGIN block was run. Applications came to depend on this "feature." When awk was changed to match its documentation, this option was added to accommodate applications that depended upon the old behavior. (This feature was agreed on by both the AT&T and GNU developers.)

The _W option for implementation-specific features is from the standard.

When processing arguments, gawk uses the special option __ to signal the end of arguments. In compatibility mode, it will warn about, but otherwise ignore, 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 System V Release 4 version of awk (and the 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 new 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 AT&T's version); the tolower() and toupper() built-in functions (from AT&T); and the C conversion specifications in printf (done first in AT&T's version).

GNU EXTENSIONS

gawk has some extensions to awk. They are described in this section. All the extensions described here can be disabled by invoking gawk with the _W compat option.

The following features of gawk are not available in awk:
The \x escape sequence.
The systime() and strftime() functions.
The special filenames available for I/O redirection are not recognized.
The ARGIND and ERRNO variables are not special.
The IGNORECASE variable and its side effects.
The FIELDWIDTHS variable and fixed width field splitting.
No path search is performed for files named via the_f option. Therefore, the AWKPATH environment variable is not special.
The use of next file to abandon processing of the current input file.
The use of delete array to delete the entire contents of an array.

The awk book does not define the return value of the close() function. gawk's close() returns the value from fclose(3), or pclose(3), when closing a file or pipe, respectively.

When gawk is invoked with the _W compat option, if the fs argument to the _F option is t, then FS will be set to the tab character. Since this is a rather ugly special case, it is not the default behavior. This behavior also does not occur if _Wposix has been specified.

Page 172

HISTORICAL FEATURES

There are two features of historical awk implementations that gawk supports. First, it is possible to call the length() built-in function not only with no argument, but even without parentheses! Thus, this:


a = length

is the same as either of these:


a = length()

a = length($0)

This feature is marked as "deprecated" in the standard, and gawk will issue a warning about its use if _W lint is specified on the command line.

The other feature is the use of either the continue or the break statements outside the body of a while, for, or do loop. Traditional awk implementations have treated such usage as equivalent to the next statement. gawk will support this usage if _W compat has been specified.

ENVIRONMENT VARIABLES

If POSIXLY_CORRECT exists in the environment, then gawk behaves exactly as if — -posix had been specified on the command line. If —-lint has been specified, gawk will issue a warning message to this effect.

BUGS

The _F option is not necessary given the command-line variable assignment feature; it remains only for backwards compatibility.

If your system actually has support for /dev/fd and the associated /dev/stdin, /dev/stdout, and /dev/stderr files, you may get different output from gawk than you would get on a system without those files. When gawk interprets these files internally, it synchronizes output to the standard output with output to /dev/stdout, while on a system with those files, the output is actually to different open files. Caveat emptor.

VERSION INFORMATION

This man page documents gawk, version 2.15.

Starting with the 2.15 version of gawk, the _c, _V, _C, _D, _a, and _e options of the 2.11 version are no longer recognized. This fact will not even be documented in the manual page for the next major version.

AUTHORS

The original version of awk was designed and implemented by Alfred Aho, Peter Weinberger, and Brian Kernighan of AT&T Bell Labs. Brian Kernighan continues to maintain and enhance it.

Paul Rubin and Jay Fenlason, of the Free Software Foundation, wrote gawk, to be compatible with the original version of awk distributed in the seventh edition. John Woods contributed a number of bug fixes. David Trueman, with contributions from Arnold Robbins, made gawk compatible with the new version of awk. Arnold Robbins is the current maintainer.

The initial DOS port was done by Conrad Kwok and Scott Garfinkle. Scott Deifik is the current DOS maintainer. Pat Rankin did the port to VMS, and Michal Jaegermann did the port to the Atari ST. The port to OS/2 was done by Kai Uwe Rommel, with contributions and help from Darrel Hankerson.

BUG REPORTS

If you find a bug in gawk, please send electronic mail to


bug-gnu-utils@prep.ai.mit.edu,

with a copy to arnold@gnu.ai.mit.edu. Please include your operating system and its revision, the version of gawk, what C compiler you used to compile it, and a test program and data that are as small as possible for reproducing the problem.

Previous | Table of Contents | Next