zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers <zsh-workers@sunsite.dk>
Subject: Re: Quoting problems with _zip (unzip) completer
Date: Tue, 4 Aug 2009 18:31:31 +0200	[thread overview]
Message-ID: <237967ef0908040931k5e3f547ckf0fd52a083575cca@mail.gmail.com> (raw)
In-Reply-To: <200908040850.n748oxlc011862@news01.csr.com>

2009/8/4 Peter Stephenson <pws@csr.com>:
> 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)
>>
>>..
>> @@ -114,7 +114,7 @@ case $state in
>>      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) )
>> +      zipfile=( $line[1](|.zip|.ZIP) )
>>        [[ -z $zipfile[1] ]] && return 1
>>        if [[ $zipfile[1] !=  $_zip_cache_list ]]; then
>>       _zip_cache_name="$zipfile[1]"
>
> The trouble is this stops you using filenames with a ~, among other
> things.  This suggests the value of "line" is a bit inconsistent.  Sure
> enough if I use ~/tmp/zip/tmp\[.zip $line[1] comes back (using print -r) as
>
>  ~/tmp/zip/test[.zip
>
> which is wrong---either the ~ needs to be expanded, or the [ needs to be
> quoted.  So this needs tracking internally, unfortunately.  If it hits
> the internal completion quoting system we're probably stuck---I spent
> weeks looking at that a couple of years ago and got virtually nowhere.
> However, it may not be that bad in this case.

I would argue it is better without the $~; I can replace the ~ with
$PWD on the commandline, but I can't rename the file to not have
brackets without actually renaming it.

I came up with a reproducible test case for the other issue:
% mkdir '[test] a name with spaces'
% touch '[test] a name with spaces'/{'a file with spaces','another
file with spaces',a file with a unique name','afilewithoutspaces'}
% zip -r test.zip '[test] a name with spaces'
% unzip test.zip <tab> # -> gives "\[test\]\ a\ name\ with\ spaces "
with the space after
% unzip test.zip \[test\]\ a\ name\ with\ spaces<tab> # -> just adds
the space back
% unzip test.zip \[test\]\ a\ name\ with\ spaces/<tab>
# -> \[test\]\ a\ name\ with\ spaces/afilewithoutspaces
% unzip test.zip \[test\]\ a\ name\ with\ spaces/a<tab>
# same
% unzip test.zip \[test\]\ a\ name\ with\ spaces/an<tab>
# -> "\[test\]\ a\ name\ with\ spaces/another\ file\ with\ spaces "
# (as a unique match)
% unzip test.zip \[test\]\ a\ name\ with\ spaces/a\ file<tab><tab><tab><tab>
# just beeps, ie no matches

calling the directory 'normaldirectoryname' causes the directory to
get a slash appended at the first step, but the files inside then
behave exactly the same as above.

According to _complete_debug the whole array of filenames gets passed
down along the chain, it should be available here for some time:
http://mika.l3ib.org/zsh-zip-complete-debug.txt

-- 
Mikael Magnusson


  reply	other threads:[~2009-08-04 16:40 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 [this message]
2009-08-17 20:58   ` Peter Stephenson
2009-08-17 21:49     ` Peter Stephenson
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=237967ef0908040931k5e3f547ckf0fd52a083575cca@mail.gmail.com \
    --to=mikachu@gmail.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).