From 6860eee843c4bdbc3c9f0d4eac4cb6815ca668d1 Mon Sep 17 00:00:00 2001 From: Johannes Kimmel Date: Fri, 19 Jan 2024 22:56:53 +0100 Subject: [PATCH] buildscript: add color to the root warning Use color output when the `tput` command is available. `tput` handles terminal-dependant capabilities, so the script should remain portable. Signed-off-by: Johannes Kimmel --- buildscript | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/buildscript b/buildscript index 422008d..06d9597 100755 --- a/buildscript +++ b/buildscript @@ -381,8 +381,12 @@ buildall() { } if [ "$(/usr/bin/id -u)" -eq 0 ]; then - echo "WARNING: buildscript is running as root" - echo "WARNING: build may fail at a later stage" + TPUT=$(command -v tput || echo ":") + textWarn="$($TPUT bold setaf 1)" # bold + red + textReset="$($TPUT sgr0)" # be a good citizen + + printf "${textWarn}WARNING: buildscript is running as root${textReset}\n" + printf "${textWarn}WARNING: build may fail at a later stage${textReset}\n" fi if [ "$1" != "selectbsp" -a "$1" != "selectvariant" ]; then