@@ -97,13 +97,25 @@ readonly appname="$0"
9797# ## CLI control constants
9898# ##############################
9999{
100- # tput is not present on some systems (Alpine Linux), this trick with printf allows to store, not 'codes' - literal symbols
101- readonly red=$( printf ' \033[1;31m' )
102- readonly green=$( printf ' \033[1;32m' )
103- readonly yellow=$( printf ' \033[1;33m' )
104- readonly blue=$( printf ' \033[1;34m' )
105- readonly bold=$( printf ' \033[1m' )
106- readonly reset=$( printf ' \033[0;m' ) # Reset to default output
100+ if test -t ; then # File descriptor is associated with a terminal - output colors
101+ if tput colors; then
102+ # use tput and terminfo DB
103+ readonly red=$( tput setaf 1)
104+ readonly green=$( tput setaf 2)
105+ readonly yellow=$( tput setaf 3)
106+ readonly blue=$( tput setaf 4)
107+ readonly bold=$( tput smso)
108+ readonly reset=$( tput sgr0) # Reset to default output
109+ else
110+ # tput is not present on some systems (Alpine Linux), this trick with printf allows to store, not 'codes' - literal symbols
111+ readonly red=$( printf ' \033[1;31m' )
112+ readonly green=$( printf ' \033[1;32m' )
113+ readonly yellow=$( printf ' \033[1;33m' )
114+ readonly blue=$( printf ' \033[1;34m' )
115+ readonly bold=$( printf ' \033[1m' )
116+ readonly reset=$( printf ' \033[0;m' ) # Reset to default output
117+ fi
118+ fi
107119}
108120# ##############################
109121# ## CLI output functions
0 commit comments