Bug 1338689

Summary: zsh exits with "parse error near `!'" for script with unescaped ! character
Product: Red Hat Enterprise Linux 7 Reporter: Tim Speetjens <tspeetje>
Component: zshAssignee: Kamil Dudka <kdudka>
Status: CLOSED ERRATA QA Contact: Jan Kepler <jkejda>
Severity: high Docs Contact: Maxim Svistunov <msvistun>
Priority: urgent    
Version: 7.2CC: fkrska, jkejda
Target Milestone: rcKeywords: Patch, Regression, ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
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: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1339601    
Attachments:
Description Flags
[PATCH 2/7] Resolves: #1338689 - better initialize parser state kdudka: review?

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:55 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