git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] t/test-lib.sh: Let test_must_fail fail on signals only

From
Jeff King <peff@peff.net>
Date
Jul 17, 2008, 06:01 UTC
Message-ID
<20080717060143.GA3338@sigill.intra.peff.net>
In-Reply-To
<7v3am9m5ne.fsf@gitster.siamese.dyndns.org>
On Wed, Jul 16, 2008 at 10:38:45PM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> "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
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 15 in “t/test-lib.sh: Let test_must_fail fail on signals only”
  1. 1/2 t/test-lib.sh: Let test_must_fail fail on signals onlyStephan Beyer, Jul 12, 2008
  2. 2/2 t/: Use "test_must_fail git" instead of "! git"Stephan Beyer, Jul 12, 2008
  3. Jakub NarebskiJul 12, 2008
  4. Stephan BeyerJul 12, 2008
  5. t9001: Use "test_must_fail git" instead of "! git"Stephan Beyer, Jul 12, 2008
  6. Jeff KingJul 16, 2008
  7. Junio C HamanoJul 16, 2008
  8. Jeff KingJul 17, 2008
  9. Junio C HamanoJul 17, 2008
  10. Jeff KingJul 17, 2008
  11. Junio C HamanoJul 17, 2008
  12. Jeff KingJul 17, 2008
  13. Johannes SixtJul 17, 2008
  14. Junio C HamanoJul 17, 2008
  15. Stephan BeyerJul 16, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.