From 3100c72c1386ce6c3ce2d405df431bbf3809ace8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Forslund?= Date: Thu, 18 Jul 2019 14:00:41 +0200 Subject: [PATCH] Check for terminals ability to display colours On serial connections, with weird terminal emulators or when run interactively the terminal may not support colours this would cause the dev_setup to be aborted. This adds a simple check for terminal colors. "-1" for no color support was empirically established. --- dev_setup.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dev_setup.sh b/dev_setup.sh index 306e38cf19..fef1faaa56 100755 --- a/dev_setup.sh +++ b/dev_setup.sh @@ -115,13 +115,16 @@ function get_YN() { done } +# If tput is available and can handle multiple colors if found_exe tput ; then - GREEN=$(tput setaf 2) - BLUE=$(tput setaf 4) - CYAN=$(tput setaf 6) - YELLOW=$(tput setaf 3) - RESET=$(tput sgr0) - HIGHLIGHT=$YELLOW + if [[ $(tput colors) != "-1" ]]; then + GREEN=$(tput setaf 2) + BLUE=$(tput setaf 4) + CYAN=$(tput setaf 6) + YELLOW=$(tput setaf 3) + RESET=$(tput sgr0) + HIGHLIGHT=$YELLOW + fi fi # Run a setup wizard the very first time that guides the user through some decisions