Re: [PATCH 1/2] t/test-lib.sh: support Korn shell by converting GIT_EXIT_OK to GIT_EXIT_CODE
- From
Clemens Buchacher <drizzd@aon.at>
- Date
- Oct 10, 2009, 12:01 UTC
- Message-ID
- <20091010120121.GA16336@localhost>
- In-Reply-To
- <1eweIwf5YoFwmLPWwEFN69a2f-EUnj_kgiagVJoVQYfNQeLjlpm12U84RKxhzjh0NJv36SqO12lAX2c_x0WSgA@cipher.nrlssc.navy.mil>
Hi,
On Fri, Oct 09, 2009 at 01:39:56PM -0500, Brandon Casey wrote:
> For the Korn shell, $? has the value of the last executed statement > _before_ the call to exit.
I just installed ksh/stable (version 93s+ 2008-01-31) on Debian and it behaves correctly. Maybe you need to upgrade? This really looks like a bug in your shell to me.
Show 12 quoted lines
> die () {
> code=$?
> - if test -n "$GIT_EXIT_OK"
> + if test -n "$GIT_EXIT_CODE"
> then
> - exit $code
> + exit $GIT_EXIT_CODE
> else
> echo >&5 "FATAL: Unexpected exit with code $code"
> exit 1
> fi
> }So in your shell an unexpected exit will always output this?
FATAL: Unexpected exit with code <some command>
If we can't rely on the value of $?, we should not use it.
Clemens