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

Re: strange behavior in zsh 5.3.1



On Thu, 13 Jul 2017 16:26:21 +0100
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> On Thu, 13 Jul 2017 17:06:34 +0200
> Francesco Giordano <nhoyadx@xxxxxxxxx> wrote:
> > > echo {1..10}{1..
> 
> Definitely a bug in brace handling, which the shell even picks up in
> debug mode...
> 
>  glob.c:2248: BUG: unmatched brace in xpandbraces()
> 
> I'm guessing the existing pair of braces make it cavalier about
> interpreting the last one.

It's slightly more complicated than that... the first expansion takes
place, then the second should find there isn't a pair of braces left.
However, we're not checking for the null at the end of the string
properly, and if we skip that we find a brace a bit later on in memory.

It's not supposed to do that.

pws

diff --git a/Src/glob.c b/Src/glob.c
index af5d082..c9ec97e 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2194,6 +2194,8 @@ bracechardots(char *str, convchar_t *c1p, convchar_t *c2p)
 	pnext[0] != '.' || pnext[1] != '.')
 	return 0;
     pnext += 2;
+    if (!*pnext)
+	return 0;
     if (itok(*pnext)) {
 	if (*pnext == Inbrace)
 	    return 0;
diff --git a/Test/D09brace.ztst b/Test/D09brace.ztst
index 3e667a8..580ed43 100644
--- a/Test/D09brace.ztst
+++ b/Test/D09brace.ztst
@@ -112,3 +112,7 @@
   print -r left{[..]}right
 0:{char..char} ranges with tokenized characters
 >left[right left\right left]right
+
+  print -r {1..10}{..
+0:Unmatched braces after matched braces are left alone.
+>1{.. 2{.. 3{.. 4{.. 5{.. 6{.. 7{.. 8{.. 9{.. 10{..



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