Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: bug in 'rm' completion
- X-seq: zsh-workers 27391
- From: Greg Klanderman <gak@xxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: bug in 'rm' completion
- Date: Wed, 11 Nov 2009 21:48:48 -0500
- In-reply-to: <091110075221.ZM27832@xxxxxxxxxxxxxxxxxxxxxx> (Bart Schaefer's message of "Tue, 10 Nov 2009 07:52:21 -0800")
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <19191.43212.832827.724369@xxxxxxxxxxxxxxxxxx> <m38wef4qqs.fsf@xxxxxxxxxxxxxx> <091109092926.ZM26572@xxxxxxxxxxxxxxxxxxxxxx> <m3639j4mcl.fsf@xxxxxxxxxxxxxx> <m3iqdjmm31.fsf@xxxxxxxxxxxxxx> <091110075221.ZM27832@xxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: gak@xxxxxxxxxxxxxx
>>>>> On November 10, 2009 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> } + ignored=(${line[1,CURRENT-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
> } + ignored+=(${line[CURRENT+1,-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
> I'd be inclined to wrap that in a check that ((CURRENT > 1))
As long as you mean to wrap just the first line with that check..
otherwise it won't work correctly, for example:
% rm -rf <tab> foo bar baz
> just so
> it's obvious that we don't ignore the only word on the line, rather
> than rely on $line[1,0] to do the right thing, but otherwise this
> seems right to me.
Do you want the analogous check wrapped around the second line?
Can we rely on $line[$#line+1,-1] to do the right thing? If not
then presumably you want something like the new patch below..
thanks,
Greg
Index: Completion/Unix/Command/_rm
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_rm,v
retrieving revision 1.2
diff -u -r1.2 _rm
--- Completion/Unix/Command/_rm 23 Nov 2008 18:23:29 -0000 1.2
+++ Completion/Unix/Command/_rm 12 Nov 2009 02:47:20 -0000
@@ -5,7 +5,7 @@
'(-f --force)'{-f,--force}'[ignore nonexistent files, never prompt]'
'(-I --interactive)-i[prompt before every removal]'
'(-r -R --recursive)'{-r,-R,--recursive}'[remove directories and their contents recursively]'
- '*:files:->file'
+ '*::files:->file'
)
if _pick_variant gnu=gnu unix --help; then
opts+=(-S)
@@ -33,7 +33,11 @@
case $state in
(file)
declare -a ignored
- ignored=(${line//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
+ ignored=()
+ (( CURRENT > 1 )) &&
+ ignored+=(${line[1,CURRENT-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
+ (( CURRENT < $#line )) &&
+ ignored+=(${line[CURRENT+1,-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
_files -F ignored && ret=0
;;
esac
Messages sorted by:
Reverse Date,
Date,
Thread,
Author