Bug 484348 - Error parsing $(...)
Summary: Error parsing $(...)
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: zsh
Version: 5.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: James Antill
QA Contact: James Antill
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-02-06 11:25 UTC by Tomas Smetana
Modified: 2018-10-20 01:36 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 496791 (view as bug list)
Environment:
Last Closed: 2009-05-06 15:31:42 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Proposed patch (386 bytes, patch)
2009-02-06 11:31 UTC, Tomas Smetana
no flags Details | Diff
Improved patch (783 bytes, patch)
2009-02-27 09:34 UTC, Tomas Smetana
no flags Details | Diff
Even more improved patch... (802 bytes, patch)
2009-03-02 11:09 UTC, Tomas Smetana
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2009:0463 0 normal SHIPPED_LIVE zsh bug fix update 2009-05-06 15:31:35 UTC

Description Tomas Smetana 2009-02-06 11:25:20 UTC
Description of problem:
Consider the following script:

#!/bin/zsh
# Comment containing '
VAR=$(
echo a
# Comment containing '
)
echo $VAR

The script is syntactically correct but zsh throws an error executing it.

Version-Release number of selected component (if applicable):
zsh-4.2.6-2 (reproduced also with Fedora's  zsh-4.3.6-5 version)

How reproducible:
always

Steps to Reproduce:
1. run the script above
  
Actual results:
parse error near `VAR=$('

Expected results:
a

Additional info:
ksh and bash are able to run the script without error.  No error appears when the $(...) command substitution is replaced with `...`.  I think there's a bug in parsing the content in the round brackets: the '\'' character is treated as special even when it appears in a comment.

Comment 1 Tomas Smetana 2009-02-06 11:31:22 UTC
Created attachment 331118 [details]
Proposed patch

Change in the (...) parsing function: if the '#' is found, all the characters until the newline lose their special meaning.

Comment 7 Tomas Smetana 2009-02-26 09:01:02 UTC
Patch has been sent upstream: http://www.zsh.org/mla/workers/2009/msg00396.html

Comment 8 Tomas Smetana 2009-02-27 09:34:21 UTC
Created attachment 333448 [details]
Improved patch

The previous patch didn't really care about the context of the '#' character which might have caused problems in cases where it was not meant as beginning of a comment.

I'm attaching the version that was committed upstream: http://zsh.cvs.sourceforge.net/viewvc/zsh/zsh/Src/lex.c?r1=1.49&r2=1.50

Comment 11 Tomas Smetana 2009-03-02 11:09:41 UTC
Created attachment 333724 [details]
Even more improved patch...

There was still a small problem with the latest patch:  http://www.zsh.org/mla/workers/2009/msg00408.html. (upstream lex.c: http://zsh.cvs.sourceforge.net/viewvc/zsh/zsh/Src/lex.c?revision=1.51&view=markup#l_1799)

Comment 16 errata-xmlrpc 2009-05-06 15:31:42 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-0463.html


Note You need to log in before you can comment on or make changes to this bug.