Portable way to color

Change-Id: I62ae1da772f4e3eb80ed26aca89ebe47aff8efa7
This commit is contained in:
Jacky Cao 2015-05-15 22:12:53 +08:00 committed by Jacky Tsao
parent c340a30641
commit 89483b83fb
1 changed files with 9 additions and 9 deletions

View File

@ -29,7 +29,7 @@ EOF
T=$(gettop) T=$(gettop)
local A local A
A="" A=""
for i in `cat $T/build/envsetup.sh | sed -n "/^[ \t]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do for i in `cat $T/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
A="$A $i" A="$A $i"
done done
echo $A echo $A
@ -1426,9 +1426,9 @@ function pez {
local retval=$? local retval=$?
if [ $retval -ne 0 ] if [ $retval -ne 0 ]
then then
echo -e "\e[0;31mFAILURE\e[00m" echo $'\E'"[0;31mFAILURE\e[00m"
else else
echo -e "\e[0;32mSUCCESS\e[00m" echo $'\E'"[0;32mSUCCESS\e[00m"
fi fi
return $retval return $retval
} }
@ -1450,9 +1450,9 @@ function make()
local secs=$(($tdiff % 60)) local secs=$(($tdiff % 60))
local ncolors=$(tput colors 2>/dev/null) local ncolors=$(tput colors 2>/dev/null)
if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
color_failed="\e[0;31m" color_failed=$'\E'"[0;31m"
color_success="\e[0;32m" color_success=$'\E'"[0;32m"
color_reset="\e[00m" color_reset=$'\E'"[00m"
else else
color_failed="" color_failed=""
color_success="" color_success=""
@ -1460,9 +1460,9 @@ function make()
fi fi
echo echo
if [ $ret -eq 0 ] ; then if [ $ret -eq 0 ] ; then
echo -n -e "${color_success}#### make completed successfully " echo -n "${color_success}#### make completed successfully "
else else
echo -n -e "${color_failed}#### make failed to build some targets " echo -n "${color_failed}#### make failed to build some targets "
fi fi
if [ $hours -gt 0 ] ; then if [ $hours -gt 0 ] ; then
printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs
@ -1471,7 +1471,7 @@ function make()
elif [ $secs -gt 0 ] ; then elif [ $secs -gt 0 ] ; then
printf "(%s seconds)" $secs printf "(%s seconds)" $secs
fi fi
echo -e " ####${color_reset}" echo " ####${color_reset}"
echo echo
return $ret return $ret
} }