Comment 58 for bug 769866

Revision history for this message
Victsm (victor-nju) wrote :

My situation is a little bit different, and I believe some others share my situation.
By applying the fix in #10, it only solves the problem for some commands, i.e. those listed in that for loop.
However, for commands such as mplayer and dpkg, it still does not work.
Also, I do not have file acroread.sh under /etc/bash_completion.d/
So, I cannot delete this file as others do.
I tried to move away all the files under /etc/bash_completion.d/, and the problem still remains for some commands such as xfig.
This means, if there is a problem, it has to be within /etc/bash_completion
I noticed that on my laptop, both gzip and mplayer have an autocompletion configuration file under /etc/bash_completion.d/,
and autocompletion works fine for gzip but not for mplayer.
A comparison between the configurations files reveal that:
in line 43 of gzip's configurationfile, function _compopt_o_filenames is called before autocompletion at line 44,
but for mplayer's configuration file, in the last case starting at line 253, function _filedir is invoked without calling function _compopt_o_filenames.
By adding an invocation to the function _compopt_o_filenames before line 254 in mplayer's configuration file, it makes mplayer work as expected.

This gives the idea of how to solve the problem with /etc/bash_completion
In /etc/bash_completion, line 72-126 defines the application specific autocompletion for many commands,
and they are also without calling function _compopt_o_filenames first.
However, function _compopt_o_filenames is defined in line 618, thus it cannot be called at line 72.
My fix is to paste the implementation of this function in line 623-624 before line 72.
However, there is still another problem.
The complete commands defined in line 72-126 (now 74-128) are only for filename completion.
So, the option "-o plusdirs" needs to be added to each complete command to also include the result of directory name completion.
e.g. "complete -f -X '!*.fig' xfig" -> "complete -f -o plusdirs -X '!*.fig' xfig"
After this, all the commands listed in line 74-128 work properly.

As a conclusion, this should be a bug in /etc/bash_completion and those configuration files under /etc/bash_completion.d/
My solution only fix those commands listed in /etc/bash_completion.
For commands that have a separate configuration file under /etc/bash_completion.d/, the fix should be applied to the configuration file individually.