From: Peter Stephenson <p.stephenson@samsung.com>
To: Peter Stephenson <p.stephenson@samsung.com>, zsh-workers@zsh.org
Subject: Re: strange behavior in zsh 5.3.1
Date: Thu, 13 Jul 2017 17:08:40 +0100 [thread overview]
Message-ID: <20170713170840.0e06c473@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20170713162621.0a2fd57a@pwslap01u.europe.root.pri>
On Thu, 13 Jul 2017 16:26:21 +0100
Peter Stephenson <p.stephenson@samsung.com> wrote:
> On Thu, 13 Jul 2017 17:06:34 +0200
> Francesco Giordano <nhoyadx@gmail.com> 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{..
prev parent reply other threads:[~2017-07-13 16:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170713150750epcas3p2abec52da71e68ecb3e6a48f349831ab4@epcas3p2.samsung.com>
2017-07-13 15:06 ` Francesco Giordano
2017-07-13 15:26 ` Peter Stephenson
2017-07-13 16:08 ` Peter Stephenson [this message]
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=20170713170840.0e06c473@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.com \
--cc=zsh-workers@zsh.org \
/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).