stecman / symfony-console-completion

Automatic tab-key completion for Symfony console application options, arguments and parameters
MIT License
420 stars 26 forks source link

Check if bash_completion is installed. #13

Closed pjcdawkins closed 9 years ago

pjcdawkins commented 9 years ago

I'm not sure if this is the right approach, but this is to avoid these kinds of errors on (weird) Bash shells when bash-completion is not installed.

-bash: _get_comp_words_by_ref: command not found
-bash: __ltrim_colon_completions: command not found
stecman commented 9 years ago

Hmm, this is another thing where I'm not sure if it belongs in this module or in user code.. I've seen that error come up when bash-completion is missing / not loaded. Have you seen it in any other cases? Looking at the bash-completion repo, those two functions appeared in version 1.2 (mid 2010) so they're relatively recent; older versions would also see those errors.

Code wise, I think this is a little bit clearer:

if [ "$(type -t _get_comp_words_by_ref)" == "function" ]; then
    ...
fi;
pjcdawkins commented 9 years ago

Personally I can deal with this in my own code. I haven't found a clean way to check for the installed version of bash-completion itself. That type command doesn't work on my Mac by the way.