.bashrc not executed to the end

Bug #160405 reported by Pekka Jääskeläinen
This bug report is a duplicate of:  Bug #149527: .profile not sourced anymore. Edit Remove
8
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

The ~/.bashrc script is not executed to the end.

I noticed this when upgrading to Gutsy and my custom environment settings at the end of .bashrc didn't
appear anymore in my shell.

I tracked this to

if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

No code after this block gets executed. If I add those environment settings to the top of the file, it works as expected.
However, I can imagine this breaks a lot of systems in an upgrade.

This is broken also in clean Gutsy installs (no upgrade).

Revision history for this message
Pekka Jääskeläinen (pekka-jaaskelainen) wrote :

Something strange happens here. It gets executed when I start a new shell, but not when I source it:

From the end of my .bashrc:

echo a
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi
echo b

visit0r@foo:~$. .bashrc
a
visit0r@foo:~$

visit0r@foo:~$ bash
a
b
visit0r@foo:~$

And even when I relogin to the system it seems to work:

ssh foo
...
a
b

So the problem is only when sourcing the script, it seems.

Revision history for this message
François Marier (fmarier) wrote :

I was also affected by this problem but was able to fix it when I removed the bash_completion line from my ~/.bashrc

It turns out that the bash_completion script was sourced twice: once in /etc/bash.bashrc and once in ~/.bashrc

I commented it out in ~/.bashrc and left it enabled in /etc/bash.bashrc and now it works fine. So it looks like the real problem is that the script is not idempotent (cannot be sourced more than once).

Revision history for this message
uthpala (uthpalawe) wrote :

Commenting the ~/.bashrc s bash completion line solves this problem. But it reduces the shell's capability to auto complete. For example when the line is commented man <tab twice> does nothing. When the line is there it tries to display all possibilities.

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.