Bug 1116508

Summary: wrong return code from a function
Product: Red Hat Enterprise Linux 6 Reporter: Marcel Kolaja <mkolaja>
Component: kshAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED ERRATA QA Contact: Martin Kyral <mkyral>
Severity: high Docs Contact:
Priority: high    
Version: 6.7CC: borgan, cpelland, fkrska, jkurik, magoldma, mhlavink, mkyral, mpoole, ovasik, yoguma
Target Milestone: rcKeywords: Regression, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: ksh-20120801-21.el6 Doc Type: Bug Fix
Doc Text:
Previously, ksh could skip setting the exit code from the last command of a function. As a result, function could return wrong exit code. The code was updated to make sure exit code from the last command of a function is used and functions now return correct exit code.
Story Points: ---
Clone Of:
: 1136318 1146507 (view as bug list) Environment:
Last Closed: 2014-10-14 07:07:46 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: 1136318    
Attachments:
Description Flags
reproducer
none
patch to fix this none

Description Marcel Kolaja 2014-07-05 12:55:23 UTC
Description of problem:
Under some circumstances, one gets an incorrect return code from a function.

Version-Release number of selected component (if applicable):
ksh-20120801-10.el6_5.6.x86_64

How reproducible:
always

Steps to Reproduce:
1. run the reproducer (see the attachment)

Actual results:
Res is: 0
Res is: 1

Expected results:
Res is: 1
Res is: 1

Additional info:
N/A

Comment 1 Marcel Kolaja 2014-07-05 13:04:44 UTC
Created attachment 914813 [details]
reproducer

Please, note that function foo() is affected by the bug while the return code of function bar() is correct.

Comment 2 Marcel Kolaja 2014-07-05 13:10:28 UTC
ksh-20100621-19.el6_4.4.x86_64 works correctly, so it's a regression.

Comment 5 Marcel Kolaja 2014-07-06 10:16:18 UTC
The regression is caused by the fix of bug #994251.

Comment 10 Michal Hlavinka 2014-09-01 12:24:18 UTC
Created attachment 933343 [details]
patch to fix this

Comment 18 errata-xmlrpc 2014-10-14 07:07:46 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.

http://rhn.redhat.com/errata/RHBA-2014-1381.html