[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes various builtins, that do not really belong in any of the previous chapters.
13.1 Printing error messages 13.2 Exiting from m4
Exiting from m4
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
You can print error messages using errprint
:
errprint(message, ...) |
The expansion of errprint
is void.
errprint(`Illegal arguments to forloop ') error-->Illegal arguments to forloop => |
A trailing newline is not printed automatically, so it must be
supplied as part of the argument, as in the example. (BSD flavored
m4
's do append a trailing newline on each errprint
call).
To make it possible to specify the location of the error, two utility builtins exist:
__file__ __line__ |
errprint(`m4:'__file__:__line__: `Input error ') error-->m4:56.errprint:2: Input error => |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
m4
If you need to exit from m4
before the entire input has been
read, you can use m4exit
:
m4exit(opt code) |
m4
to exit, with exit code code. If
code is left out, the exit code is zero.
define(`fatal_error', `errprint(`m4: '__file__: __line__`: fatal error: $* ')m4exit(1)') => fatal_error(`This is a BAD one, buster') error-->m4: 57.m4exit: 5: fatal error: This is a BAD one, buster |
After this macro call, m4
will exit with exit code 1. This macro
is only intended for error exits, since the normal exit procedures are
not followed, e.g., diverted text is not undiverted, and saved text
(see section 7.5 Saving input) is not reread.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |