Value of $? lost in the beginning of a function.
Jilles Tjoelker
jilles at stack.nl
Sun Jul 19 20:47:56 UTC 2009
On Sun, Jul 19, 2009 at 10:26:38PM +0200, Romain Tartière wrote:
> Hi!
>
> Simple test case:
>
> ----8<----------------------
> #!/bin/sh
> foo()
> {
> echo "\$?=$? \$1=$1"
> }
> false
> foo $?
> ----8<----------------------
>
> % sh foo.sh
> $?=0 $1=1
> % zsh foo.sh
> $?=1 $1=1
> % bash foo.sh
> $?=1 $1=1
>
> As you can see, the value of $? is « lost » when FreeBSD sh enters a
> function. Is this supposed to behave this way?
This has been fixed in 8.x:
Revision 185231 - Directory Listing
Modified Sun Nov 23 20:23:57 2008 UTC (7 months, 3 weeks ago) by stefanf
Fix $? at the first command of a function. The previous exit status was saved
twice and thus lost.
--
Jilles Tjoelker
More information about the freebsd-stable
mailing list