Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Error parsing $(...)

  I have stumbled upon a problem with comments in $(...) construct.  Consider
the following script:

# Comment containing '
echo a
# Comment containing '
echo $VAR

This is syntactically correct but zsh would throw an error parsing it:
parse error near `VAR=$('

Note that the same script works OK in ksh or bash. It seems that the '\''
character doesn't lose its special meaning even though it appears in the
comment.  I have written a patch (attached) which seems to fix the problem.
Could you please review the patch and consider applying it?

Please cc: me in the answers I'm not subscribed.

Thanks and regards,
Tomas Smetana
Index: Src/lex.c
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.49
diff -u -r1.49 lex.c
--- Src/lex.c	25 Feb 2009 10:24:01 -0000	1.49
+++ Src/lex.c	26 Feb 2009 08:28:08 -0000
@@ -1854,6 +1854,11 @@
+	case '#':
+	    add(c);
+	    while ((c = hgetc()) != '\n' && !lexstop)
+		add(c);
+	    break;
     while (pct);

Messages sorted by: Reverse Date, Date, Thread, Author