hledger/shell-completion/hledger-completion.bash.m4
Vladimir Zhelezov 419817e656 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.
2021-02-28 08:33:18 +01:00

30 lines
820 B
Plaintext

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 <<TEXT
undivert(`commands.txt')dnl
TEXT
read -r -d "" _hledger_complist_query_filters <<TEXT
undivert(`query-filters.txt')dnl
TEXT
read -r -d "" _hledger_complist_generic_options <<TEXT
undivert(`generic-options.txt')dnl
TEXT
# Dashes are replaced by m4 with underscores to form valid identifiers
# Referenced by indirect expansion of $subcommandOptions
dnl
include(`foreach2.m4')dnl
foreach(`cmd', (include(`commands-list.txt')), `
read -r -d "" _hledger_complist_options_`'translit(cmd, -, _) <<TEXT
undivert(options-cmd.txt)dnl
TEXT
')dnl
return 0