diff options
author | Reto Buerki <reet@codelabs.ch> | 2012-12-06 15:48:14 +0100 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-01-17 15:22:09 +0100 |
commit | c120f25e60415bda8d8cce752e34a0bfff264ff5 (patch) | |
tree | 13fd1989c8bec778c5b41ab5fc37b586eefeb53d | |
parent | 3c9df38c5e81eb9e7b3e1bf1f6ca6a7573c877ed (diff) | |
download | strongswan-c120f25e60415bda8d8cce752e34a0bfff264ff5.tar.bz2 strongswan-c120f25e60415bda8d8cce752e34a0bfff264ff5.tar.xz |
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.
-rwxr-xr-x | testing/scripts/function.sh | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/testing/scripts/function.sh b/testing/scripts/function.sh index 04723f105..daf56486b 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 |