[Bash-completion-devel] Towards dynamic completion loading

Igor Murzov e-mail at date.by
Sun Oct 23 22:21:58 UTC 2011


> > Why try to load different completions for the same program.
> 
> Because it might not be the same program; for example we want different
> completions for /etc/init.d/mysql and /usr/bin/mysql.

Ok, if you really need this, then we should work with real path here at least. 
Using relative paths is something that looks odd to me.

Also how you want to distinguish among different programs with the same name? 
Is the path to a binary really makes any sense for this? I don't think so. If 
we plan to distinguish among different variants of the program like, for 
example, GNU make and BSD make, then we should rather examine result of `make 
--version | grep 'GNU Make'`. And such things probably should be done in 
completions/make itself, not in _completion_loader().

> > 2.
> > 
> >>    # Special case for init.d scripts.
> >>    if [[ $1 == /etc?(/rc.d)/init.d/* ]]; then
> >>    
> >>        . "$compdir/service" &>/dev/null && return 124 || return 1
> >>    
> >>    fi
> > 
> > This special case will not work if one do
> > $ cd /etc
> > $ ./init.d/rc.mpd st<TAB>
> 
> That doesn't work in the master branch either.
 
I know :) But this condition is incorrect anyway, and fixing it will make 
*every* call to _completion_loader() slower.

> > To my mind this case is not that necessary. We can merge
> > completions/service to bash_completion script.
> 
> I have a strong opinion that we should be moving things *away* from
> bash_completion, not into it.

There is a lot we can move away from bash_completion, but it is also necessary 
to make _completion_loader() clear, light and fast. Having special cases is 
not good.


-- Igor



More information about the Bash-completion-devel mailing list