[Fix] `bash_completion`: check if `compinit` is called before calling it

Fixes #2489.
akefirad 2021-04-16 18:53:35 +02:00 committed by Jordan Harband
parent 07253ecd51
commit 117486d4a7
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
1 changed files with 8 additions and 5 deletions

View File

@ -84,11 +84,14 @@ __nvm() {
# called bashcompinit that will create a complete in ZSH. If the user is in # called bashcompinit that will create a complete in ZSH. If the user is in
# ZSH, load and run bashcompinit before calling the complete function. # ZSH, load and run bashcompinit before calling the complete function.
if [[ -n ${ZSH_VERSION-} ]]; then if [[ -n ${ZSH_VERSION-} ]]; then
# Calling compinit first and then bashcompinit as mentioned by zsh man page. # First calling compinit (only if not called yet!)
autoload -U +X compinit && if [[ ${ZSH_DISABLE_COMPFIX-} = true ]]; then # and then bashcompinit as mentioned by zsh man page.
compinit -u if ! command -v compinit > /dev/null; then
else autoload -U +X compinit && if [[ ${ZSH_DISABLE_COMPFIX-} = true ]]; then
compinit compinit -u
else
compinit
fi
fi fi
autoload -U +X bashcompinit && bashcompinit autoload -U +X bashcompinit && bashcompinit
fi fi