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 <fff@bareminimum.eu>
Reviewed-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
Johannes Kimmel 2024-01-19 22:56:53 +01:00 committed by Fabian Bläse
parent de15c71c53
commit 5a6a0a39d7

View File

@ -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