Fix _hledger_extension_completion when called by path...

Could break if called with ./funky-path/with-dashes/hledger-ui
This commit is contained in:
Vladimir Zhelezov 2020-12-15 08:38:21 +01:00
parent fb3577d3e0
commit fdac46d68a
2 changed files with 10 additions and 6 deletions

View File

@ -117,9 +117,11 @@ _hledger_completion_function() {
} }
_hledger_extension_completion_function() { _hledger_extension_completion_function() {
# Pretend that hledger is called with given extension local cmd=${1##*/}
# as first argument and call main completion function local ext=${cmd#hledger-}
COMP_WORDS=("hledger" "${1#*-}" "${COMP_WORDS[@]:1}") # Pretend that hledger is called with the given extension
# as the first argument and call main completion function
COMP_WORDS=("hledger" "$ext" "${COMP_WORDS[@]:1}")
COMP_CWORD=$((COMP_CWORD + 1)) COMP_CWORD=$((COMP_CWORD + 1))
_hledger_completion_function "hledger" "${@:1}" _hledger_completion_function "hledger" "${@:1}"
} }

View File

@ -117,9 +117,11 @@ _hledger_completion_function() {
} }
_hledger_extension_completion_function() { _hledger_extension_completion_function() {
# Pretend that hledger is called with given extension local cmd=${1##*/}
# as first argument and call main completion function local ext=${cmd#hledger-}
COMP_WORDS=("hledger" "${1#*-}" "${COMP_WORDS[@]:1}") # Pretend that hledger is called with the given extension
# as the first argument and call main completion function
COMP_WORDS=("hledger" "$ext" "${COMP_WORDS[@]:1}")
COMP_CWORD=$((COMP_CWORD + 1)) COMP_CWORD=$((COMP_CWORD + 1))
_hledger_completion_function "hledger" "${@:1}" _hledger_completion_function "hledger" "${@:1}"
} }