Bug 1338689 - zsh exits with "parse error near `!'" for script with unescaped ! character
Summary: zsh exits with "parse error near `!'" for script with unescaped ! character
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: zsh   
(Show other bugs)
Version: 7.2
Hardware: x86_64
OS: Linux
urgent
high
Target Milestone: rc
: ---
Assignee: Kamil Dudka
QA Contact: Jan Kepler
Maxim Svistunov
URL:
Whiteboard:
Keywords: Patch, Regression, ZStream
Depends On:
Blocks: 1339601
TreeView+ depends on / blocked
 
Reported: 2016-05-23 09:37 UTC by Tim Speetjens
Modified: 2016-11-03 23:03 UTC (History)
2 users (show)

Fixed In Version: zsh-5.0.2-23.el7
Doc Type: Bug Fix
Doc Text:
*zsh* parses unescaped exclamation marks correctly now Previously, *zsh* parser state was insufficiently initialized. Consequently, *zsh* failed to parse unescaped exclamation marks in a text string. With this update, *zsh* properly initializes the parser state. As a result, *zsh* now parses unescaped exclamation marks correctly.
Story Points: ---
Clone Of:
: 1339601 (view as bug list)
Environment:
Last Closed: 2016-11-03 23:03:20 UTC
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
[PATCH 2/7] Resolves: #1338689 - better initialize parser state (2.03 KB, patch)
2016-05-23 15:25 UTC, Kamil Dudka
kdudka: review?
Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2152 normal SHIPPED_LIVE zsh bug fix update 2016-11-03 13:13:01 UTC

Description Tim Speetjens 2016-05-23 09:37:06 UTC
Description of problem:
zsh exits with "parse error near `!'" for script with unescaped ! character

Version-Release number of selected component (if applicable):
zsh-5.0.2-19.el7.x86_64

How reproducible:
100%

Steps to Reproduce:

$ cat simple.ksh 
#!/bin/ksh

if [[ -z $(echo !) ]]; then
  echo this does not happen
else
  echo ok
fi

$ zsh simple.ksh
simple.ksh:3: parse error near `!'
simple.ksh:4: parse error near `$(echo !) ]]; then'

with ksh linked to zsh, to invoke zsh in posix mode:
$ ksh simple.ksh
simple.ksh:3: parse error near `!'
simple.ksh:4: parse error near `$(echo !) ]]; then'


Actual results:
Script exits with error: parse error near `!'

Expected results:
Script runs fine

Additional info:

Affected:
zsh version 5.0.2-19.el7

Ok:
zsh up until and including 5.0.2-14.el7,
zsh-5.0.8-8.fc22.x86_64 in fedora22

This issue seems to be limited to the $( ) notation, as the following script runs fine:
$ cat simple-ok.ksh 
#!/bin/ksh

if [[ -z `echo !` ]]; then
  echo this does not happen
else
  echo ok
fi

Also AT&T ksh runs this script fine.

Comment 2 Kamil Dudka 2016-05-23 13:54:39 UTC
This seems to be yet another regression introduced by the fix for bug #1241023.  git-bisect points to the following (non-trivial) upstream commit as the fix for this bug:

https://sourceforge.net/p/zsh/code/ci/cfd91eac

Comment 4 Kamil Dudka 2016-05-23 15:25 UTC
Created attachment 1160672 [details]
[PATCH 2/7] Resolves: #1338689 - better initialize parser state

This fix is isolated out from a huge upstream commit that includes major
code refactoring changes together with the initialization fix actually
needed to resolve #1338689.

Comment 12 errata-xmlrpc 2016-11-03 23:03:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2152.html


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