Ubuntu

Bash-completion add extra space char

Asked by Norbert on 2011-05-02

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:
2011-05-05
Last reply:
2013-04-24

This question was originally filed as bug #775386.

Norbert (nrbrtx) said : #1

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

Lekensteyn (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?

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.

Norbert (nrbrtx) said : #5

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

Paul Goins (pgoins) 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 "

Paul Goins (pgoins) 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?

Paul Goins (pgoins) said : #8

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

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.

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!

pd5rm (pedrum) said : #11

This problem still exists in the 11.10 release.

Lekensteyn (lekensteyn) said : #12

Have you upgraded or have you performed a fresh install?

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.

Groove (groove-c) said : #14

i also still have this problem after an upgrade to 11.10

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

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

thx

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

massimoi (massimoi) said : #18

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

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

Thank you.

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!

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.