Disable color outputs using RAW_OUTPUT env var

Setting this environment variable will not wrap the text in color ANSI code, so that we can print a raw output.

Signed-off-by: Rishikesh Nair <alienware505@gmail.com>
This commit is contained in:
Rishi 2024-02-06 13:15:26 +05:30 committed by Brad Davidson
parent 59c724f7a6
commit ff7cfa2235
1 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,9 @@ binDir=$(dirname "$0")
configFormat=gz
isError=0
# RAW_OUTPUT=1 disables colored outputs
RAW_OUTPUT=${RAW_OUTPUT:-0}
if [ $# -gt 0 ]; then
CONFIG="$1"
fi
@ -81,6 +84,11 @@ color() {
printf '\033['"$codes"'m'
}
wrap_color() {
if [ $RAW_OUTPUT -eq 1 ]; then
echo -n "$1"
return
fi
text="$1"
shift
color "$@"