Thread (3 messages) flat view 3 messages, 1 author, 2016-06-15
DORMANTno replies

Revision rfc of 2 in this series.

Revisions (2)
  1. rfc current
  2. v3 [diff vs current]

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

From: Fredrik Gustafsson <hidden>
Date: 2016-06-15 22:51:14
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
Mentored-by: Jens Lehmann [off-list ref]
Mentored-by: Heiko Voigt [off-list ref]
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help