Skip to content

Commit f6d67e3

Browse files
committed
Use tput for colors and only redefine if not already set
1 parent c5c3fbf commit f6d67e3

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

releasey/libs/_log.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ if [[ -t 2 ]] &&
2727
[[ "${NO_COLOR:-}" != "1" ]] &&
2828
[[ "${TERM:-}" != "dumb" ]] &&
2929
command -v tput >/dev/null; then
30-
RED='\033[0;31m'
31-
GREEN='\033[0;32m'
32-
YELLOW='\033[1;33m'
33-
BLUE='\033[0;34m'
34-
RESET='\033[0m' # No Color
30+
RED=${RED:-$(tput setaf 1)}
31+
GREEN=${GREEN:-$(tput setaf 2)}
32+
YELLOW=${YELLOW:-$(tput bold; tput setaf 3)}
33+
BLUE=${BLUE:-$(tput setaf 4)}
34+
RESET=${RESET:-$(tput sgr0)}
3535
else
36-
RED=''
37-
GREEN=''
38-
YELLOW=''
39-
BLUE=''
40-
RESET=''
36+
RED=${RED:-''}
37+
GREEN=${GREEN:-''}
38+
YELLOW=${YELLOW:-''}
39+
BLUE=${BLUE:-''}
40+
RESET=${RESET:-''}
4141
fi
4242

4343
function print_error() {

0 commit comments

Comments
 (0)