Bug 1245094

Summary: case in a for loop inside subshell causes syntax error
Product: Red Hat Enterprise Linux 7 Reporter: Martin Kyral <mkyral>
Component: kshAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1212775 Environment:
Last Closed: 2015-07-21 08:09:15 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:

Description Martin Kyral 2015-07-21 08:06:31 UTC
The very same bug is in ksh / RHEL-7, too.

Version-Release number of selected component (if applicable):
ksh-20120801-22.el7

Additional info:
This works in mksh-46-5.el7

+++ This bug was initially created as a clone of Bug #1212775 +++

Description of problem:

# this works
$ x=$(for i in test; do echo $i; done)
$ echo $x
test

# this too, works
$ i=test
$ x=$(case $i in test) echo test;; esac)
$ echo $x
test

# this does not
$ x=$(for i in test; do case $i in test) echo test;; esac; done)
-bash: syntax error near unexpected token `;;'

# however removing the output-into-variable makes it work
$ (for i in test; do case $i in test) echo test;; esac; done)
test


Version-Release number of selected component (if applicable):
bash-4.2.46-12.el7

How reproducible:
always

Actual results:
expression fails on syntax error

Expected results:
the subshell output is assigned to a variable

Additional info:
This *works* on my bash-4.3.30-2.fc21, so there might have been an upstream fix.

Comment 1 Martin Kyral 2015-07-21 08:09:15 UTC

*** This bug has been marked as a duplicate of bug 1241014 ***