Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Quoting problems with _zip (unzip) completer
- X-seq: zsh-workers 27658
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: Quoting problems with _zip (unzip) completer
- Date: Thu, 4 Feb 2010 11:37:45 +0000
- In-reply-to: <20100203220958.26bc25fe@pws-pc>
- 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
- Organization: CSR
- References: <237967ef0908031315u72fa3661i17ff7f0107b85b9c@xxxxxxxxxxxxxx> <200908040850.n748oxlc011862@xxxxxxxxxxxxxx> <20090817215819.796e9416@pws-pc> <237967ef1002021716l101c98b7obc758fb200a117e8@xxxxxxxxxxxxxx> <20100203220958.26bc25fe@pws-pc>
On Wed, 3 Feb 2010 22:09:58 +0000
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> On Wed, 3 Feb 2010 02:16:15 +0100
> Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> > On 17 August 2009 21:58, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> > > On Tue, 04 Aug 2009 09:50:59 +0100
> > > Peter Stephenson <pws@xxxxxxx> wrote:
> > >> Mikael Magnusson wrote:
> > >> > % unzip test\[.zip <tab>
> > >> > _zip:117: bad pattern: test[.zip(|.zip|.ZIP)
> > >> > _zip:117: bad pattern: test[.zip(|.zip|.ZIP)
> > >> > _zip:117: bad pattern: test[.zip(|.zip|.ZIP)
>
> The exact test above is currently working for me, with my default
> completion setup.
It's working starting from zsh -f just loading compinit, too. I tried
another vanilla version of zsh just to make sure.
If the other part of the thread doesn't yield anything, could you see if
you can find what's breaking it, in terms of shell settings or environment?
(To be quite clear: I'm not going to be doing this myself without some
indication of what to do.)
Ben wrote:
> Breaks for me w/ latest git. Changing _zip line 117:
> from zipfile=( $~line[1](|.zip|.ZIP) )
> to zipfile=( $line[1](|.zip|.ZIP) )
>
> fixes the 'test[.zip' case
This isn't a proper fix. If you want to play along, read and digest the
description with my first patch. The key point is to keep ~-expansion
working.
However, this form does certainly have the globbing problems you pointed
out. $~ is doing multiple things not all of which we want; I wonder if
this might be causing other problems, too. It's annoyingly hard to get the
effect of file expansion and removal of quotes without the effect of
globbing, but a scalar assignment with $~ and an explicit unquote seems to
do the trick. Does changing it along the lines of this patch fix the
original problem?
Index: Completion/Unix/Command/_zip
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_zip,v
retrieving revision 1.9
diff -u -r1.9 _zip
--- Completion/Unix/Command/_zip 7 Nov 2006 10:38:54 -0000 1.9
+++ Completion/Unix/Command/_zip 4 Feb 2010 11:30:48 -0000
@@ -1,6 +1,6 @@
#compdef zip unzip zipinfo
-local suffixes suf zipfile uzi
+local suffixes suf zipfile uzi testfile
local expl curcontext="$curcontext" state line ret=1
typeset -A opt_args
@@ -114,10 +114,18 @@
if [[ $service = zip ]] && (( ! ${+opt_args[-d]} )); then
_wanted files expl zfile _files -g '^(#i)*.(zip|xpi|[ejw]ar)(-.)' && return
else
- zipfile=( $~line[1](|.zip|.ZIP) )
- [[ -z $zipfile[1] ]] && return 1
- if [[ $zipfile[1] != $_zip_cache_list ]]; then
- _zip_cache_name="$zipfile[1]"
+ testfile=${~${(Q)line[1]}}
+ if [[ -f $testfile ]]; then
+ zipfile=$testfile
+ elif [[ -f $testfile.zip ]]; then
+ zipfile=$testfile.zip
+ elif [[ -f $testfile.ZIP ]]; then
+ zipfile=$testfile.ZIP
+ else
+ return 1
+ fi
+ if [[ $zipfile != $_zip_cache_list ]]; then
+ _zip_cache_name="$zipfile"
_zip_cache_list=( ${(f)"$(zipinfo -1 $_zip_cache_name)"} )
fi
_wanted files expl 'file from archive' \
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
Messages sorted by:
Reverse Date,
Date,
Thread,
Author