Bug 522002

Summary: ksh is showing an incorrect exit status ($?) in some cases
Product: Red Hat Enterprise Linux 5 Reporter: Ryan Leslie <rylesny>
Component: kshAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED CURRENTRELEASE QA Contact: BaseOS QE <qe-baseos-auto>
Severity: high Docs Contact:
Priority: low    
Version: 5.2CC: kvolny, rylesny
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-15 10:30:33 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ryan Leslie 2009-09-09 03:21:40 UTC
$ uname -a
Linux <edited> 2.6.18-92.1.10.el5 #1 SMP Wed Jul 23 03:56:11 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux

$ /bin/ksh --version
  version         sh (AT&T Research) 93t+ 2009-01-20

$ cat works
#!/bin/ksh

echo hi | while read f
do
    cat notarealfile || echo fails
done

$ ./works  # The result is expected.
cat: notarealfile: No such file or directory
fails

$ cat broken
#!/bin/ksh

echo hi | while read f
do
    cat notarealfile || echo fails
done
exit 0

$ ./broken  # The exit status of 'cat notarealfile' will incorrectly be 0, so 'fails' will not be printed.
cat: notarealfile: No such file or directory

$ diff works broken  # All we did was add 'exit 0'
6a7
> exit 0

$

Comment 1 Michal Hlavinka 2009-09-15 10:02:43 UTC
this bug was introduced in upstream ksh 2009-01-20 and fixed in upstream ksh 2009-02-02

Comment 2 Michal Hlavinka 2009-09-15 10:30:33 UTC
this bug exists only in ksh 2009-01-20, but RHEL 5 contains ksh 2008-02-02