[Bash-completion-devel] RFC: Turn on -o filenames in _filedir() if compopt is available
Freddy Vulto
fvulto at gmail.com
Thu Dec 3 18:22:00 UTC 2009
On 091130 22:15, Crestez Dan Leonard wrote:
> On Mon, 2009-11-30 at 21:50 +0200, Ville Skyttä wrote:
> > On Monday 30 November 2009, Crestez Dan Leonard wrote:
> > > > (No strong opinions whether the test should be
> > > > "type compopt &>/dev/null" or "${BASH_VERSINFO[0]} -ge 4" but I like
> > > > the former a bit better.)
> > >
> > > compopt is so very useful it might be worth creating a _compopt wrapper
> >
> > There actually was one (although badly implemented) for a while but it was
> > removed because it was not used nor seen necessary.
> I tried sending two patches and both times I felt the need to use
> compopt.
We had a global $compopt, but we wanted to get rid of the pollution
bash-completion globals are causing in everyone's environment. That's
why this is preferred instead:
type compopt &>/dev/null && compopt ...
We could alias this to a function _compopt, but since bash-completion is
targetted for bash-3, I'd rather turn it the other way around like we do
for _filedir:
_modify_completions_in_some_way() {
if [${BASH_VERSINFO[0]} -ge 4]; then
compopt ...
else
# Bash-3
# Manually tweak the completions
fi
}
Creating descriptive function wrappers around the few situations where
compopt would prove useful, now result in hooks we can use for improving
bash-completion under bash-3.
Inside your completion code you'd typically call the function wrapper
instead of compopt directly.
Regards,
Freddy Vulto
http://fvue.nl
More information about the Bash-completion-devel
mailing list