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

Re: 1.7.2 cycle will open soon

From
Jeff King <peff@peff.net>
Date
May 6, 2010, 06:54 UTC
Message-ID
<20100506065419.GA21009@coredump.intra.peff.net>
In-Reply-To
<20100506064428.GA29360@progeny.tock>
On Thu, May 06, 2010 at 01:44:28AM -0500, Jonathan Nieder wrote:
> > Am I missing something?
> 
> If cleanup fails, I want to catch it.  Would something like this do?
Ah, I see.
Show 12 quoted lines
>  test_run_ () {
> 	test_cleanup=:
> 	eval >&3 2>&4 "$1"
> 	eval_ret=$?
> 	eval >&3 2>&4 "$test_cleanup" && (exit "$eval_ret")
> 	eval_ret=$?
> 	return 0
>  }
> 
>  test_when_finished () {
> 	test_cleanup="$* && $test_cleanup"
>  }

Doesn't that violate your rule that the cleanup will _always_ be run? Here, if the first cleanup fails, we don't run subsequent ones.

Perhaps the simplest would be to just keep a cleanup_ret in the second eval (where you have eval_ret in the original patch), and then act appropriately after the eval finishes. That would be easier on the eyes, too, I think.

Show 8 quoted lines
> To permit a line break at the end of a cleanup command, one can do
> 
>  test_when_finished () {
> 	test_cleanup="{ $*
> 		} && $test_cleanup"
>  }
> 
> but that might not be worth the ugliness.

I doubt anyone will put a linebreak in, but it is probably better to be defensive, and the ugliness is at least contained only in that function.

-Peff
Previous: Jonathan NiederNext: Jonathan Nieder
Message 4 of 11 in “1.7.2 cycle will open soon”
  1. Junio C HamanoMay 5, 2010
  2. Jeff KingMay 6, 2010
  3. Jonathan NiederMay 6, 2010
  4. Jeff KingMay 6, 2010
  5. test-lib: some shells do not let $? propagate into an evalJonathan Nieder, May 6, 2010
  6. Jeff KingMay 6, 2010
  7. Junio C HamanoMay 6, 2010
  8. Johannes SixtMay 6, 2010
  9. Jeff KingMay 6, 2010
  10. Jonathan NiederMay 6, 2010
  11. Johannes SixtMay 6, 2010

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.