Skip to content

Commit 117486d

Browse files
akefiradljharb
authored andcommitted
[Fix] bash_completion: check if compinit is called before calling it
Fixes #2489.
1 parent 07253ec commit 117486d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

bash_completion

+8-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ __nvm() {
8484
# called bashcompinit that will create a complete in ZSH. If the user is in
8585
# ZSH, load and run bashcompinit before calling the complete function.
8686
if [[ -n ${ZSH_VERSION-} ]]; then
87-
# Calling compinit first and then bashcompinit as mentioned by zsh man page.
88-
autoload -U +X compinit && if [[ ${ZSH_DISABLE_COMPFIX-} = true ]]; then
89-
compinit -u
90-
else
91-
compinit
87+
# First calling compinit (only if not called yet!)
88+
# and then bashcompinit as mentioned by zsh man page.
89+
if ! command -v compinit > /dev/null; then
90+
autoload -U +X compinit && if [[ ${ZSH_DISABLE_COMPFIX-} = true ]]; then
91+
compinit -u
92+
else
93+
compinit
94+
fi
9295
fi
9396
autoload -U +X bashcompinit && bashcompinit
9497
fi

0 commit comments

Comments
 (0)