Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham
	autolearn_force=no version=3.4.0
X-AuditID: cbfec7f4-f79026d00000418a-e6-569f69ce21fe
Date: Wed, 20 Jan 2016 11:04:43 +0000
From: Peter Stephenson <p.stephenson@samsung.com>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [BUG] quoting within bracket patterns has no effect
Message-id: <20160120110443.63273e43@pwslap01u.europe.root.pri>
In-reply-to: <A7E28A2F-E785-4EAF-A1E3-961D4AF95456@kba.biglobe.ne.jp>
References: <569C68AB.2010806@inlv.org>
 <20160118172434.2fb7d5b9@pwslap01u.europe.root.pri>
 <C61F4B81-0BCF-45CD-9DE3-202ED2D268FF@kba.biglobe.ne.jp>
 <20160119173511.53b92033@pwslap01u.europe.root.pri>
 <A7E28A2F-E785-4EAF-A1E3-961D4AF95456@kba.biglobe.ne.jp>
Organization: Samsung Cambridge Solution Centre
X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu)
MIME-version: 1.0
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7bit
X-Brightmail-Tracker:
 H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t/xK7rnMueHGZyYy2NxsPkhkwOjx6qD
	H5gCGKO4bFJSczLLUov07RK4MnacuM1WMI2rYtPpBWwNjA/Zuxg5OSQETCSezXvAAmGLSVy4
	t56ti5GLQ0hgKaPEz+PXmSGcGUwSL9c3sUA45xgljk+6wAbSIiRwllHiyXVuEJtFQFXi4rIF
	YGPZBAwlpm6azQhiiwjoS1z8cwvMFhZwkLh+vw2shlfAXqJx6QywOKeAq0Tjmt2MEAs6mST6
	+/uZQRL8QM1X/35igrjPXmLmlTOMEM2CEj8m3wO7m1lAS2LztiZWCFteYvOat8wQx6lL3Li7
	m30Co/AsJC2zkLTMQtKygJF5FaNoamlyQXFSeq6hXnFibnFpXrpecn7uJkZIQH/Zwbj4mNUh
	RgEORiUeXobmeWFCrIllxZW5hxglOJiVRHjz4+aHCfGmJFZWpRblxxeV5qQWH2KU5mBREued
	u+t9iJBAemJJanZqakFqEUyWiYNTqoFx8joH15hJRm9cdrTGPrh/iuViWdiUg+d7fSYfeLDw
	XsC2TR9jOGVNpR7s0F7Z4Jh04bVy48R901IWBmbwCTCvOylhIpH8w5L3xdLdFrek385a/yZf
	fVX0RAej9C1JniEdr1cs/nB5vlfbdSPG+5Hhux7P+uv0q3le7lWXi/c7eGbnt+9fvV7xnBJL
	cUaioRZzUXEiAMzTJgtkAgAA
X-Seq: zsh-workers 37705

On Wed, 20 Jan 2016 19:48:00 +0900
Jun T. <takimoto-j@kba.biglobe.ne.jp> wrote:
> In gettokstr(), seen_brct is set to 1 by the '[' and
> never reset to 0, and the '-' is converted to Dash.
> 
> % x=
> % y=yes
> % echo ${x:-$y}
> yes
> % a[1]=${x:-$y}
> % echo '<'$a[1]'>'
> <>

There could well be more of these --- as we don't parse patterns until
late (we don't know it's a pattern) and quote handling is done
early I don't see a more general fix.

diff --git a/Src/lex.c b/Src/lex.c
index 3ea878c..23b0a1c 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1026,8 +1026,10 @@ gettokstr(int c, int sub)
 		    c = Inbrace;
 		    ++bct;
 		    cmdpush(CS_BRACEPAR);
-		    if (!in_brace_param)
-			in_brace_param = bct;
+		    if (!in_brace_param) {
+			if ((in_brace_param = bct))
+			    seen_brct = 0;
+		    }
 		} else {
 		    hungetc(e);
 		    lexstop = 0;
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index bcea980..a6817fe 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1880,3 +1880,9 @@
 >'two words'
 >'three so-called '\''words'\'
 >'three so-called ''words'''
+
+  array=(one two three)
+  array[1]=${nonexistent:-foo}
+  print $array
+0:"-" works after "[" in same expression (Dash problem)
+>foo two three

