diff --git a/shell-completion/hledger-completion.bash b/shell-completion/hledger-completion.bash index 00aa0222e..d6dc14502 100644 --- a/shell-completion/hledger-completion.bash +++ b/shell-completion/hledger-completion.bash @@ -41,11 +41,12 @@ _hledger_completion_function() { )" return 0 fi - if [[ $cur == -* ]]; then - # Replace dashes with underscores and use indirect expansion - subcommandOptions=_hledger_complist_options_${subcommand//-/_} - _hledger_compreply "$(_hledger_compgen "${!subcommandOptions}")" + # Replace dashes with underscores and use indirect expansion + subcommandOptions=_hledger_complist_options_${subcommand//-/_} + + if [[ $cur == -* ]]; then + _hledger_compreply "$(_hledger_compgen "${!subcommandOptions}")" # Suspend space on completion of long options requiring an argument [[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace diff --git a/shell-completion/hledger-completion.bash.m4 b/shell-completion/hledger-completion.bash.m4 index cf6749c6d..bb1499867 100644 --- a/shell-completion/hledger-completion.bash.m4 +++ b/shell-completion/hledger-completion.bash.m4 @@ -41,11 +41,12 @@ _hledger_completion_function() { )" return 0 fi - if [[ $cur == -* ]]; then - # Replace dashes with underscores and use indirect expansion - subcommandOptions=_hledger_complist_options_${subcommand//-/_} - _hledger_compreply "$(_hledger_compgen "${!subcommandOptions}")" + # Replace dashes with underscores and use indirect expansion + subcommandOptions=_hledger_complist_options_${subcommand//-/_} + + if [[ $cur == -* ]]; then + _hledger_compreply "$(_hledger_compgen "${!subcommandOptions}")" # Suspend space on completion of long options requiring an argument [[ ${COMPREPLY[0]} == --*= ]] && compopt -o nospace