This version of
m4 contains a few facilities that do not exist
in System V
m4. These extra facilities are all suppressed by
using the -G command line option (see Invoking m4), unless overridden by other command line options.
$nnotation for macro arguments, n can contain several digits, while the System V
m4only accepts one digit. This allows macros in GNU
m4to take any number of arguments, and not only nine (see Arguments).
This means that
define(`foo', `$11') is ambiguous between
implementations. To portably choose between grabbing the first
parameter and appending 1 to the expansion, or grabbing the eleventh
parameter, you can do the following:
define(`a1', `A1') ⇒ dnl First argument, concatenated with 1 define(`_1', `$1')define(`first1', `_1($@)1') ⇒ dnl Eleventh argument, portable define(`_9', `$9')define(`eleventh', `_9(shift(shift($@)))') ⇒ dnl Eleventh argument, GNU style define(`Eleventh', `$11') ⇒ first1(`a', `b', `c', `d', `e', `f', `g', `h', `i', `j', `k') ⇒A1 eleventh(`a', `b', `c', `d', `e', `f', `g', `h', `i', `j', `k') ⇒k Eleventh(`a', `b', `c', `d', `e', `f', `g', `h', `i', `j', `k') ⇒k
Also see the
argn macro (see Shift).
divert(see Divert) macro can manage more than 9 diversions. GNU
m4treats all positive numbers as valid diversions, rather than discarding diversions greater than 9.
sincludeare sought in a user specified search path, if they are not found in the working directory. The search path is specified by the -I option and the
M4PATHenvironment variable (see Search Path).
undivertcan be non-numeric, in which case the named file will be included uninterpreted in the output (see Undivert).
formatbuiltin, which is modeled after the C library function
regexp(see Regexp) and
patsubst(see Patsubst) builtins. Some BSD implementations use extended regular expressions instead.
dumpdefand macro tracing can be controlled with
debugmode(see Debug Levels).
debugfile(see Debug Output).
maketemp(see Mkstemp) macro behaves like
mkstemp, creating a new file with a unique name on every invocation, rather than following the insecure behavior of replacing the trailing ‘X’ characters with the
The debugging and tracing facilities in GNU
m4 are much
more extensive than in most other versions of