Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

/ displays when it fails
  • Loading branch information...
commit 26599e2c252d01c0687e221bb7ff4515288d40a9 1 parent e4d9ea3
Kris Moore kmoore134 authored

Showing 1 changed file with 20 additions and 0 deletions. Show diff stats Hide diff stats

  1. +20 0 src-sh/libsh/functions.sh
20 src-sh/libsh/functions.sh
@@ -665,3 +665,23 @@ rc_halt()
665 665 exit_err "Error ${STATUS}: ${CMD}"
666 666 fi
667 667 }
  668 +
  669 +# Run-command silently, only display / halt if command exits with non-0
  670 +rc_halt_s()
  671 +{
  672 + CMD="$@"
  673 +
  674 + if [ -z "${CMD}" ] ; then
  675 + exit_err "Error: missing argument in rc_halt()"
  676 + fi
  677 +
  678 + TMPRCLOG=`mktemp /tmp/.rc_halt.XXXXXX`
  679 + ${CMD} >${TMPRCLOG} 2>${TMPRCLOG}
  680 + STATUS=$?
  681 + if [ ${STATUS} -ne 0 ] ; then
  682 + cat ${TMPRCLOG}
  683 + rm ${TMPRCLOG}
  684 + exit_err "Error ${STATUS}: ${CMD}"
  685 + fi
  686 + rm ${TMPRCLOG}
  687 +}

0 comments on commit 26599e2

Please sign in to comment.
Something went wrong with that request. Please try again.