From 419817e65607141997ec2701c672bc2fdd805dc1 Mon Sep 17 00:00:00 2001 From: Vladimir Zhelezov Date: Sun, 20 Dec 2020 07:56:47 +0100 Subject: [PATCH] Prevent unwanted m4 macro expansion + `-g` GNU compatibility flag Most of the included files are meant to be output literally, without any macro processing. Using `undivert` in place of `include` achieves that. This is a safety net against unsanitized input generated during the build. Also, developers editing the shell code stub shouldn't be constantly alert about triggering accidental macro expansion. In order that `undivert` mimics GNU behaviour on BSDs, the `-g` flag is used for the m4 invocation. --- shell-completion/Makefile | 2 +- shell-completion/hledger-completion.bash.m4 | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shell-completion/Makefile b/shell-completion/Makefile index e61d71066..9c9deccdd 100644 --- a/shell-completion/Makefile +++ b/shell-completion/Makefile @@ -63,7 +63,7 @@ $(CMDOPTFILES) endef hledger-completion.bash: $(M4DEPS) - m4 hledger-completion.bash.m4 > $@ + m4 -g hledger-completion.bash.m4 > $@ commands.txt: printf "%s\n" $(COMMANDS) > $@ diff --git a/shell-completion/hledger-completion.bash.m4 b/shell-completion/hledger-completion.bash.m4 index a5636417c..4e4685944 100644 --- a/shell-completion/hledger-completion.bash.m4 +++ b/shell-completion/hledger-completion.bash.m4 @@ -1,19 +1,19 @@ -include(`hledger-completion.bash.stub')dnl +undivert(`hledger-completion.bash.stub')dnl # Include lists of commands and options generated by the Makefile using the # m4 macro processor. # Included files must have exactly one newline at EOF to prevent weired errors. read -r -d "" _hledger_complist_commands <