Bug 49773 - Function return values larger than 256 are not returned correctly.
Summary: Function return values larger than 256 are not returned correctly.
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
(Show other bugs)
Version: 7.1
Hardware: i686 Linux
medium
medium
Target Milestone: ---
Assignee: Bernhard Rosenkraenzer
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-07-23 19:46 UTC by Need Real Name
Modified: 2008-05-01 15:38 UTC (History)
0 users

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: ---


Attachments (Terms of Use)

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



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