RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1241013 - case in a for loop inside subshell causes syntax error
Summary: case in a for loop inside subshell causes syntax error
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: ksh
Version: 6.6
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Michal Hlavinka
QA Contact: Martin Kyral
URL:
Whiteboard:
Depends On:
Blocks: 1172231 1240994 1254457 1269889
TreeView+ depends on / blocked
 
Reported: 2015-07-08 10:09 UTC by Martin Kyral
Modified: 2016-05-11 00:46 UTC (History)
4 users (show)

Fixed In Version: ksh-20120801-32.el6
Doc Type: Bug Fix
Doc Text:
Clone Of: 1212775
Environment:
Last Closed: 2016-05-11 00:46:21 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Proposed patch (854 bytes, patch)
2015-08-19 08:31 UTC, Ondrej Oprala
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:0932 0 normal SHIPPED_LIVE ksh bug fix update 2016-05-10 22:54:18 UTC

Description Martin Kyral 2015-07-08 10:09:11 UTC
ksh in RHEL 6 has the same issue

Version-Release number of selected component (if applicable):
ksh-20120801-28.el6

+++ 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.

--- Additional comment from Ondrej Oprala on 2015-04-18 09:36:45 EDT ---

Hi Jiri,
Yes, this was fixed in 4.3. I have yet to look at the size of the change.

Meanwhile, the more verbose way of writing a case statement still seems to work:
x=$(for i in test; do case $i in (test) echo test;; esac; done)
#                                ^^

Comment 2 Ondrej Oprala 2015-08-19 08:31:46 UTC
Created attachment 1064678 [details]
Proposed patch

Proposed patch backported from ksh-20130409 along with a test. Code is the same in ksh-20140929.

Comment 6 errata-xmlrpc 2016-05-11 00:46:21 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-0932.html


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