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.
This commit is contained in:
parent
2e44fe9e90
commit
419817e656
@ -63,7 +63,7 @@ $(CMDOPTFILES)
|
|||||||
endef
|
endef
|
||||||
|
|
||||||
hledger-completion.bash: $(M4DEPS)
|
hledger-completion.bash: $(M4DEPS)
|
||||||
m4 hledger-completion.bash.m4 > $@
|
m4 -g hledger-completion.bash.m4 > $@
|
||||||
|
|
||||||
commands.txt:
|
commands.txt:
|
||||||
printf "%s\n" $(COMMANDS) > $@
|
printf "%s\n" $(COMMANDS) > $@
|
||||||
|
|||||||
@ -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
|
# Include lists of commands and options generated by the Makefile using the
|
||||||
# m4 macro processor.
|
# m4 macro processor.
|
||||||
# Included files must have exactly one newline at EOF to prevent weired errors.
|
# Included files must have exactly one newline at EOF to prevent weired errors.
|
||||||
|
|
||||||
read -r -d "" _hledger_complist_commands <<TEXT
|
read -r -d "" _hledger_complist_commands <<TEXT
|
||||||
include(`commands.txt')dnl
|
undivert(`commands.txt')dnl
|
||||||
TEXT
|
TEXT
|
||||||
|
|
||||||
read -r -d "" _hledger_complist_query_filters <<TEXT
|
read -r -d "" _hledger_complist_query_filters <<TEXT
|
||||||
include(`query-filters.txt')dnl
|
undivert(`query-filters.txt')dnl
|
||||||
TEXT
|
TEXT
|
||||||
|
|
||||||
read -r -d "" _hledger_complist_generic_options <<TEXT
|
read -r -d "" _hledger_complist_generic_options <<TEXT
|
||||||
include(`generic-options.txt')dnl
|
undivert(`generic-options.txt')dnl
|
||||||
TEXT
|
TEXT
|
||||||
|
|
||||||
# Dashes are replaced by m4 with underscores to form valid identifiers
|
# Dashes are replaced by m4 with underscores to form valid identifiers
|
||||||
@ -22,7 +22,7 @@ dnl
|
|||||||
include(`foreach2.m4')dnl
|
include(`foreach2.m4')dnl
|
||||||
foreach(`cmd', (include(`commands-list.txt')), `
|
foreach(`cmd', (include(`commands-list.txt')), `
|
||||||
read -r -d "" _hledger_complist_options_`'translit(cmd, -, _) <<TEXT
|
read -r -d "" _hledger_complist_options_`'translit(cmd, -, _) <<TEXT
|
||||||
include(options-cmd.txt)dnl
|
undivert(options-cmd.txt)dnl
|
||||||
TEXT
|
TEXT
|
||||||
')dnl
|
')dnl
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user