intersection is empty, the empty string is returned; so sub‐
str("ABC", 1, 0) = "" and substr("ABC", -4, 6) = "A".
• Every string, including the empty string, matches the empty string at the front so, s ~ // and s ~ "", are always 1 as is match(s, //) and match(s, ""). The last two set RLENGTH to 0.
• index(s, t) is always the same as match(s, t1) where t1 is the same as t with metacharacters escaped. Hence consistency with match requires that index(s, "") always returns 1. Also the condition, index(s,t)
!= 0 if and only t is a substring of s, requires index("","") = 1.
• If getline encounters end of file, getline var, leaves var unchanged. Similarly, on entry to the END actions, $0, the fields and NF have their value unaltered from the last record.
ENVIRONMENT VARIABLES
Mawk recognizes these variables:
MAWKBINMODE
(see COMPATIBILITY ISSUES)
MAWK_LONG_OPTIONS
If this is set, mawk uses its value to decide what to do with GNU‐style long options:
allow Mawk allows the option to be checked against the (small) set of long options it recognizes.
The long names from the -W option are recognized, e.g., --version is derived from -Wversion.
error Mawk prints an error message and exits. This is the default.
ignore Mawk ignores the option, unless it happens to be one of the one it recognizes.
warn Print an warning message and otherwise ignore the option.
If the variable is unset, mawk prints an error message and exits.
WHINY_USERS
This is a gawk 3.1.0 feature, removed in the 4.0.0 release. It tells mawk to sort array indices before it starts to iterate over the elements of an array.
SEE ALSO
grep(1)
Aho, Kernighan and Weinberger, The AWK Programming Language, Addison‐Wesley Publishing, 1988, (the AWK book), defines the language, opening with a tutorial and advancing to many interesting programs that delve into
issues of software design and analysis relevant to programming in any language.
The GAWK Manual, The Free Software Foundation, 1991, is a tutorial and language reference that does not attempt the depth of the AWK book and assumes the reader may be a novice programmer. The section on AWK arrays
is excellent. It also discusses POSIX requirements for AWK.
mawk‐arrays(7) discusses mawk’s implementation of arrays.
mawk‐code(7) gives more information on the -W dump option.
BUGS
mawk implements printf() and sprintf() using the C library functions, printf and sprintf, so full ANSI compatibility requires an ANSI C library. In practice this means the h conversion qualifier may not be available.
Also mawk inherits any bugs or limitations of the library functions.
Implementors of the AWK language have shown a consistent lack of imagination when naming their programs.
AUTHOR
Mike Brennan (brennan@whidbey.com).
Thomas E. Dickey <dickey@invisible‐island.net>.
Version 1.3.4 2023‐04‐04 MAWK(1)