Bash completion whitelisting returns no results when it could return some that do not match

Bug #533985 reported by Michael B. Trausch on 2010-03-07
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
bash-completion (Debian)
Fix Released
Unknown
bash-completion (Ubuntu)
Wishlist
Unassigned

Bug Description

Binary package hint: bash-completion

When attempting to write a command line to decompress a .tar.xz file, tab completion fails:

mbt@fennel:~$ ls -l *.tar.xz
-rw-r--r-- 1 mbt mbt 4467540 2010-03-07 15:11 coreutils-8.4.tar.xz
mbt@fennel:~$ tar xf core

Pressing TAB multiple times does nothing.

I think that completion should not be a whitelist thing; that is, there should be some way to override the shell's notion of what you want it to complete. For example, if I were to do:

mbt@fennel:~$ ls -l *.tar.xz
-rw-r--r-- 1 mbt mbt 4467540 2010-03-07 15:11 coreutils-8.4.tar.xz
mbt@fennel:~$ tar xf ./core

… and press TAB multiple times, I still get nothing even though it should be perfectly clear to the shell that I really _do_ want it to autocomplete on the only possible file in the directory that matches the prefix. This is also a problem when attempting to autocomplete names for .zip files that have been renamed to something else entirely (such as is the case for MozBackup’s renamed ZIP files, which is .pcv).

ProblemType: Bug
Architecture: amd64
Date: Sun Mar 7 15:12:04 2010
DistroRelease: Ubuntu 10.04
InstallationMedia: Ubuntu 10.04 "Lucid Lynx" - Alpha amd64 (20100224.1)
Package: bash-completion 1:1.1-3
PackageArchitecture: all
ProcEnviron:
 LANG=en_US.utf8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.32-15.22-generic
SourcePackage: bash-completion
Uname: Linux 2.6.32-15-generic x86_64

Michael B. Trausch (mtrausch) wrote :
Michael B. Trausch (mtrausch) wrote :

Eek. LP truncated the title of the bug report, it was entered as “Bash completion fails for .tar.xz files when invoking tar (and in various other situations)”.

See also bug 526264, which is about sqlite only completing ".sqlite" files.

summary: - Bash completion fails for .tar.xz files when invoking tar
+ Bash completion fails for .tar.xz files when invoking tar (and in
+ various other situations)
Changed in bash-completion (Ubuntu):
status: New → Triaged
importance: Undecided → Wishlist
Clint Byrum (clint-fewbar) wrote :

Here is a patch that simply disables the whitelist and re-runs compgen whenever it fails to produce any results.

I've been using this on my dev system for the last day and it pretty much solves all of my gripes that led to me filing and working on this blueprint:

https://blueprints.launchpad.net/ubuntu/+spec/packageselection-server-n-commandline-userfriendly

tags: added: patch
summary: - Bash completion fails for .tar.xz files when invoking tar (and in
- various other situations)
+ Bash completion whitelisting returns no results when it could return
+ some that do not match
Changed in bash-completion (Debian):
status: Unknown → Confirmed
Chase Douglas (chasedouglas) wrote :

I've tried to review the patch, but I'm not sure what is changed. Based on the summary, I did the following:

1. Take a tar.gz tarball and rename it test.tar.xz
2. Try "$ tar xf test<TAB><TAB>"

This autocompleted to test.tar.xz as expected with the current version of bash-completion in Natty.

I also noticed that the change as committed to the upstream source is slightly different. It omits the "-X" argument to compgen. I would guess the patch against the ubuntu package should be updated for this change as well.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package bash-completion - 1:1.3-1ubuntu3

---------------
bash-completion (1:1.3-1ubuntu3) natty; urgency=low

  * Drop whitelists if they fail to produce any results
    (LP: #533985)
 -- Clint Byrum <email address hidden> Sun, 20 Mar 2011 05:56:52 -0700

Changed in bash-completion (Ubuntu):
status: Triaged → Fix Released
Bryce Harrington (bryce) wrote :

I confirmed that test.tar.xz does not work on stock natty, and that after Clint's patch, it does complete.

(For testing, I started a fresh terminal after each step, since within a particular shell session bash_completion changes don't automatically take effect.)

Changed in bash-completion (Debian):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.