Bug 49773

Summary: Function return values larger than 256 are not returned correctly.
Product: [Retired] Red Hat Linux Reporter: Need Real Name <feimer>
Component: bashAssignee: Bernhard Rosenkraenzer <bero>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-07-23 20:49:19 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 Need Real Name 2001-07-23 19:46:42 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.73 [en] (X11; U; Linux 2.0.34 i686)

Description of problem:
A function in a shell script returns a value larger than 256.  After
returning, $? is 1 instead of 256.  When returning a value less than
or equal to 256, $? is the correct value.

How reproducible:
Always

Steps to Reproduce:
1. Run the following shell script.

#!/bin/sh

foo() {
    i=257
    return $i
}

foo
echo "foo returned $?"


Actual Results:  The script outputs: foo returned 1

Expected Results:  The script should output: foo returned 257

Additional info:

Comment 1 Bernhard Rosenkraenzer 2001-07-24 14:43:44 UTC
This is normal behavior. Since the return value of an application is a byte 
(unsigned char), 256 = 0, 257 = 1, ...