setup_mm_packages.sh: handle weird terminals 67/13667/1
authorMartin Kelly <mkelly@xevo.com>
Wed, 31 Jan 2018 22:33:12 +0000 (14:33 -0800)
committerMartin Kelly <mkelly@xevo.com>
Tue, 27 Mar 2018 00:10:12 +0000 (17:10 -0700)
Currently, setup_mm_packages.sh fails on terminals that won't display
colors (such as my Jenkins CI setup). Tweak the code to handle this case
and display an error message instead of failing.

Change-Id: If18e16ed385af567801a56871542b4eb86f4588d
Signed-off-by: Martin Kelly <mkelly@xevo.com>
meta-agl-bsp/meta-rcar-gen3/scripts/setup_mm_packages.sh

index 242c0f0..16613bf 100644 (file)
@@ -15,10 +15,14 @@ function color {
        [[ $stdout_in_terminal == 0 ]] && return
        for k in $*; do
                case $k in
-                       bold) tput bold 2>/dev/null;;
-                       none) tput sgr0 2>/dev/null;;
-                       *) tput setaf $k 2>/dev/null;;
+                       bold) tput bold;;
+                       none) tput sgr0;;
+                       *) tput setaf $k;;
                esac
+        if [[ $? != 0 ]]; then
+            echo "tput: terminal doesn't support color settings, continuing" >&2
+            true
+        fi
        done
 }
 color_green=$(color bold 2)