Commit ff81da4f authored by Rishi's avatar Rishi Committed by Brad Davidson

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: 's avatarRishikesh Nair <alienware505@gmail.com> (cherry picked from commit ff7cfa22) Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com>
parent 8202e930
......@@ -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 "$@"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment