Permalink
Browse files

Add rc_halt_s() function. Runs a shell command silently and only halts

/ displays when it fails
  • Loading branch information...
1 parent e4d9ea3 commit 26599e2c252d01c0687e221bb7ff4515288d40a9 @kmoore134 kmoore134 committed Sep 9, 2013
Showing with 20 additions and 0 deletions.
  1. +20 −0 src-sh/libsh/functions.sh
View
20 src-sh/libsh/functions.sh
@@ -665,3 +665,23 @@ rc_halt()
exit_err "Error ${STATUS}: ${CMD}"
fi
}
+
+# Run-command silently, only display / halt if command exits with non-0
+rc_halt_s()
+{
+ CMD="$@"
+
+ if [ -z "${CMD}" ] ; then
+ exit_err "Error: missing argument in rc_halt()"
+ fi
+
+ TMPRCLOG=`mktemp /tmp/.rc_halt.XXXXXX`
+ ${CMD} >${TMPRCLOG} 2>${TMPRCLOG}
+ STATUS=$?
+ if [ ${STATUS} -ne 0 ] ; then
+ cat ${TMPRCLOG}
+ rm ${TMPRCLOG}
+ exit_err "Error ${STATUS}: ${CMD}"
+ fi
+ rm ${TMPRCLOG}
+}

0 comments on commit 26599e2

Please sign in to comment.