zsh-workers
 help / color / mirror / code / Atom feed
From: Greg Klanderman <gak@klanderman.net>
To: zsh-workers@zsh.org
Subject: Re: bug in 'rm' completion
Date: Wed, 11 Nov 2009 21:48:48 -0500	[thread overview]
Message-ID: <m3d43omp9r.fsf@klanderman.net> (raw)
In-Reply-To: <091110075221.ZM27832@torch.brasslantern.com> (Bart Schaefer's message of "Tue, 10 Nov 2009 07:52:21 -0800")

>>>>> On November 10, 2009 Bart Schaefer <schaefer@brasslantern.com> 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


  reply	other threads:[~2009-11-12  2:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-09  5:29 Greg Klanderman
2009-11-09 16:17 ` Greg Klanderman
2009-11-09 17:29   ` Bart Schaefer
2009-11-09 17:52     ` Greg Klanderman
2009-11-09 21:20       ` Greg Klanderman
2009-11-10 15:52         ` Bart Schaefer
2009-11-12  2:48           ` Greg Klanderman [this message]
2009-11-12  4:21             ` Bart Schaefer
2009-11-12 17:22               ` Greg Klanderman
2009-11-09 16:29 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3d43omp9r.fsf@klanderman.net \
    --to=gak@klanderman.net \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).