Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bug in 'rm' completion



>>>>> On November 9, 2009 Greg Klanderman <gak@xxxxxxxxxxxxxx> wrote:

> | lwm% mkdir temp2
> | lwm% cd temp2
> | lwm% touch foo foo-bar

> At this point, if you type "rm f" and hit <tab> it correctly completes
> to "rm foo".  If you then hit <tab> again, it incorrectly completes to
> "rm foo-bar".

It looks like the code in _rm is trying to ignore completing other
files already listed to be removed on the command line, but brokenly
including the current word being completed in the ignore pattern.

The patch below seems to fix the problem, provided you are completing
the last word on the line.  So for example,

% mkdir temp
% cd temp
% touch bar foo foo-bar
% rm f<tab> bar

if you hit <tab> with the cursor in the location indicated, the
problem still exists with my patch, so I don't really think this is
the right fix.. I guess I should use $CURRENT to exclude the current
word?

Can someone explain where $line is coming from in _rm?  I don't see it
listed in the 'Completion Special Parameters' or 'Parameters Set By
The Shell' sections of the manual, and the name is too generic to
effectively search for.  Is it the same as $words, which I do see
documented in 'Completion Special Parameters'?  Hmm, not exactly, as
$line does not contain the command.. can I assume line=$words[2,-1]
and adjust $CURRENT appropriately?

BTW, what's the deal with _files vs _path_files?  I see that revision
1.2 of _rm switched from using _path_files to _files:

| revision 1.2
| date: 2008/11/23 18:23:29;  author: barts;  state: Exp;  lines: +1 -1
| users/13477: call _files instead of _path_files to correctly handle
| cycling through choices.

but there are plenty of completion functions using each.

thanks,
Greg



Messages sorted by: Reverse Date, Date, Thread, Author