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

[PATCH v3 1/2] Add new function die_with_status

From
Fredrik Gustafsson <iveqy@iveqy.com>
Date
Jun 9, 2011, 07:47 UTC
Message-ID
<1307605623-2831-2-git-send-email-iveqy@iveqy.com>
In-Reply-To
<1307605623-2831-1-git-send-email-iveqy@iveqy.com>
This function takes the exit code as a parameter.
This allows scripts to control the exit code when they need to die.

Make the old die-function to use die_with_status for simpler maintenance.

die no longer prints empty die messages, this is a changed behavior.
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 |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 94e26ed..1a91f6e 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -40,8 +40,16 @@ git_broken_path_fix () {
 # @@BROKEN_PATH_FIX@@
 
 die() {
-	echo >&2 "$@"
-	exit 1
+	die_with_status 1 $@
+}
+die_with_status() {
+	stat=$1
+	shift
+	if test ${#@} -gt 0
+	then
+		echo >&2 "$@"
+	fi
+	exit $stat
 }
 
 GIT_QUIET=
-- 
1.7.6.rc0.14.g4fc55
Previous: Fredrik GustafssonNext: Junio C Hamano
Message 2 of 6 in “submodule update continue”
  1. 0/2 submodule update continueFredrik Gustafsson, Jun 9, 2011
  2. 1/2 Add new function die_with_statusFredrik Gustafsson, Jun 9, 2011
  3. Junio C HamanoJun 13, 2011
  4. 2/2 submodule update: continue when a checkout failsFredrik Gustafsson, Jun 9, 2011
  5. Junio C HamanoJun 9, 2011
  6. 2/2 submodule update: continue when a checkout failsFredrik Gustafsson, Jun 13, 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.