From 5a6a0a39d754400b8f754a106691134183cc18c9 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Fabian Bläse --- buildscript | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/buildscript b/buildscript index 66de49e0..c61c7a4c 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