extract_utils: Introduce colored echo helper function
Change-Id: I25db42087232c646525f281cc0a1404fe60d1c8c
diff --git a/build/tools/extract_utils.sh b/build/tools/extract_utils.sh
index 635027f..dc80470 100755
--- a/build/tools/extract_utils.sh
+++ b/build/tools/extract_utils.sh
@@ -2072,3 +2072,24 @@
# Clean-up
rm -f "$output_list_tmp"
}
+
+function colored_echo() {
+ IFS=" "
+ local color=$1;
+ shift
+ if ! [[ $color =~ '^[0-9]$' ]] ; then
+ case $(echo $color | tr '[:upper:]' '[:lower:]') in
+ black) color=0 ;;
+ red) color=1 ;;
+ green) color=2 ;;
+ yellow) color=3 ;;
+ blue) color=4 ;;
+ magenta) color=5 ;;
+ cyan) color=6 ;;
+ white|*) color=7 ;; # white or invalid color
+ esac
+ fi
+ tput setaf $color
+ printf '%s\n' "$*"
+ tput sgr0
+}