Bash completions broken I am using following bash completions installed via brew:

bash-completion
bash-completion@2


My .bashrc looks like:

if [ -f /usr/local/share/bash-completion/bash_completion ]; then
. /usr/local/share/bash-completion/bash_completion
fi


if [ -f /usr/local/Cellar/bash-completion/1.3_2/etc/bash_completion ]; then
  BASH_COMPLETION=/usr/local/Cellar/bash-completion/1.3_2/etc/bash_completion
  . /usr/local/Cellar/bash-completion/1.3_2/etc/bash_completion
fi


The problem is when I press TAB on an empty prompt on keyboard I get the error:

-bash: words: bad array subscript

After removing /usr/local/share/bash-completion/bash_completion from .bashrc error doesn’t happen but I miss out on many completions.

What is the problem here? How can I fix it?
The solution is that I should call bash completion from 1.3.2 before bash-completion@2. Following is how my .bashrc looks, and this solves the problem:

if [ -f /usr/local/Cellar/bash-completion/1.3_2/etc/bash_completion ]; then
  BASH_COMPLETION=/usr/local/Cellar/bash-completion/1.3_2/etc/bash_completion
  . /usr/local/Cellar/bash-completion/1.3_2/etc/bash_completion
fi

if [ -f /usr/local/share/bash-completion/bash_completion ]; then
    . /usr/local/share/bash-completion/bash_completion
fi