Bug 49773 - Function return values larger than 256 are not returned correctly.
Function return values larger than 256 are not returned correctly.
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
7.1
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Bernhard Rosenkraenzer
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-07-23 15:46 EDT by Need Real Name
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-07-23 16:49:19 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2001-07-23 15:46:42 EDT
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 10:43:44 EDT
This is normal behavior. Since the return value of an application is a byte 
(unsigned char), 256 = 0, 257 = 1, ...

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