From 117486d4a7aea2c407f1d1350f906ab0f27cf177 Mon Sep 17 00:00:00 2001 From: akefirad Date: Fri, 16 Apr 2021 18:53:35 +0200 Subject: [PATCH] [Fix] `bash_completion`: check if `compinit` is called before calling it Fixes #2489. --- bash_completion | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bash_completion b/bash_completion index e10138a..3e72500 100644 --- a/bash_completion +++ b/bash_completion @@ -84,11 +84,14 @@ __nvm() { # called bashcompinit that will create a complete in ZSH. If the user is in # ZSH, load and run bashcompinit before calling the complete function. if [[ -n ${ZSH_VERSION-} ]]; then - # Calling compinit first and then bashcompinit as mentioned by zsh man page. - autoload -U +X compinit && if [[ ${ZSH_DISABLE_COMPFIX-} = true ]]; then - compinit -u - else - compinit + # First calling compinit (only if not called yet!) + # and then bashcompinit as mentioned by zsh man page. + if ! command -v compinit > /dev/null; then + autoload -U +X compinit && if [[ ${ZSH_DISABLE_COMPFIX-} = true ]]; then + compinit -u + else + compinit + fi fi autoload -U +X bashcompinit && bashcompinit fi