BASH Bug - "return" returns incorrect value when used incorrectly
From:
Dan Reif
Subject:
BASH Bug - "return" returns incorrect value when used incorrectly
Date:
Mon, 10 Mar 2003 18:39:12 -0500
Subject: "return" returns incorrect value when used
incorrectly
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu'
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H -D_GNU_SOURCE
-I. -I. -I./include -I./lib -O2 -march=i386 -mcpu=i686
uname output: Linux [censored hostname by dreif] 2.4.18-3 #1 Thu Apr 18
07:37:53 EDT 2002 i686 unknown
Machine Type: i686-pc-linux-gnu
Bash Version: 2.05a
Patch Level: 0
Release Status: release
Description:
Bash manual indicates:
"Shell
builtin commands return a status of 0 (true) if successful,
and non-zero (false) if an error
occurs while they
execute. All builtins return an exit status of 2 to indicate
incorrect usage."
In fact, usage of "return
X", where X is any integer, from an interactive bash session,
returns a status of 1.
Repeat-By:
export TEMPRAND=$RANDOM; echo
Trying "return \$TEMPRAND"; return $TEMPRAND; echo $?
Fix:
Incorrect usage of return
should return 2, as per the spec.
Dan Reif Fairfield Language Technologies
Makers of the award-winning Rosetta Stone language-learning
software.
Check us out at
http://www.RosettaStone.com
- We have ways to make you think -
[Prev in Thread]
Current Thread
[Next in Thread]
BASH Bug - "return" returns incorrect value when used incorrectly,
Dan Reif<=