Red Hat Bugzilla – Bug 1338689
zsh exits with "parse error near `!'" for script with unescaped ! character
Last modified: 2016-11-03 19:03:20 EDT
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.
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
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.
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