Subject: Re: [BUG] quoting within bracket patterns has no effect
From: Peter Stephenson <[email-masked]>
To: [email-masked]
Date: Tue, 19 Jan 2016 17:35:11 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Wed, 20 Jan 2016 00:57:30 +0900
Jun T. <[email-masked]> wrote:
> In glob.c, switch statement from line 1298,
> *s is not '-' but Dash, and not handled by
> case '-':
> at line 1316.

It looks like glob qualifiers are a grey area for tokenisation, with
arguments that should be untokenised but aren't (so far as I can see),
so it's not necessarily just that case.  Short of rewriting it, this is
about the best I can see, and ought to be OK for -, but I suspect this
is just the tip of the iceberg.  However, maybe it gets tidied up
later somewhere I haven't noticed so just handling the case statement
would actually work.

pws

diff --git a/Src/glob.c b/Src/glob.c
index c799281..69de155 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1230,7 +1230,7 @@ zglob(LinkList list, LinkNode np, int nountok)
 	char *s;
 	int sense, qualsfound;
 	off_t data;
-	char *sdata, *newcolonmod;
+	char *sdata, *newcolonmod, *ptr;
 	int (*func) _((char *, Statptr, off_t, char *));
 
 	/*
@@ -1273,6 +1273,9 @@ zglob(LinkList list, LinkNode np, int nountok)
 	*s++ = 0;
 	if (qualsfound == 2)
 	    s += 2;
+	for (ptr = s; *ptr; ptr++)
+	    if (*ptr == Dash)
+		*ptr = '-';
 	while (*s && !newcolonmod) {
 	    func = (int (*) _((char *, Statptr, off_t, char *)))0;
 	    if (idigit(*s)) {