Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Quoting problems with _zip (unzip) completer



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 value of "line" [in _zip] 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.

It's inside comparguments, but luckily in only one place.  This removes
the internal unquoting so the form above works.

This could easily have knock-on effects in other callers of _arguments,
however they should be fixable by simple local changes (and at least
one case, the one above, works without updating, so others probably do,
too), while with the old code there were unfixable cases, so I think we
just need to identify them and change them as they come up.

So please watch out for any anomalous _arguments quoting behaviour.

Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.115
diff -u -r1.115 computil.c
--- Src/Zle/computil.c	5 Aug 2009 10:14:54 -0000	1.115
+++ Src/Zle/computil.c	17 Aug 2009 20:52:20 -0000
@@ -1866,9 +1866,12 @@
     Caopt ptr, wasopt = NULL, dopt;
     struct castate state;
     char *line, *oline, *pe, **argxor = NULL;
-    int cur, doff, argend, arglast, ne;
+    int cur, doff, argend, arglast;
     Patprog endpat = NULL, napat = NULL;
     LinkList sopts = NULL;
+#if 0
+    int ne;
+#endif
 
     /* Free old state. */
 
@@ -1927,13 +1930,24 @@
 	dopt = NULL;
 	doff = state.singles = arglast = 0;
 
-        /* remove quotes */
         oline = line;
+#if 0
+        /*
+	 * remove quotes.
+	 * This is commented out:  it doesn't allow you to discriminate
+	 * between command line values that can be expanded and those
+	 * that can't, and in some cases this generates inconsistency;
+	 * for example, ~/foo\[bar unqotes to ~/foo[bar which doesn't
+	 * work either way---it's wrong if the ~ is quoted, and
+	 * wrong if the [ isn't quoted..  So it's now up to the caller to
+	 * unquote.
+	 */
         line = dupstring(line);
         ne = noerrs;
         noerrs = 2;
         parse_subst_string(line);
         noerrs = ne;
+#endif
         remnulargs(line);
         untokenize(line);
 



-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author