Last active
November 25, 2020 22:29
-
-
Save louisswarren/fc5cd9c91387d9822dcbcc16909341a6 to your computer and use it in GitHub Desktop.
Mutex files with preprocessing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Generate all .m4 file outputs - being lazy and just re-running the script | |
# with an argument. To be safe AND lazy, add a useless argument just to make | |
# sure this doesn't fork bomb me some day if I change how this is done. | |
if [ -z "$1" ]; then | |
exec find $(dirname -- "$0") -name '*.m4' -exec "./$0" '{}' 'safety' \; | |
fi | |
# Generate $1 from its .m4 file. | |
# Piping this program into .gitignore is a good idea | |
echo "${1%.m4}" | |
m4 --prefix-builtins - "$1" > "${1%.m4}" << 'EOF' | |
m4_define(HOST, m4_esyscmd(`echo -n $(hostname)')) | |
m4_define(`if_host', `m4_ifelse(HOST, $1, $2, $3)') | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment