git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Stephan Beyer <s-beyer@gmx.net>,
	Johannes Sixt <j.sixt@viscovery.net>,
	git@vger.kernel.org
Subject: Re: [PATCH 1/2] t/test-lib.sh: Let test_must_fail fail on signals only
Date: Thu, 17 Jul 2008 02:01:43 -0400	[thread overview]
Message-ID: <20080717060143.GA3338@sigill.intra.peff.net> (raw)
In-Reply-To: <7v3am9m5ne.fsf@gitster.siamese.dyndns.org>

On Wed, Jul 16, 2008 at 10:38:45PM -0700, Junio C Hamano wrote:

> "Only the least significant 8 bits (that is, status & 0377) shall be
> available to a waiting parent process".  So it is not just "at least on
> Linux" but is a well defined behaviour.
> 
> http://www.opengroup.org/onlinepubs/000095399/functions/exit.html

Ah, thanks. I read that same text in the Linux manpage but didn't think
to check that it was POSIX. However, some of our systems aren't quite
POSIX...check out 2488df84 (builtin run_command: do not exit with -1) by
Johannes Sixt [who is now cc'd]. I assume that was a Windows fallout.

> I would however agree that when we do mean 255 we should probably write
> 255, not (-1).  It is easier to document things that way.

I started to fix the callsites that Stephan mentioned, but it really is
convenient to be able to 'return error("foo")' (or even return
func_that_calls_error(), and tracking down deep calls is time consuming
and error prone). So maybe we should just enhance the change from
2488df84 and special case "-1" into "1"?

diff --git a/git.c b/git.c
index 6b600b5..4f28e8c 100644
--- a/git.c
+++ b/git.c
@@ -240,7 +240,7 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)
 
 	status = p->fn(argc, argv, prefix);
 	if (status)
-		return status & 0xff;
+		return status == -1 ? 1 : status & 0xff;
 
 	/* Somebody closed stdout? */
 	if (fstat(fileno(stdout), &st))

-Peff

  reply	other threads:[~2008-07-17  6:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-12 15:47 [PATCH 1/2] t/test-lib.sh: Let test_must_fail fail on signals only Stephan Beyer
2008-07-12 15:47 ` [PATCH 2/2] t/: Use "test_must_fail git" instead of "! git" Stephan Beyer
2008-07-12 16:04   ` Jakub Narebski
2008-07-12 21:43     ` Stephan Beyer
2008-07-12 21:30   ` [SQUASH PATCH] t9001: " Stephan Beyer
2008-07-16  5:18 ` [PATCH 1/2] t/test-lib.sh: Let test_must_fail fail on signals only Jeff King
2008-07-16  5:54   ` Junio C Hamano
2008-07-17  5:18     ` Jeff King
2008-07-17  5:38       ` Junio C Hamano
2008-07-17  6:01         ` Jeff King [this message]
2008-07-17  6:31           ` Junio C Hamano
2008-07-17  6:38             ` Jeff King
2008-07-17  7:22               ` Johannes Sixt
2008-07-17  7:25                 ` Junio C Hamano
2008-07-16 11:57   ` Stephan Beyer

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=20080717060143.GA3338@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    --cc=s-beyer@gmx.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).