Use variable to store color for script output

This commit is contained in:
clsty
2025-10-01 21:40:06 +08:00
parent 87c031b825
commit 9f711c20e0
9 changed files with 87 additions and 73 deletions
+4 -2
View File
@@ -1,13 +1,15 @@
#!/usr/bin/env bash
#
# This script is for quickly generate helpful info
#
# It should be as independent as possible and should not source other files unless it has to
COLOR_RED='\e[31m'
COLOR_RESET='\e[00m'
cd "$(dirname "$0")";export base="$(pwd)"
output_file=diagnose.result;rm $output_file
export LANG=C;export LC_ALL=C
case $(whoami) in
root)echo -e "\e[31m[$0]: This script is NOT to be executed with sudo or as root. Aborting...\e[0m";exit 1;;
root)echo -e "${COLOR_RED}[$0]: This script is NOT to be executed with sudo or as root. Aborting...${COLOR_RESET}";exit 1;;
esac