bash completion enabled by default (or move to another package)

Bug #25096 reported by Manuel López-Ibáñez
10
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
Fix Released
Wishlist
Matthias Klose

Bug Description

Bash completion feature is currently disabled in the default installation. If
not everybody wants this feature enabled by default, then a good solution would
be to enable it as follows and move all completion files (/etc/bash_completion*)
to another package (bash_completion):

@@ -29,6 +29,6 @@
 #esac

 # enable bash completion in interactive shells
-#if [ -f /etc/bash_completion ]; then
-# . /etc/bash_completion
-#fi
+if [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+fi

Then, if the package bash_completion is not installed, then /etc/bash_completion
doesn't exist and completion is not enabled. When the package is installed, it
will work out-of-the-box.

Matthias Klose (doko)
Changed in bash:
status: Unconfirmed → Fix Committed
Revision history for this message
Manuel López-Ibáñez (manuellopezibanez) wrote :

Fixed. Great!

How? Are you releasing a separate package? Is it enabled for everybody by default? Could explain the solution?

Changed in bash:
status: Fix Committed → Fix Released
Revision history for this message
levmatta (levmatta) wrote :

On Hardy the problem reappeared. Please verify.

Revision history for this message
Mika Fischer (zoop) wrote :

The way it is supposed to work is as follows:

In /etc/skel/.bashrc we have the following:
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

This was added in version: 3.1-3 in March 2006. So this was active since edgy at least. And it is still present on my hardy installation.

The files in /etc/skel are copied into the home directories of new users. However this will not change anything for old users. So if you have a user account that was created before edgy or have edited/overwritten your ~/.bashrc then you may not have these lines in your ~/.bashrc. In this case take a look at the file /etc/skel/.bashrc and copy the relevant lines into your ~/.bashrc.

I hope this helps you. Let me know if you have more questions.

Revision history for this message
levmatta (levmatta) wrote :

In /etc/skel/.bashrc (Hardy Alpha6) I have the lines you mentioned.
But bash completion was commented out in /etc/bash.bashrc AND did not work (which was nerve wrecking) until I installed the package bash-completion and uncommented it.
Note that this problem was confirmed by many people in #ubuntu+1 irc channel.
I will test it without the package, and without the package + lines commented out.

Thanks.
PS: personally I prefer Fish, but bash is the standard.

Revision history for this message
Mika Fischer (zoop) wrote :

I think the reason it was done this way is this:

If you uncomment the lines in /etc/bash.bashrc the *every* user on the system will have bash_completion enabled. This is bad because there is no easy way to disable it again. So the solution is to activate it in the user's .bashrc. If he does not want it he can just comment out the lines. But Ubuntu never touches the files in your home directory, so if you have a .bashrc with those lines in it (be it because your user account is from pre-edgy, or because you use a custom .bashrc), then it won't be enabled and this is intended.

If you want it enabled just include the three lines quoted above.

So the behaviour you see is expected. Please also note that this works for new installs or new user accounts. But there is no way Ubuntu will mess with the existing users' ~/.bashrc files, so you will have to do this yourself.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.