FIXES revised: 2014-01-15 23:10 UTC
Near the beginning was the 1987 awk book:
''The AWK Programming Language''
Since then Dr. Kernighan (the k of awk) has updated it and
fixed bugs. Updated Dec 20, 2012
File FIXES from the source code: "This file lists all bug fixes,
changes, etc., made since the AWK book was sent to the
printers in August, 1987."
(( copyright: awk_Lucent_Copyright_notice ))
Edited - reordered oldest to newest; pruned out bug fixes;
added undocumented features at the end.
2014 - added dates, %* format, -Ft
added toupper and tolower functions (Oct xx, 1987)
recognize -- as terminator of command-line options
evaluate all arguments of built-in functions, as in C; the appearance is that
arguments are evaluated before the function is called
Added \a ("alert"), \v (vertical tab), \xhhh (hexadecimal)
ENVIRON array contains environment: if shell variable V=thing,
ENVIRON["V"] is "thing"
multiple -f arguments permitted.
fixed order of evaluation of commandline assignments to match what the
book claims: an argument of the form x=e is evaluated at the
time it would have been opened if it were a filename (p 63).
added some missing ansi printf conversion letters: %i %X %E %G.
no sensible meaning for h or L, so they may not do what one expects.
made %* conversions work. (Jun 14, 1989)
added -v x=1 ... for immediate commandline variable assignment;
done before the BEGIN block for sure. they have to precede the
program if the program is on the commandline.
requires a separate -v for each assignment.
FILENAME is now defined in the BEGIN block (Oct 11, 1989)
"-" means stdin in getline as well as on the commandline.
Added \x to regular expressions (already in strings).
awk -f - reads the program from stdin.
enforce variable name syntax for commandline variables:
has to start with letter or _.
added explicit check for /dev/std(in,out,err) in redirection.
added CONVFMT as in posix (Jul 23, 1993)
delete arrayname is now legal; it clears the elements but leaves
the array, which may not be the right behavior.
enhanced split(), as in gawk, etc: split(s, a, "") splits s into
a[1]...a[length(s)] with each character a single element.
made the same changes for field-splitting if FS is "".
added nextfile, as in gawk: causes immediate advance to next input file.
printf("%c", 0) to include a null byte in output.
added a "-safe" argument that disables file output (print >, print >>),
process creation (cmd|
getline, print |
, system),
and access to the environment (ENVIRON).
added -V to print version number (Mar 12, 1998)
permit \n explicitly in character classes (Sep 24, 2000)
close() is now a function. it returns whatever the library fclose returns,
and -1 for closing a file or pipe that wasn't opened.
added support for posix character class names like [:digit:] (Nov 16, 2001)
fflush() or fflush("") flushes all files and pipes.
length(arrayname) returns number of elements (Jan 1, 2002)
subtle change to split: if source is empty, number of elems
is always 0 and the array is not set.
values of $0 et al are preserved in the END block.
-version and --version options to print the version and exit (Jan 17, 2006)
a change to FS is now noticed immediately for subsequent splits.
changed srand() to return the previous seed (which is 1
on the first call of srand).
split(s, a, //
) now behaves the same as split(s, a, "") (Aug 7, 2011)
undocumented features:
command line switch -d dumps debug info.
valid filenames /dev/stdin /dev/stdout /dev/stderr
can use **
or **
= in place of ^ for exponention.
array SYMTAB holds info.
from commandline: -F "" is nojoy setting FS to null
use -v FS="" instead.
the new escapes \a \v \xhh are nojoy from the -v var=value
(although they work fine in the code)
use octal instead ie -v alert=\007
system() returns errorcode / 256 (in windows)
cmd |
getline; n = close(cmd); n is the errorcode
nojoy re -v e== use -v e=\075
-Ft sets FS to \t tab; whereas -v FS=t is the letter t.