diff --git a/shell-completion/hledger-completion.bash b/shell-completion/hledger-completion.bash index f53e385de..0b8ecd48c 100644 --- a/shell-completion/hledger-completion.bash +++ b/shell-completion/hledger-completion.bash @@ -36,15 +36,9 @@ _hledger_completion_function() { # $subcommand == bal --> balance, balancesheet, balancesheetequity, etc. # Do not ignore them! if ((i == cword)); then - local subcommandMatches - subcommandMatches=$(grep -c "^$subcommand" <<< "$_hledger_complist_commands") - if ((subcommandMatches > 1)); then - subcommand= - break - else - _hledger_compreply "$subcommand" - return 0 - fi + compopt +o filenames + _hledger_compreply "$(_hledger_compgen "$_hledger_complist_commands")" + return 0 fi break done diff --git a/shell-completion/hledger-completion.bash.m4 b/shell-completion/hledger-completion.bash.m4 index 2c30c8cf9..9bfc23a32 100644 --- a/shell-completion/hledger-completion.bash.m4 +++ b/shell-completion/hledger-completion.bash.m4 @@ -36,15 +36,9 @@ _hledger_completion_function() { # $subcommand == bal --> balance, balancesheet, balancesheetequity, etc. # Do not ignore them! if ((i == cword)); then - local subcommandMatches - subcommandMatches=$(grep -c "^$subcommand" <<< "$_hledger_complist_commands") - if ((subcommandMatches > 1)); then - subcommand= - break - else - _hledger_compreply "$subcommand" - return 0 - fi + compopt +o filenames + _hledger_compreply "$(_hledger_compgen "$_hledger_complist_commands")" + return 0 fi break done