From 4ae4f0aa6aaa9d317af1d8d2e880a33cf48c6765 Mon Sep 17 00:00:00 2001 From: Jitendra Adhikari Date: Wed, 2 Oct 2019 23:15:16 +0700 Subject: [PATCH] fix: respect NOCOLOR (-C) --- tusc.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tusc.sh b/tusc.sh index 1d63af1..9930ed9 100755 --- a/tusc.sh +++ b/tusc.sh @@ -16,7 +16,10 @@ declare -A HEADERS # assoc headers of last request declare ISOK=0 # is last request ok? # message helpers -line() { echo -e "\e[${3:-0};$2m$1\e[0m"; if [[ "$4" != "" ]]; then exit $4; fi } +line() { + [[ $NOCOLOR ]] && echo -e "$1" || echo -e "\e[${3:-0};$2m$1\e[0m" + [[ "$4" == "" ]] || exit $4 +} error() { line "$1" 31 0 $2; } ok() { line "${1:- Done}" 32 0 $2; } info() { line "$1" 33 0 $2; }