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

[RFC PATCH 1/2] sh-setup: Make die take the error code as param.

From
Fredrik Gustafsson <iveqy@iveqy.com>
Date
May 15, 2011, 12:42 UTC
Message-ID
<1f45f5634f08cb0f63d61d8b734a2cf7bebf591b.1305462132.git.iveqy@iveqy.com>
In-Reply-To
<cover.1305462132.git.iveqy@iveqy.com>

die used to print all parameters and then exit with code 1. Now die prints the first parameter and uses the optional second parameter as the exit code. The default exit code is 1.

This allows scripts to control the exit code when they call die.

All current git-code only uses the first parameter of die today so this change has no impact on them.

Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com>
Mentored-by: Jens Lehmann <Jens.Lehmann@web.de>
Mentored-by: Heiko Voigt <hvoigt@hvoigt.net>
---
 git-sh-setup.sh |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index aa16b83..6aa6c59 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -40,7 +40,11 @@ git_broken_path_fix () {
 # @@BROKEN_PATH_FIX@@
 
 die() {
-	echo >&2 "$@"
+	echo >&2 "$1"
+	if test $2
+	then
+		exit $2
+	fi
 	exit 1
 }
 
-- 
1.7.5.1.219.ge2152.dirty
Previous: Fredrik GustafssonNext: Junio C Hamano
Message 2 of 5 in “submodule update continue”
  1. 0/2 submodule update continueFredrik Gustafsson, May 15, 2011
  2. 1/2 sh-setup: Make die take the error code as param.Fredrik Gustafsson, May 15, 2011
  3. Junio C HamanoMay 15, 2011
  4. 2/2 submodule update: continue when a checkout failsFredrik Gustafsson, May 15, 2011
  5. Junio C HamanoMay 15, 2011

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.