Bash-completion add extra space char

Asked by Norbert

Binary package hint: bash-completion

When I enter some command with argument in the terminal and press <Tab> bash-completion adds extra space to the end of command.
I.e. I want to open /etc/issue with cat (full command is "cat /etc/issue").
What I do: "cat /et <Tab>". After this I get "cat /etc " (yes, with extra space).

It works normally under Lucid and Maverick.

ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: bash-completion 1:1.3-1ubuntu3
ProcVersionSignature: Ubuntu 2.6.38-8.42-generic 2.6.38.2
Uname: Linux 2.6.38-8-generic x86_64
Architecture: amd64
CheckboxSubmission: a3c9de473bf7a483a92609c6b20d2aee
CheckboxSystem: b633b4f40868d491c2ae5b50030ce6f3
Date: Mon May 2 11:11:35 2011
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100429)
PackageArchitecture: all
ProcEnviron:
 LANGUAGE=en_US:en
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: bash-completion
UpgradeStatus: Upgraded to natty on 2011-05-01 (0 days ago)

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu bash-completion Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was originally filed as bug #775386.

Revision history for this message
Norbert (nrbrtx) said :
#1
Revision history for this message
Federico Tello Gentile (federicotg) said :
#2

I cannot reproduce it. No extra space on my computer.

Revision history for this message
Peter Wu (lekensteyn) said :
#3

I can neither reproduce it, but have seen this behavior before with other commands, could you try re-installing the bash-completion package?

    sudo apt-get --reinstall bash-completion
If this does not help, could you post your ~/.bashrc contents?

Revision history for this message
Groove (groove-c) said :
#4

I have the same Problem since upgrading to natty. reinstalling bash-completion did not help and also overwriting my bashrc with that from /etc/skel did also not help.
This also happens not for all commands. For example the behaviour of cd is correct.

Revision history for this message
Norbert (nrbrtx) said :
#5

Reinstalling did not help me.
Converted back to bug - https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/775386.

Revision history for this message
Paul Goins (vultaire) said :
#6

I also have a similar issue.
Attempted a reinstall of bash-completion. Didn't help here, either.

The completion varies depending on command, as Groove mentioned. For example: cd, vi, and emacs all seem to work right, but rm, cat, ln, du, and df all produce a space.

Concrete examples:

"cd /usr" + TAB => "cd /usr/"
"vi /usr" + TAB => "vi /usr/"
"emacs /usr" + TAB => "emacs /usr/"
"rm /usr" + TAB => "rm /usr "
"cat /usr" + TAB => "cat /usr "
"ln /usr" + TAB => "ln /usr "

Revision history for this message
Paul Goins (vultaire) said :
#7

For what it's worth, the commands previously mentioned as not working are defined in /etc/bash_completion, lines 1581-1588. All of the commands are set to complete using _longopt, a function defined immediately above this block.

I don't have time to look at this myself, but maybe this might give someone a start?

Revision history for this message
Paul Goins (vultaire) said :
#8

Sorry; I didn't read so well. I'll move these comments to the appropriate bug.

Revision history for this message
Johann Philipp Strathausen (strathausen) said :
#9

For me, #10 of bug https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/769866 solved my problem for now:

> I believe there is a bug on line 1587 of /etc/bash_completion, the "-o default" on that line should be changed to "-o filenames".

But, besides that, I have tried zsh instead of bash and I really like it. It is faster than bash, and more flexible, the autocompletion just rocks!! I strongly recommend zsh.

Revision history for this message
vasillalov (vasil-lalov) said :
#10

> I believe there is a bug on line 1587 of /etc/bash_completion, the "-o default" on that line should be changed to "-o filenames".

This worked for me! I edited my /etc/bash_completion as described above and the problem went away!

Revision history for this message
pd5rm (pd5rm) said :
#11

This problem still exists in the 11.10 release.

Revision history for this message
Peter Wu (lekensteyn) said :
#12

Have you upgraded or have you performed a fresh install?

Revision history for this message
NigelCohen (gnc-softwaredesign) said :
#13

I just upgraded to 11.10. I had a number of problems, this being on. Your "-o filenames" solution worked for me too. Thanks for the help.

Revision history for this message
Groove (groove-c) said :
#14

i also still have this problem after an upgrade to 11.10

Revision history for this message
Jindrich Liprt (jliprt) said :
#15

I would like just to confirm the information listed above.
The workaround also works:
$ diff bash_completion bash_completion.orig
1587c1587
< have $i && complete -F _longopt -o filenames $i
---
> have $i && complete -F _longopt -o default $i

DistroRelease: Ubuntu 11.10
Package: bash-completion 1:1.3-1ubuntu3
Uname: Linux 2.6.38-11-generic-pae i686

Revision history for this message
Alessio Tomelleri (alessio-tomelleri) said :
#16

... modifying with "-o filenames" solution is fine for me as well.

thx

Revision history for this message
Exolon (v-launchpad-exoz-net) said :
#17

Ok now this is weird. I got several Linux machines running and i encountered this problem on my machine at work to.
But: This occurred only at work and on my main desktop at home. Both of them are x86_64 machines. The thing that really puzzles me, I remember this wasn't happening when i reinstalled cleanly using 11.10. Some modification since that day must have introduced this bug. Using the hack mentioned above, solved it but there is still one thing that doesn't feel right. My second Desktop has the original bash_completion file, but does tab completion right! A both files produce just the same diff as shown in #15. The bug has to originate elsewhere. Doing the hack just solves a symptom.

Linux Exolon 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:44:39 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
updated just today, no selfcompiled stuff interfering

Revision history for this message
massimoi (massimoi) said :
#18

... modifying with "-o filenames" solution is fine for me as well.
+1
Thanks

Revision history for this message
Erwin Komaruloh (le-komaruloh) said :
#19

12.04 still have this issue. Fixed by modifying "-o default" to "-o filenames".

Thank you.

Revision history for this message
Edward (edthedev) said :
#21

This have this problem with Ubuntu 12.04.

Reinstalling does not help:
apt-get remove bash-completion
apt-get install bash-completion

Modifying the script manually, as described above seems to fix it.

I'm curious whether the fact that Bash is the default selected or the fact that 12.04 is an LTS release will influence the priority of fixing this? This seems like a surprisingly long time for something so fundamental to sit unaddressed.

I would be interested if anyone has comments on whether the work-around above is a true fix, or whether I've just hacked in some new, more subtle problem.

Anyway, thanks for the work-around!

Revision history for this message
Aaron Gamble (invalidfunction) said :
#22

There appears to be a bug in the /etc/bash_completion.d/acroread.sh that comes with Adobe Reader. When I remove this file and start a new bash terminal the problem is gone.

tlo pointed this bug out in http://stackoverflow.com/questions/11981764/bash-tab-completion-adds-extra-space-after-the-first-completion/14975552#14975552

Can you help with this problem?

Provide an answer of your own, or ask Norbert for more information if necessary.

To post a message you must log in.