zsh-workers
 help / color / mirror / code / Atom feed
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
Date: Wed, 20 Jan 2016 11:04:43 +0000	[thread overview]
Message-ID: <20160120110443.63273e43@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <A7E28A2F-E785-4EAF-A1E3-961D4AF95456@kba.biglobe.ne.jp>

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


  reply	other threads:[~2016-01-20 11:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-18  4:23 Martijn Dekker
2016-01-18 17:24 ` Peter Stephenson
2016-01-19 15:57   ` Jun T.
2016-01-19 17:35     ` Peter Stephenson
2016-01-19 18:54       ` Bart Schaefer
2016-01-20 10:48       ` Jun T.
2016-01-20 11:04         ` Peter Stephenson [this message]
2016-01-19 16:03   ` Peter Stephenson
2016-01-19 16:25     ` Mikael Magnusson
2016-01-19 16:34       ` Peter Stephenson
2016-01-19 18:41     ` Bart Schaefer
2016-01-23  0:17   ` Martijn Dekker
2016-01-23  1:49     ` Bart Schaefer
2016-01-26  4:03       ` Martijn Dekker
2016-01-26  4:48         ` Bart Schaefer
2016-01-26 14:07           ` Martijn Dekker
2016-01-27  3:05             ` Bart Schaefer

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=20160120110443.63273e43@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).