TAB autocomplete does not work correctly for "chown user:group"

Bug #255058 reported by Christian González
12
Affects Status Importance Assigned to Milestone
bash-completion
Unknown
Unknown
bash-completion (Debian)
Fix Released
Unknown
bash-completion (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: bash-completion

bash-completion does not work correctly for chown.

try the following:
go into a dir as root, and type:

mkdir test
  $ ls -l
  insgesamt 4
  drwxr-xr-x 2 root root 4096 2008-08-05 19:10 test

now type
  $ chown ma[TAB]
it tries autocompletes and suggests:
  mail: man:

There are the colons, auto-completion does not delete them. Therefore, if you press another 'i' ->for 'mail' or just type
  $ chown mai[TAB]
it auto-completes to
  $ chown mail\:
with a trailing space - this is useless.

if you type
  $ chown mail:[TAB]
it shows the correct groups.

I think the autocomplete feature forgets to delete the trailing colon and interprets it as part of the user to search for.

Revision history for this message
Christian González (droetker) wrote :

I think problem is the file /etc/bash_completion.

at line 3236 it says:
   # remove any \: generated by a command that doesn't
   # default to filenames or dirnames (e.g. sudo chown)
   # FIXME: I'm pretty sure this does not work!

But it doesn't matter whether you say
chown or 'sudo chown' or 'sudo -s' and then chown.

Despite the FIXME I didn't find a bug report...

Revision history for this message
Jignesh Borad (jigneshborad) wrote :

I can confirm this behavior in interpid.

Although, I am not sure about the package. I think bash-completion returns proper mail: which is taken by bash and displayed as mail\: but I am not too sure.

Changed in bash-completion:
status: New → Confirmed
Changed in bash-completion (Debian):
status: Unknown → Confirmed
Revision history for this message
Juanma (juanma-bellon) wrote :

Changing the binding of autocompletion function to command from this:
  complete -F _chown $filenames chown
to this:
  complete -F _chown -o nospace chown
avoids both the quotting of the colon and the adding of a trailing space added (both actions are performed by Bash's autocompletion features, so the package selection is probably right).

The relevant line is in /etc/bash_completion.

The problem of this solution is that it breaks the proper filename completion for 'chown'.

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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