bash-completion scripts to /usr/share bugs filed today

Ville Skyttä ville.skytta at iki.fi
Tue Mar 19 16:43:24 UTC 2013


Looks like a bunch of "move your bash completion scripts to
/usr/share/bash-completion/completions" bugs were filed today without
any information how to do it properly. I wish this would have been
discussed beforehand with me before mass filing bugs, but now that the
bugs are already there, here's a couple of things to take into account.

First, the completions from /usr/share/bash-completion/completions are
loaded dynamically on demand, not eagerly on shell startup like they
used to be and still are when loaded from /etc/bash_completion.d. It
depends on the script what this means per completion, but for all
completions it means that the script name in
/usr/share/bash-completion/completions must be the same as the command
it installs completions for. If the script installs completions for
multiple commands, the script should be installed (in practice
symlinked) for all these names in
/usr/share/bash-completion/completions. The bash-completion package
itself contains plenty of examples for these symlinks.

Second, I recommend using pkgconfig for finding out the completions dir
instead of hardwiring /usr/share/bash-completion/completions. There's a
question and answer related to this in bash-completion's README.

Third, please work with upstreams when moving the completion scripts.
This new location and dynamic loading is available with bash-completion
1.99+ as is the pkgconfig file.

Fourth, the have() bash-completion function that was earlier the way to
check whether a command is available is no longer available at runtime
when loading completions on demand, so any completions moved from
/etc/bash_completion.d to /usr/share/bash-completion/completions that
use it will need modifications. In most cases its use can be just
dropped, but if availability of some commands really need to be checked
at runtime, _have() is suitable for that use.


More information about the devel mailing list