From: Brandon Casey <drafnel@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
Brandon Casey <casey@nrlssc.navy.mil>,
git@vger.kernel.org, drizzd@aon.at, peff@peff.net
Subject: Re: [PATCH 1/2] t/test-lib.sh: support Korn shell by converting GIT_EXIT_OK to GIT_EXIT_CODE
Date: Fri, 9 Oct 2009 17:37:23 -0500 [thread overview]
Message-ID: <ee63ef30910091537i40a8cc68y2513f07c91fb35b@mail.gmail.com> (raw)
In-Reply-To: <7vhbu8s151.fsf@alter.siamese.dyndns.org>
I'm away from a computer right now. Junio, if gmail is showing me the
entirety of your workaround, then no, I don't think that will work.
Your code will always exit non-zero, but there are cases where 'exit
0' is called and a '0' exit status is desired. e.g. when test_done is
called.
I'll look more closely at the suggestions when I get back to a computer.
-brandon
On 10/9/09, Junio C Hamano <gitster@pobox.com> wrote:
> Brandon Casey <casey@nrlssc.navy.mil> writes:
>
>> From: Brandon Casey <drafnel@gmail.com>
>>
>> Commit 6e7b5aaf introduced the concept of GIT_EXIT_OK as a way to indicate
>> to die(), the exit handler, whether the exit was initiated by the test
>> harness, or whether it was unexpected. die() expects $? to contain the
>> value passed to exit(), and when GIT_EXIT_OK is set, die() calls exit with
>> the value in $?. This works as expected when using the Bash shell. For
>> the Korn shell, $? has the value of the last executed statement _before_
>> the call to exit. If that statement completed successfully, then die()
>> would incorrectly exit with a successful status when GIT_EXIT_OK is set.
>
> That's somewhat unexpected, as I did not think this was an anomaly in
> bash. FWIW, dash seems to behave the same way.
>
> The environment in which the shell executes a trap on EXIT shall be
> identical to the environment immediately after the last command executed
> before the trap on EXIT was taken.
>
> If the trap action was triggered because somebody called "exit 13", $? is
> expected to contain that value, because that is the last command executed
> before the trap on EXIT was taken, no?
>
>> So, rather than relying on the behavior of Bash in order to get the exit
>> code from $? inside die(), change GIT_EXIT_OK into GIT_EXIT_CODE, and set
>> it to the code that we want to exit with. This allows the test suite to
>> be run with the Korn shell.
>
> I wonder if the attached is a more clear and contained workaround for this
> issue.
>
> ---
> t/test-lib.sh | 9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index f2ca536..c47a295 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -185,7 +185,14 @@ die () {
> code=$?
> if test -n "$GIT_EXIT_OK"
> then
> - exit $code
> + # Korn does not update $? when "exit 47" triggers
> + # the EXIT trap.
> + if test $code = 0
> + then
> + exit 1
> + else
> + exit $code
> + fi
> else
> echo >&5 "FATAL: Unexpected exit with code $code"
> exit 1
>
--
Sent from my mobile device
next prev parent reply other threads:[~2009-10-09 22:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-09 18:39 [PATCH 1/2] t/test-lib.sh: support Korn shell by converting GIT_EXIT_OK to GIT_EXIT_CODE Brandon Casey
2009-10-09 18:39 ` [PATCH 2/2] Makefile: use the native (Korn) shell on SunOS and IRIX/IRIX64 Brandon Casey
2009-10-09 19:28 ` [PATCH 1/2] t/test-lib.sh: support Korn shell by converting GIT_EXIT_OK to GIT_EXIT_CODE Jonathan Nieder
2009-10-09 20:01 ` Jonathan Nieder
2009-10-09 21:33 ` Junio C Hamano
2009-10-09 22:37 ` Brandon Casey [this message]
2009-10-10 0:57 ` Junio C Hamano
2009-10-10 12:01 ` Clemens Buchacher
2009-10-10 12:24 ` Andreas Schwab
2009-10-10 12:53 ` Ben Walton
2009-10-10 14:03 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ee63ef30910091537i40a8cc68y2513f07c91fb35b@mail.gmail.com \
--to=drafnel@gmail.com \
--cc=casey@nrlssc.navy.mil \
--cc=drizzd@aon.at \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).