directory for mount not completing

Bug #395279 reported by Dave Gilbert
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
bash-completion (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: bash-completion

version: 1.0-3

If I type

mount /dev/frob /me and hit tab complete it completes to /media/cdrom0
(frob is irrelevant - it seems to ignore what I put there for the completion of the other part).

However, /media has :

ls -l /media
drwxr-xr-x 7 dg root 4096 2009-03-29 15:34 6f6d157c-5722-440f-afb3-6300a8b7fc34
lrwxrwxrwx 1 root root 6 2007-04-13 23:30 cdrom -> cdrom0
drwxr-xr-x 2 root root 4096 2007-04-13 23:30 cdrom0
drwxrwxrwx 4 root root 4096 2009-06-13 18:34 Music16GBa

So there is no good reason it should complete to cdrom0, I expect it to complete to /media/ for
me then to type a bit more.
The 6f.... and Music16GBa directories are manually created.

(This is on Karmic updated about a week ago).

Dave

Revision history for this message
Dave Gilbert (ubuntu-treblig) wrote :

This is still doing it on one of my machines upgraded to Lucid (davros), but not the other. Very curious!

Dave

Revision history for this message
Dave Gilbert (ubuntu-treblig) wrote :

OK, I can see what's happening here - and I think it's a bug (although I might be persuaded it's a preference).

/etc/bash_completion uses:

    complete -F _mount $default $dirnames mount

where _mount is a function that returns a list of the mount directories matching the name being completed; so
because I have one and only one /media mount in fstab (/media/cdrom0) it returns /media/cdrom0 as the one
and only completion option.

$dirnames is set to -o dirnames
  This causes completion to complete directories only if the -F function returns an empty list.

Newer bash has -o plusdirs which *adds* the list from the -F to the list, which IMHO is the right behaviour;
the code at the top of /etc/bash_completion detects that bash is new enough and sets a $plusdirs
that we could use instead of $dirnames.

$plusdirs is rarely used (in a few of the /etc/bash_completion.d scripts)

IMHO the right behaviour here is to use -o plusdirs in most cases, either by just assuming we're on a modern bash,
or by having a variable (e.g. $newestdircomp) that is set to '-o plusdirs' on newer bashes and '-o dirnames' on older bashes.

Dave

Revision history for this message
Martin Erik Werner (arand) wrote :

Lucid
bash-completion: 1.1-3ubuntu2

I'm using this in my fstab:
# Manually added for automount of DATA partition
/dev/disk/by-uuid/A66C42F16C42BBB5 /media/DATA ntfs defaults,gid=46,umask=007,group 0 0

And when using mount bash always completes to /media/DATA even though I have several other folders in /media/ and even though I'm trying to mount something new, and /media/DATA is already mounted.
I would agree that this behaviour is questionable.

Marking as confirmed.

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