Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 649986 - app-shells/bash-completion: broken dynamic completion loading in _filedir()
Summary: app-shells/bash-completion: broken dynamic completion loading in _filedir()
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Michał Górny
URL: https://github.com/scop/bash-completi...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-09 09:13 UTC by Alexander Sergeyev
Modified: 2018-03-11 15:56 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Sergeyev 2018-03-09 09:13:02 UTC
I describe the problem on bash for vim, but I believe the problem is not limited to vim.

First, I hit questionable autocompletion behaviour:
# mkdir /tmp/bashcomp-test; cd /tmp/bashcomp-test; touch foo bar ld.so.test.conf
# ls
bar              foo              ld.so.test.conf
# vim <Tab><Tab>
bar  foo

So, no ld.so.test.conf file in the vim autocompletion output. I checked the vim-specific autocompletion file: /usr/share/bash-completion/completions/vim. It uses _filedir function when not completing an option. But it works differently:

# unset COMPREPLY; cur="" _filedir ; echo "${COMPREPLY[@]}"
bar ld.so.test.conf foo

But then it seems that the vim-specific autocompletion is not actually used:
# complete | grep vim
complete -F _filedir_xspec rvim
complete -F _filedir_xspec gvim
complete -o filenames -F _vim vix
complete -o filenames -F _vim vim
complete -F _filedir_xspec rgvim
complete -o filenames -F _vim vi

The source for these generic rules is at /usr/share/bash-completion/bash_completion:
_install_xspec '*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)' vi vim gvim rvim view rview rgvim rgview gview emacs xemacs sxemacs kate kwrite

But then after doing the following:
# complete -r vim
# complete | grep vim
complete -F _filedir_xspec rvim
complete -F _filedir_xspec gvim
complete -F _filedir_xspec rgvim
# vim <Tab> <Tab>
bar             foo              ld.so.test.conf
# complete | grep vim
complete -o filenames -F _vim rview
complete -o filenames -F _vim rvim
complete -F _filedir_xspec gvim
complete -o filenames -F _vim view
complete -o filenames -F _vim vim
complete -o filenames -F _vim ex
complete -F _filedir_xspec rgvim
complete -o filenames -F _vim vi
complete -o filenames -F _vim vimdiff

So what happens is that we have a generic completion via _filedir_xspec, which blocks _vim() from loading. But with _filedir_xspec manually removed, _vim() is loaded on the first use.
Thus, it looks like app-specific completion is not working as expected and might be blocked by default completion rules.

Installed packages:
=app-shells/bash-completion-2.7-r2
=app-editors/vim-8.0.1428
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-03-10 10:54:03 UTC
Thanks for doing the research. This is something that needs to be addressed upstream, though. Would you like to file a bug upstream [1] yourself, or should I proxy for you?

[1]:https://github.com/scop/bash-completion/issues
Comment 2 Alexander Sergeyev 2018-03-10 12:43:57 UTC
> Would you like to file a bug upstream [1] yourself, or should I proxy for you?

Oh, for some reason I was pretty sure this is a gentoo-specific project. I filed a new bug in the upstream (see $URL).
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-03-10 17:51:22 UTC
Thanks a lot. I'm subscribed to the issue now. Upstream is quite responsive, so we can expect some answer soon-ish.
Comment 4 Larry the Git Cow gentoo-dev 2018-03-11 15:56:20 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ddcca142e8aeffdba8a5a40d886f3f8254252be4

commit ddcca142e8aeffdba8a5a40d886f3f8254252be4
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2018-03-11 15:32:44 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2018-03-11 15:56:14 +0000

    app-shells/bash-completion: Remove implicit completions for vim
    
    Closes: https://bugs.gentoo.org/649986

 .../bash-completion/bash-completion-2.7-r3.ebuild  | 132 +++++++++++++++++++++
 .../bash-completion/bash-completion-9999.ebuild    |   6 +
 2 files changed, 138 insertions(+)