[arch-projects] [initscripts] [PATCH 10/20] functions: Make status() return the actual exit code

Kurt J. Bosch kjb-temp-2009 at alpenjodel.de
Sun Jul 10 12:56:58 EDT 2011


The exit code returned by the given command might be useful/expected, so don't discard but return it.
---
 functions |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/functions b/functions
index 202db30..6efcd52 100644
--- a/functions
+++ b/functions
@@ -156,12 +156,10 @@ stat_die() {
 status() {
 	stat_busy "$1"
 	shift
-	if "$@" &>/dev/null; then
-		stat_done
-		return 0
-	fi
-	stat_fail
-	return 1
+	"$@" &>/dev/null
+	local ret=$?
+	(( $ret == 0 )) && stat_done || stat_fail
+	return $ret
 }
 
 #  usage : in_array( $needle, $haystack )
-- 
1.7.1



More information about the arch-projects mailing list