Repeating Ourselves Less with M4
This guide demonstrates how to condense the httpd.conf file using macros. In a previous post, the author mentioned having to repeat identical code blocks for blocking malicious routes. Fortunately, OpenBSD comes with a utility called m4 that can greatly reduce repetitive parts. There are two types of macros: those built into programming languages and those that manipulate text. m4 falls into the second category, being a standalone program that can be used with any text manipulation.
It has built-in functions and allows for substitution of values, but it's not a language parser. The guide explains how to use m4 to create macros for URL blocking and server configurations, making the httpd.conf file shorter and easier to modify.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.