bash ls tab completion broken for files/dirs with spaces in name

Bug #883268 reported by Dan Kegel
26
This bug affects 6 people
Affects Status Importance Assigned to Milestone
bash-completion (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Running updated ubuntu 11.10, tab completion fails to escape spaces in filenames for some commands.

To repeat:
mkdir "abc def"
touch "abc def"/xyz
ls ab<TAB><ENTER>
Expected:
xyz
Observed:
ls: cannot access abc: No such file or directory
ls: cannot access def: No such file or directory

Also affects tab completion for 'touch', but not for 'echo' or when looking for commands.

This worked fine in ubuntu 11.04.

Revision history for this message
Dan Kegel (dank) wrote :

This does not affect the 'cd' command's tab expansion.

Also, on the affected commands, a space instead of a slash is the last character of a directory completion.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in bash-completion (Ubuntu):
status: New → Confirmed
Revision history for this message
Andy Meier (andy-meier) wrote :
Revision history for this message
Rachel Greenham (rachel-strangenoises) wrote :

I know I'm waking up a very old bug here, but I just hit it, on *trusty*. There was no problem in saucy.

It does seem to match what the original reporter was saying: that it fails to autocomplete *files* if the directory path has spaces in it. It will autocomplete subdirectories of directories with spaces in their names, but not when it gets down to the actual files.

Checked out the workaround in comment #3, but as far as I can make out, that fix is already in: line 1587 of (now) /usr/share/bash-completion/bash_completion is:

    compopt -o filenames

Of course the offending line may not be the exact number, but it *looks* like the same thing. So it looks like it may be same symptom, different cause this time.

NB: This is affecting ls and various other random commands including personal helper scripts of my own, so I don't think it's completion rules for specific commands getting in the way.

Revision history for this message
Isuru Perera (chrishantha) wrote :

I also experience this on Ubuntu 14.04 (Trusty). I have upgraded all packages and I'm also in proposed repository.

Filenames are not autocompleted in bash. Directory names are autocompleted.

Revision history for this message
Peter Cordes (peter-cordes) wrote :

It's working fine for me. Do you have some old cruft in /etc/bash_completion.d that's causing trouble?

And btw, yes once the completion code for ls option processing figures out that it's completing a filename, it passes it to the same code that's used generically for filenames. So if that's having a problem, it will affect everything.

Revision history for this message
Dan Kegel (dank) wrote :

Ubuntu 14.04 doesn't seem to have the problem here.

Revision history for this message
Peter Cordes (peter-cordes) wrote :

If this wasn't /etc/bash_completion.d/acroread.sh (which is now blacklisted), then add info to bug 1372286. If we can find more problematic files to blacklist, we can prevent this problem for other people.

 Closing this because it was reported against a version before the acroread blacklist was added, so it's maybe different even if it's "back".

Changed in bash-completion (Ubuntu):
status: Confirmed → Fix Released
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.