[Bash-completion-devel] New directory layout

Ville Skyttä ville.skytta at iki.fi
Thu Jan 15 21:18:16 UTC 2009


On Tuesday 13 January 2009, Santiago M. Mola wrote:
> Hi all,
>
> Based on the current aproach on Gentoo and on comments from other
> distros, I'd like to propose a new directory layout for bash-completion.
[...]
> In Gentoo, we install all bash-completion modules
> to /usr/share/bash-completion/.
>
> Modules are enabled system-wide when they're symlinked
> from /etc/bash_completion.d/ and users can enable extra modules creating
> symlinks in ~/.bash_completion.d/.
>
> We have a Gentoo-specific tool for handling these symlinks, but I guess
> each distro would take its own aproach, which could be a) providing a
> configuration interface, b) enabling all modules by default (like some
> already do), c) let the user do it himself.

In Fedora, we use rpm triggers to enable (symlink to /etc/bash_completion.d) 
additional completion modules whenever a package known to provide the needed 
commands is installed.

> I think installing modules to /usr/share/bash-completion is more
> consistent than the current state (I don't think bash-completion modules
> can be considered anything near to configuration files).

I agree, ditto also about the FHS part Guillaume mentioned.  But the main 
bash_completion script falls into the above category in my opinion as well.

Here's some food for thought:

The main script:
    /usr/share/bash-completion/bash_completion

Directory where all the bundled modules are installed, all packages installing 
additional modules should also drop theirs here; bash_completion does *not* 
load anything from here:
    /usr/share/bash-completion/modules/

Per user config file, loaded by bash_completion (just like it does now):
   ~/.bash_completion

Directory for user to install/symlink additional modules to, bash_completion 
loads everything from here:
   ~/.bash_completion.d/

Directory reserved for local sysadmins to symlink/install additional system 
wide modules to (no packages should drop anything here), bash_completion 
loads everything from here:
   /etc/bash_completion.d/

Directory where OS default modules (e.g. ones enabled at additional package 
install time) are symlinked to, everything loaded by bash_completion; 
sysadmins or users should not touch this dir or its contents.  Tools that 
manage system wide modules should operate on these files, 
not /etc/bash_completion.d/ ones:
    /var/lib/bash-completion # or maybe bash[-_]completion.d ?

The OS and sysadmin distinction is there primarily to ensure that sysadmins 
and OS/package defaults don't stomp on each other.  I'm not entirely sure if 
this is needed, but it could be useful.

The order to load stuff could be:

1) ~/.bash_completion
2) ~/.bash_completion.d/*
3) /etc/bash_completion.d/*
4) /var/lib/bash-completion/*

Then, have some kind of a blacklist mechanism (e.g. adding unwanted module 
names to let's say a bash_completion_blacklist array) that each of the above 
steps could use to prevent something from a later step from being loaded (and 
obviously to add some additional things): users can blacklist sysadmin 
(/etc/bash_completion.d) and OS (/var/lib/bash-completion) defaults, sysadmin 
can blacklist OS ones.  It could obviously be done the other way around as 
well, by letting users undef stuff that has been enabled by a previous step, 
but that approach has the drawback that things a user may not want need to be 
loaded anyway, only to be undefined a bit later.




More information about the Bash-completion-devel mailing list