Issue: Bash Completion script gives error

(Thomas Manson) #1

Hi Guys,

I’m trying to figure out why on a brand new installation, I’ve errors when I try to enable bash completion.

The trouble is that I don’t have the “have” function that is used in every completion scripts.
I could add it by hand but :

  • I don’t want to customize brew like this, it might break later
  • Other user may have the same issue

Any idea ?

Here is my issue on GitHub :


(Paul M Lambert) #2

I think the instructions are incorrect.

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

That works great for me with bash-completion@2 installed.

For bash-completion I think you use:

[[ -r "/usr/local/etc/profile.d/" ]] && . "/usr/local/etc/profile.d/"

That script itself will then loop through the directory of included files, as appropriate. No need to do that yourself.

I don’t have time at the moment to file a bug or PR to fix the instructions; you’re more than welcome to do so, as it’s the best way to ensure the problem doesn’t affect anyone else. I’ll try to remember to do it when I’m at my Mac and can verify a patch, if no one else has.



(Thomas Manson) #3

Well, I did fill an issue to Homebrew (the link is in my initial post), but I was told, quite unpleasantly, to go get some help elsewhere.

That’s why I open this topic here.

on my old mac, I was using this:

# brew bash completion
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion

The file still exists, but I’m not sure it’s the correct way of doing.

BTW, how do I test that bash completion is really working ?
What’s more than the classic built in bash completion ?


(Thomas Manson) #4

there’s a version 2 of bash-completion ?

What an unexpected rich topic :wink:

Thanks for your response !


(Sean Molenaar) #5

yes, it’s not compatible with the default macOS bash though.


(Thomas Manson) #6

ok, I’ve installed bash 5 with Brew, so I’ll give it a try !


(Thomas Manson) #7

works perfectly with bash-completion@2

thanks :slight_smile: