Tab expansion only auto-completes directory names

Bug #1288031 reported by Simon Déziel on 2014-03-05
148
This bug affects 29 people
Affects Status Importance Assigned to Milestone
bash-completion (Debian)
Fix Released
Unknown
bash-completion (Ubuntu)
High
Matthias Klose

Bug Description

Under bash 4.3, tab expansion only auto-completes directory names. Steps to reproduce:

 # Preparation
 D=$(mktemp -d)
 cd $D
 touch a
 mkdir b c

 # test
 vi # (press tab tab)
b/ c/

Notice the file "a" isn't proposed in the listing, only the 2 directories ("b" and "c").

$ lsb_release -rd
Description: Ubuntu Trusty Tahr (development branch)
Release: 14.04

$ apt-cache policy bash-completion bash
bash-completion:
  Installed: 1:2.1-2ubuntu2
  Candidate: 1:2.1-2ubuntu2
  Version table:
 *** 1:2.1-2ubuntu2 0
        500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
        100 /var/lib/dpkg/status
bash:
  Installed: 4.3-1ubuntu2
  Candidate: 4.3-1ubuntu2
  Version table:
 *** 4.3-1ubuntu2 0
        500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
        100 /var/lib/dpkg/status

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: bash-completion 1:2.1-2ubuntu2
ProcVersionSignature: Ubuntu 3.13.0-15.35-generic 3.13.5
Uname: Linux 3.13.0-15-generic x86_64
ApportVersion: 2.13.2-0ubuntu5
Architecture: amd64
CurrentDesktop: Unity
Date: Tue Mar 4 21:39:35 2014
InstallationDate: Installed on 2014-01-26 (37 days ago)
InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Alpha amd64 (20140124)
PackageArchitecture: all
SourcePackage: bash-completion
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Simon Déziel (sdeziel) wrote :
Simon Déziel (sdeziel) wrote :

This is possibly the same as described in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739835

Launchpad Janitor (janitor) wrote :

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

Changed in bash-completion (Ubuntu):
status: New → Confirmed
tags: added: regression-proposed
tags: added: regression-release
removed: regression-proposed
Changed in bash-completion (Ubuntu):
assignee: nobody → Matthias Klose (doko)
importance: Undecided → High
Changed in bash-completion (Debian):
status: Unknown → New
JuanJo Ciarlante (jjo) wrote :

FTR the issue is _quote_readline_by_ref expanding an empty var to '', see:

$ _quote_readline_by_ref '' foo
$ echo $foo
''

Above MP adds a special case to avoid quoting if empty.

Agus Lopez (itinlopez) wrote :

FWIW, disabling progcomp shell option fixes the problem.

$ shopt -u progcomp
$ vi # <TAB> <TAB>
a b/ c/

From bash manpage (http://man.cx/bash):

> progcomp: If set, the programmable completion facilities (see Programmable Completion above) are enabled. This option is enabled by default.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package bash-completion - 1:2.1-2ubuntu4

---------------
bash-completion (1:2.1-2ubuntu4) trusty; urgency=medium

  * fix _quote_readline_by_ref to:
    - avoid escaping 1st '~' (lp: #1288314)
    - avoid quoting if empty, else expansion without args only shows dirs
      (lp: #1288031)
    - replace double escaping to single (eg for completing file/paths with
      spaces)
 -- JuanJo Ciarlante <email address hidden> Thu, 13 Mar 2014 19:43:22 -0300

Changed in bash-completion (Ubuntu):
status: Confirmed → Fix Released
Changed in bash-completion (Debian):
status: New → Fix Released
shanec (shane-cousins) wrote :

Still seeing this issue with python command line scripts. Even after running apt-get update/upgrade for 14.04.

cmdline.py ::
-----------------------
import argparse
parser = ArgumentParser(description="bash-completion test")
parser.add_argument("--filename", "-f")
args = parser.parse_args()
print 'Filename: {}'.format(args.filename)
---------------------------

$ python cmdline.py -f ~/[tab] [tab] [tab]

only returns directories, no files are listed.

$lsb_release -rd
Description: Ubuntu 14.04 LTS
Release: 14.04

$ apt-cache policy bash-completion bash
bash-completion:
  Installed: 1:2.1-4
  Candidate: 1:2.1-4
  Version table:
 *** 1:2.1-4 0
        500 http://jp.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
        100 /var/lib/dpkg/status
bash:
  Installed: 4.3-7ubuntu1
  Candidate: 4.3-7ubuntu1
  Version table:
 *** 4.3-7ubuntu1 0
        500 http://jp.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     4.3-6ubuntu1 0
        500 http://jp.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

Ville Skyttä (vskytta) wrote :

FYI, the _quote_readline_by_ref changes should no longer be necessary with bash 4.3 patchlevel 10 and above, that's why they're not applied in upstream bash-completion. https://lists.gnu.org/archive/html/bug-bash/2014-04/msg00035.html

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.