From: Reto Buerki Date: Thu, 6 Dec 2012 14:48:14 +0000 (+0100) Subject: Provide log_action and log_status functions X-Git-Tag: 5.0.2rc1~1^2~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c120f25e60415bda8d8cce752e34a0bfff264ff5;p=thirdparty%2Fstrongswan.git Provide log_action and log_status functions These two functions are used to log action descriptions and the corresponding command exit status in a consistent way. --- diff --git a/testing/scripts/function.sh b/testing/scripts/function.sh index 04723f1055..daf56486bc 100755 --- a/testing/scripts/function.sh +++ b/testing/scripts/function.sh @@ -16,9 +16,11 @@ ############################################ -# print output in color +# output functions # +export TERM=xterm + function cecho { echo -e "\033[1;31m$1\033[0m" } @@ -30,6 +32,29 @@ function cecho-n { echo -en "\033[1;31m$1\033[0m" } +# log an action +# $1 - current action description +log_action() +{ + /bin/echo -n "[....] $1 " +} + +# log an action status +# $1 - exit status of action +log_status() +{ + RED=$(tput setaf 1) + GREEN=$(tput setaf 2) + NORMAL=$(tput op) + + tput hpa 0 + if [ $1 -eq 0 ]; then + /bin/echo -ne "[${GREEN} ok ${NORMAL}" + else + /bin/echo -ne "[${RED}FAIL${NORMAL}" + fi + echo +} ############################################# # output all args to stderr and exit with