HP-UX Reference (11i v2 04/09) - 1 User Commands A-M (vol 1)

m
m4(1) m4(1)
(i.e., and ).
decr Returns the value of its argument decremented by 1.
define The second argument is installed as the value of the macro whose name is the first
argument. Each occurrence of $n in the replacement text, where n is a digit, is
replaced by the nth argument. Argument 0 is the name of the macro; missing argu-
ments are replaced by the null string;
$# is replaced by the number of arguments; $*
is replaced by a list of all the arguments separated by commas;
$@ is equivalent to $*,
but each argument is quoted (with the current quotes).
defn Returns the quoted definition of its arguments. It is useful for renaming macros,
especially built-ins.
divert m4 maintains 10 output streams, numbered 0 to 9. The final output is the concatena-
tion of the streams in numerical order; initially, stream 0 is the current stream. The
divert macro changes the current output stream to its (digit-string) argument. Out-
put diverted to a stream other than 0 through 9 is discarded.
divnum Returns the value of the current output stream.
dnl Reads and discards characters up to and including the next newline.
dumpdef Prints current names and definitions, for the named items, or for all if no arguments
are given.
errprint Prints its argument on the diagnostic output file.
eval Evaluates its argument as an arithmetic expression, using 32-bit arithmetic. Opera-
tors include +, -, *, /, %, ** (exponentiation), bitwise
&, |, ˆ, and ˜, relationals, and
parentheses. Octal and hexadecimal numbers may be specified as in C. The second
argument specifies the radix for the result; the default is 10. The third argument may
be used to specify the minimum number of digits in the result.
hpux Is a predefined object with a null value.
ifdef If the first argument is defined, the value is the second argument; otherwise the third.
If there is no third argument, the value is null. The word
unix is predefined on HP-
UX system versions of m4.
ifelse Has three or more arguments. If the first argument is the same string as the second,
then the value is the third argument. If not, and if there are more than four argu-
ments, the process is repeated with arguments 4, 5, 6 and 7. Otherwise, the value is
either the fourth string, or, if it is not present, null.
include Returns the contents of the file named in the argument.
incr Returns the value of its argument incremented by 1. The value of the argument is
calculated by interpreting an initial digit-string as a decimal number.
index Returns the position in its first argument where the second argument begins (zero ori-
gin), or 1 if the second argument does not occur.
len Returns the number of characters in its argument.
m4exit Causes immediate exit from m4. Argument 1, if given, is the exit code; the default is
0.
m4wrap Argument 1 is pushed back at final EOF; for example: m4wrap(‘cleanup()’)
maketemp Fills in a string of XXXXX in its argument with the current process ID.
popdef Removes current definition of its arguments, exposing the previous one, if any.
pushdef Similar to define, but saves any previous definition.
shift Returns all but its first argument. The other arguments are quoted and pushed back
with commas in between. The quoting nullifies the effect of the extra scan that will
subsequently be performed.
sinclude Identical to include, except that it says nothing if the file is inaccessible.
substr Returns a substring of its first argument. The second argument is a zero-origin
number selecting the first character; the third argument indicates the length of the
substring. A missing third argument is taken to be large enough to extend to the end
Section 1540 Hewlett-Packard Company 2 HP-UX 11i Version 2: September 2004