Date: Sun, 19 Jul 2009 22:47:55 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: Romain =?iso-8859-1?Q?Tarti=E8re?= <romain@blogreen.org> Cc: stable@FreeBSD.org Subject: Re: Value of $? lost in the beginning of a function. Message-ID: <20090719204755.GA94947@stack.nl> In-Reply-To: <20090719202638.GA85228@blogreen.org> References: <20090719202638.GA85228@blogreen.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090719204755.GA94947>