Check for tput

This commit is contained in:
Joshua Bussdieker
2012-03-28 21:52:52 -07:00
parent 611925e4e7
commit 5b7c7d708b
4 changed files with 38 additions and 18 deletions
+9 -4
View File
@@ -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
}
+9 -4
View File
@@ -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
}
+10 -5
View File
@@ -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
}
+10 -5
View File
@@ -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
}