October 2024
Intermediate to advanced
272 pages
6h 54m
English
Macro substitution, also known as macro expansion, is the workhorse of m4.
Simple macros are names replaced at runtime with their definitions. The following classical example greets the book author by using the function define(name, definition) to define a macro named AUTHOR. The value (definition) is Dmitry Z.. No quotation marks are needed, and spaces are allowed in the definition. By the way, define is a macro too.
| | define(AUTHOR, Dmitry Z.) |
| | Hello, AUTHOR! |
Let’s execute the code:
| | /home/dzseven> m4 code/m4/greet.m4 |
| | |
| | Hello, Dmitry Z.! |
The substitution worked, but where does this bothersome blank line come from? m4 isn’t trying to be too clever; quoting myself, “anything ...
Read now
Unlock full access