Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d95c7f70 authored by Greg Hackmann's avatar Greg Hackmann
Browse files

Consult tput about color control sequence support



Blocking these sequences on Darwin has false positives (Terminal.app)
and false negatives (Eclipse CDT on Linux).  Instead let's ask the
terminal what it supports.

Change-Id: I907942925a8b30abc1ea920f077b5fc3af815ba4
Signed-off-by: default avatarGreg Hackmann <ghackmann@google.com>
parent 7fc55db3
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -1651,19 +1651,21 @@ function make()
    local hours=$(($tdiff / 3600 ))
    local mins=$((($tdiff % 3600) / 60))
    local secs=$(($tdiff % 60))
    echo
    if [ $ret -eq 0 ] ; then
        if [ $(uname) != "Darwin" ]; then
            echo -n -e "\e[0;32m#### make completed successfully "
    local ncolors=$(tput colors 2>/dev/null)
    if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
        color_failed="\e[0;31m"
        color_success="\e[0;32m"
        color_reset="\e[00m"
    else
            echo -n -e "#### make completed successfully "
        color_failed=""
        color_success=""
        color_reset=""
    fi
    echo
    if [ $ret -eq 0 ] ; then
        echo -n -e "${color_success}#### make completed successfully "
    else
        if [ $(uname) != "Darwin" ]; then
            echo -n -e "\e[0;31m#### make failed to build some targets "
        else
            echo -n -e "#### make failed to build some targets "
        fi
        echo -n -e "${color_failed}#### make failed to build some targets "
    fi
    if [ $hours -gt 0 ] ; then
        printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs
@@ -1672,9 +1674,7 @@ function make()
    elif [ $secs -gt 0 ] ; then
        printf "(%s seconds)" $secs
    fi
    if [ $(uname) != "Darwin" ]; then
        echo -e " ####\e[00m"
    fi
    echo -e " ####${color_reset}"
    echo
    return $ret
}