#758038 bash_completion in .bashrc causes slow terminal prompt

#758038#5
Date:
2014-08-13 15:56:33 UTC
From:
To:
Some time back I noticed my gnome terminals became very slow to give the
prompt.  I guessed that it might be due to something in .bashrc.  So, from the
command line, I tried dotting in .bashrc to see if that was slow.  It was slow.
Then I put a set -x at the top of .bashrc to see where it appeared to hang.  I
could see that dotting in .bashrc would hang for several seconds on the
following lines:
type grub-set-default
type grub-reboot
type grub-mkconfig
type grub-setup
type grub-install
type grub-probe
type insserv

I added a time to the front to see how long it took like this:
time . .bashrc

here is how long it took:

real    2m1.944s
user    0m0.158s
sys     0m0.162s

That is horrible to wait for 2 minutes for a terminal to open.

I could see in the trace that the hanging lines were coming from:
 . /usr/share/bash-completion/bash_completion

in .bashrc

I have saved the trace of dotting in .bashrc if that would be useful.
What is going on here and how can I fix it?