Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: Error parsing $(...)
- X-seq: zsh-workers 26622
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: PATCH: Error parsing $(...)
- Date: Fri, 27 Feb 2009 10:19:41 +0000
- Cc: TomÃÅ Smetana <t.smetana@xxxxxxxxx>
- In-reply-to: <20090226225743.1b707d46@pws-pc>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20090226094507.43cf3c16@xxxxxxxxx> <20090226225743.1b707d46@pws-pc>
oncurrene of 43
On Thu, 26 Feb 2009 22:57:43 +0000
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> 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@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author