zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@sunsite.dk
Cc: 501851@bugs.debian.org
Subject: Re: Bug#501851: zsh: Completion fails if a directory name contains '(', ')' and 'Ą '.
Date: Sat, 11 Oct 2008 22:52:55 +0100	[thread overview]
Message-ID: <20081011225255.0df2e350@pws-pc> (raw)
In-Reply-To: <48F0AE88.1020307@inz.sakura.ne.jp>

On Sat, 11 Oct 2008 22:47:52 +0900
Morita Sho <morita-pub-en-debian@inz.sakura.ne.jp> wrote:
> $~tmp1 expansion seems not working correctly for a pattern '\(\)Ą/*'.

Thanks for the clear analysis.

The pattern gets divided up into chunks because of the backslashed
characters, but we don't report that it wasn't a pure string on that
basis, so the directory trise to match the wrong string.  This was triggered
in this case because of the character in a range that zsh has to quote
internally to avoid clashing with tokens, which is why it occurred with
some forms of accent but not others.

I could optimise this better but this is a simple change for now.

Index: Src/pattern.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/pattern.c,v
retrieving revision 1.47
diff -u -r1.47 pattern.c
--- Src/pattern.c	8 Jun 2008 17:53:55 -0000	1.47
+++ Src/pattern.c	11 Oct 2008 21:44:35 -0000
@@ -1446,7 +1446,13 @@
 	     * Marker for restoring a backslash in output:
 	     * does not match a character.
 	     */
-	    return patcomppiece(flagp);
+	    next = patcomppiece(flagp);
+	    /*
+	     * Can't match a pure string since we need to do this
+	     * as multiple chunks.
+	     */
+	    *flagp &= ~P_PURESTR;
+	    return next;
 	    break;
 #ifdef DEBUG
 	default:
Index: Test/D07multibyte.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D07multibyte.ztst,v
retrieving revision 1.25
diff -u -r1.25 D07multibyte.ztst
--- Test/D07multibyte.ztst	26 Mar 2008 15:26:20 -0000	1.25
+++ Test/D07multibyte.ztst	11 Oct 2008 21:44:35 -0000
@@ -395,3 +395,14 @@
 >OK
 >OK
 >OK
+
+  mkdir glob
+  mkdir glob/'()Ą' glob/'()Ā'
+  mkdir glob/'()Ą'/foo glob/'()Ā'/bar
+  tmp1=('glob/\(\)Ą/*')
+  print $~tmp1
+  tmp1=('glob/\(\)Ā/*')
+  print $~tmp1
+0:Backslashes and metafied characters in patterns
+>glob/()Ą/foo
+>glob/()Ā/bar


  reply	other threads:[~2008-10-11 21:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20081010230611.23133.42221.reportbug@debian>
2008-10-10 23:17 ` Clint Adams
2008-10-11 12:09   ` Richard Hartmann
2008-10-11 13:47   ` Morita Sho
2008-10-11 21:52     ` Peter Stephenson [this message]
2008-10-13  1:32       ` Morita Sho
2008-10-13  6:25         ` Richard Hartmann
2008-10-14  1:46           ` Morita Sho
2008-10-14 12:04             ` Peter Stephenson
2008-10-15  4:34               ` Morita Sho
2008-10-18 18:48                 ` Peter Stephenson
2008-10-19  6:00                   ` Morita Sho
2008-10-13  9:30         ` Peter Stephenson
2008-10-13 12:50           ` Richard Hartmann

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=20081011225255.0df2e350@pws-pc \
    --to=p.w.stephenson@ntlworld.com \
    --cc=501851@bugs.debian.org \
    --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).