From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers <zsh-workers@sunsite.dk>
Subject: Re: Quoting problems with _zip (unzip) completer
Date: Mon, 17 Aug 2009 22:49:54 +0100 [thread overview]
Message-ID: <20090817224954.0b55b854@pws-pc> (raw)
In-Reply-To: <20090817215819.796e9416@pws-pc>
On Mon, 17 Aug 2009 21:58:19 +0100
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> So please watch out for any anomalous _arguments quoting behaviour.
Found one in _rm... but it's not a knock-on effect of this patch, it's
another thing that was already broken.
rm stuff <TAB>
is supposed to exclude "stuff" from being completed again by using the
-F option to _files by together with the line from _arguments:
ignored=(${line//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
_files -F ignored && ret=0
However, the code for "_files -F <array>" was
broken: instead of appending the contents of <array> after the -F to
the contents of the existing array, it appended the name <array>.
After fixing this, I'm gratified to find that in a directory containing
files called "normal" and "foo[bar", it's possible to have both files
ignored owing to the previous fix (with just this fix, and not the
previous one, it only works for "normal").
(I'm not *quite* sure how this works, actually. The extra quoting shown
in the code above protects pattern characters, since we're actually
passing a pattern, not a file name, so 'foo\[bar' from line becomes
'foo\\\[bar'. Unquoting the pattern characters gives 'foo\[bar' back as
a literal match. I don't understand why this matches the file... I'm
going to pretend I didn't notice.)
I'm a bit surprised nobody noticed this wasn't working. If anyone finds
this has a negative rather an a positive effect on ignoring files in
"rm" completion, please try to reproduce it starting from "zsh -f".
Index: Completion/Unix/Type/_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_files,v
retrieving revision 1.10
diff -u -r1.10 _files
--- Completion/Unix/Type/_files 21 Aug 2008 15:53:00 -0000 1.10
+++ Completion/Unix/Type/_files 17 Aug 2009 21:42:03 -0000
@@ -1,7 +1,7 @@
#compdef -redirect-,-default-,-default-
local opts tmp glob pat pats expl tag i def descr end ign ret=1 match tried
-local type sdef
+local type sdef ignvars ignvar
zparseopts -a opts \
'/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+:
@@ -18,14 +18,18 @@
fi
tmp=$opts[(I)-F]
if (( tmp )); then
- ign=( $=opts[tmp+1] )
- if [[ $ign = _comp_ignore ]]; then
+ ignvars=($=opts[tmp+1])
+ if [[ $ignvars = _comp_ignore ]]; then
ign=( $_comp_ignore )
else
+ ign=()
+ for ignvar in $ignvars; do
+ ign+=(${(P)ignvar})
+ done
opts[tmp+1]=_comp_ignore
fi
else
- ign=
+ ign=()
fi
if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
next prev parent reply other threads:[~2009-08-17 21:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-03 20:15 Mikael Magnusson
2009-08-04 8:50 ` Peter Stephenson
2009-08-04 16:31 ` Mikael Magnusson
2009-08-17 20:58 ` Peter Stephenson
2009-08-17 21:49 ` Peter Stephenson [this message]
2009-08-17 21:59 ` Nikolai Weibull
2009-08-18 9:10 ` Peter Stephenson
2010-02-03 1:16 ` Mikael Magnusson
2010-02-03 22:09 ` Peter Stephenson
2010-02-03 22:43 ` Mikael Magnusson
2010-02-03 23:11 ` Benjamin R. Haskell
2010-02-03 23:21 ` Benjamin R. Haskell
2010-02-04 10:03 ` Peter Stephenson
2010-02-04 11:37 ` Peter Stephenson
2010-02-04 14:15 ` Benjamin R. Haskell
2010-02-04 14:22 ` Peter Stephenson
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=20090817224954.0b55b854@pws-pc \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@sunsite.dk \
/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).