Skip to content

Commit

Permalink
Disable color outputs using RAW_OUTPUT env var
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rishi authored and brandond committed Mar 5, 2024
1 parent 59c724f commit ff7cfa2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions contrib/util/check-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "$@"
Expand Down

0 comments on commit ff7cfa2

Please sign in to comment.