[arch-projects] [initscripts] [PATCH 10/12] functions: Don't do stdout/stderr redirection in status(), but allow it outside

Kurt J. Bosch kjb-temp-2009 at alpenjodel.de
Sun Jul 3 06:22:49 EDT 2011


status() did stdout/stderr redirection to /dev/null when calling the given command since the very beginning (commit fd8fde03).
This is not as flexible and intuitive as it could be. It is much better to do redirection when calling when/where ever wanted.
---
 functions |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/functions b/functions
index 38d7054..440ed31 100644
--- a/functions
+++ b/functions
@@ -153,14 +153,17 @@ stat_die() {
 	exit ${1:-1}
 }
 
+# Avoid stolen messages if status() is called with stdout redirection
+exec {RC_FUNCTIONS_STDOUT_FD}>&1
+
 status() {
-	stat_busy "$1"
+	stat_busy "$1" >&${RC_FUNCTIONS_STDOUT_FD}
 	shift
-	if "$@" &>/dev/null; then
-		stat_done
+	if "$@"; then
+		stat_done >&${RC_FUNCTIONS_STDOUT_FD}
 		return 0
 	fi
-	stat_fail
+	stat_fail >&${RC_FUNCTIONS_STDOUT_FD}
 	return 1
 }
 
-- 
1.7.1



More information about the arch-projects mailing list