From 5b7c7d708b678825d86f1c8e976d0d65aa505ad4 Mon Sep 17 00:00:00 2001 From: Joshua Bussdieker Date: Wed, 28 Mar 2012 21:52:52 -0700 Subject: [PATCH] Check for tput --- scripts/function/display_error | 13 +++++++++---- scripts/function/display_fatal | 13 +++++++++---- scripts/function/display_message | 15 ++++++++++----- scripts/function/display_warning | 15 ++++++++++----- 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/scripts/function/display_error b/scripts/function/display_error index fe632ad..0881c24 100644 --- a/scripts/function/display_error +++ b/scripts/function/display_error @@ -1,8 +1,13 @@ display_error() { - tput sgr0 - tput setaf 1 - echo "ERROR: $1" >&2 - tput sgr0 + which tput &> /dev/null + if [[ "$?" == "0" ]]; then + tput sgr0 + tput setaf 1 + echo "ERROR: $1" >&2 + tput sgr0 + else + echo "ERROR: $1" >&2 + fi return 1 } diff --git a/scripts/function/display_fatal b/scripts/function/display_fatal index 68fa12d..3185d20 100644 --- a/scripts/function/display_fatal +++ b/scripts/function/display_fatal @@ -1,8 +1,13 @@ display_fatal() { - tput sgr0 - tput setaf 1 - echo "ERROR: $1" >&2 - tput sgr0 + which tput &> /dev/null + if [[ "$?" == "0" ]]; then + tput sgr0 + tput setaf 1 + echo "ERROR: $1" >&2 + tput sgr0 + else + echo "ERROR: $1" >&2 + fi exit 1 } diff --git a/scripts/function/display_message b/scripts/function/display_message index 4513e17..6b0521c 100644 --- a/scripts/function/display_message +++ b/scripts/function/display_message @@ -1,7 +1,12 @@ display_message() { - # GREEN! - tput sgr0 - tput setaf 2 - echo "$1" - tput sgr0 + which tput &> /dev/null + if [[ "$?" == "0" ]]; then + # GREEN! + tput sgr0 + tput setaf 2 + echo "$1" + tput sgr0 + else + echo "$1" + fi } diff --git a/scripts/function/display_warning b/scripts/function/display_warning index f0c475f..0cc6fdd 100644 --- a/scripts/function/display_warning +++ b/scripts/function/display_warning @@ -1,7 +1,12 @@ display_warning() { - # YELLOW! - tput sgr0 - tput setaf 3 - echo "$1" - tput sgr0 + which tput &> /dev/null + if [[ "$?" == "0" ]]; then + # YELLOW! + tput sgr0 + tput setaf 3 + echo "$1" + tput sgr0 + else + echo "$1" + fi }