[Bug 1388445] Re: bash-completion, command-not-found and '_have' function
Peter Cordes
peter at cordes.ca
Mon Dec 1 21:53:33 UTC 2014
hmm, actually now that dpkg completions are dynamically loaded, you
could do whatever in completions/dpkg without being a burden for every
interactive shell. Might be worth thinking about, but really, just
don't remove dctrl-tools. :P
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to bash-completion in Ubuntu.
https://bugs.launchpad.net/bugs/1388445
Title:
bash-completion, command-not-found and '_have' function
Status in bash-completion package in Ubuntu:
Opinion
Bug description:
In short, how it looks for me as a user:
I have dctrl-tools package installed. I open bash and type "sudo apt-get remove dctrl-tools".
Then (for example, in the same bash) I type "sudo dpkg --purge cr<TAB>", and this is what I get:
--begin quote--
sasha at sasha-netbook:~/Downloads$ dpkg --purge crThe program 'grep-status' is currently not installed. You can install it by typing:
sudo apt-get install dctrl-tools
--end quote--
===================================================
Why this happens:
In many /usr/share/bash-completion/completions/* files we see the following construct:
_have grep-status && {
_comp_dpkg_purgeable_packages()
{
grep-status ...
}
} || {
_comp_dpkg_purgeable_packages()
{
...
}
}
I.e. the existence of some command ("grep-status" in the above example) that is needed for some function ("_comp_dpkg_purgeable_packages" in the above example) is determined (using "_have" predefined func) not at the time of calling the function, but at the time of function declaration. On the one hand this is could give some performance benefits, but on another hand checked command can disappear after check:
e.g. user opens several bash sessions, then removes some package and in all bash'es that were opened before removing the package completion can become broken.
===================================================
What should be done:
I don't know. One possible solution is to move _have-checks inside the
body of defined function (as you understand, such stuff happens not
only for _comp_dpkg_purgeable_packages / grep-status / dpkg --purge).
Other is to, at least, somehow suppress command-not-found messages in
bash-completion scripts.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/1388445/+subscriptions
More information about the foundations-bugs
mailing list