From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@sunsite.dk
Cc: "Tomáš Smetana" <t.smetana@gmail.com>
Subject: Re: PATCH: Error parsing $(...)
Date: Fri, 27 Feb 2009 10:19:41 +0000 [thread overview]
Message-ID: <20090227101941.5552f177@pws-pc> (raw)
In-Reply-To: <20090226225743.1b707d46@pws-pc>
oncurrene of 43
On Thu, 26 Feb 2009 22:57:43 +0000
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> It's not quite that simple, since "#" is only a comment character
> at the start of a word. The following is better, I hope I haven't
> missed any cases...
I should have tested for whitespace including a possible newline, not
separators, before the "#" for this level of parsing, and I should have
marked that a previous comment line ended in whitespace.
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.50
diff -u -r1.50 lex.c
--- Src/lex.c 26 Feb 2009 23:01:49 -0000 1.50
+++ Src/lex.c 27 Feb 2009 10:17:51 -0000
@@ -1813,7 +1813,7 @@
c = hgetc();
if (itok(c) || lexstop)
break;
- iswhite = isep(c);
+ iswhite = inblank(c);
switch (c) {
case '(':
pct++;
@@ -1861,6 +1861,7 @@
add(c);
while ((c = hgetc()) != '\n' && !lexstop)
add(c);
+ iswhite = 1;
}
break;
}
Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.17
diff -u -r1.17 A01grammar.ztst
--- Test/A01grammar.ztst 11 May 2008 19:03:58 -0000 1.17
+++ Test/A01grammar.ztst 27 Feb 2009 10:17:51 -0000
@@ -503,3 +503,15 @@
$ZTST_testdir/../Src/zsh -f NonExistentScript
127q:Non-existent script causes exit status 127
?$ZTST_testdir/../Src/zsh: can't open input file: NonExistentScript
+
+ (setopt nonomatch
+ # use this to get stuff at start of line
+ contents=$'# comment \'\necho value #with " stuff\n# comment\n#comment
+ echo not#comment\n'
+ eval 'VAR=$('"$contents"')'
+ print -l $VAR)
+0:comments within $(...)
+>value
+>not#comment
+
+
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
next prev parent reply other threads:[~2009-02-27 10:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-26 8:45 Tomáš Smetana
2009-02-26 22:57 ` Peter Stephenson
2009-02-27 10:19 ` Peter Stephenson [this message]
2009-02-27 16:33 ` Bart Schaefer
2009-03-02 10:06 ` Peter Stephenson
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=20090227101941.5552f177@pws-pc \
--to=p.w.stephenson@ntlworld.com \
--cc=t.smetana@gmail.com \
--cc=zsh-workers@sunsite.dk \
/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).