bash tab complete faulty where filename starts with $

Bug #19364 reported by Tristan Wibberley
14
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
Won't Fix
Medium
Unassigned

Bug Description

In bash, type "touch '$#!~'" and press return to create empty file named '$#!~'.
Then type "ls -l '$" (note the single quote)
Press tab until you get a list of suggestions (possibly scrolling with return)
The suggestions are as if the single quote wasn't present (ie, shell variables)
rather than simply completing to '$#!~'

Expected bahaviour, bash should tabcomplete '$ to '$#!~' if there is just one
file named '$#!~'

Revision history for this message
Matthias Klose (doko) wrote :

not a bug, use ls \$<tab>. using $<tab> enables variable completion.

Revision history for this message
jan_nienaber (jan-nienaber) wrote :

I think what we really want to see is conformity with other *ix - type systems. Each and every Unix - type box out there (Irix, HP-UX, SCO etc) wall tab-complete will exhinit the following behaviour:

Example:

export JBOSS_HOME=/usr/local/jboss/jboss-4.5.2GA
cd $JBOSS<tab> ...completes to 'cd /usr/local/jboss/jboss-4.5.2GA'. However, on Ubuntu, it will tab-complete to 'cd \$JBOSS_HOME'. That is NOT standard behaviour.

Revision history for this message
Jeff Sharpe (jeffsharpe) wrote :

I can confirm - this is a valid bug. It started with Gutsy - worked fine in Feisty.

Worked here with Feisty:

GNU bash, version 3.2.13(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

Acts incorrectly here on Gutsy:

GNU bash, version 3.2.25(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

Its irritating as hell when using multiple systems and you expect the bash completion to act consistency. I can't imagine this is a new 'feature' of the later version.

Changed in bash:
status: Invalid → Confirmed
Revision history for this message
era (era) wrote :

It seems that if I remove the "-o filenames" from the compspec for cd, I get the correct behavior when it comes to environment variables as arguments to cd.

vnix$ complete -p cd
complete -o filenames -o nospace -F _cd cd

vnix$ cd $HOM<TAB>
vnix$ cd \$HOME
bash: cd: $HOME: No such file or directory

vnix$ complete -o nospace -F _cd cd

vnix$ cd $HOM<TAB>
vnix$ cd $HOME

vnix$

See also bug 177243, although its author seems to be insisting that it's not a duplicate of this one.

Revision history for this message
era (era) wrote :

Seems I also need "-o dirnames" in order to actually get directory names (-:

Revision history for this message
Mika Fischer (zoop) wrote :

These are two bugs actually.

The original complaint about '$ completing environment variables is valid IMO. The bash-completion package does the right thing here and completes to: '$#!~'. The builtin completion tries to complete environment variables. So this bug is in the builtin completion of bash.

The other thing is the automatic quoting of $ characters when using cd. This is a bug in the bash-completion package. The builtin completion works correctly. So this part of the bug is actually the same as #177243.

Revision history for this message
Matthias Klose (doko) wrote :

> The original complaint about '$ completing environment variables is valid IMO
it's not specifically environment variables, it completes about all variables.

> I think what we really want to see is conformity with other *ix - type systems.
it is if you run bash there.

Changed in bash:
assignee: doko → nobody
status: Confirmed → Won't Fix
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.