mirror of https://github.com/k3s-io/k3s.git
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>pull/9660/head
parent
59c724f7a6
commit
ff7cfa2235
|
@ -21,6 +21,9 @@ binDir=$(dirname "$0")
|
||||||
configFormat=gz
|
configFormat=gz
|
||||||
isError=0
|
isError=0
|
||||||
|
|
||||||
|
# RAW_OUTPUT=1 disables colored outputs
|
||||||
|
RAW_OUTPUT=${RAW_OUTPUT:-0}
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
CONFIG="$1"
|
CONFIG="$1"
|
||||||
fi
|
fi
|
||||||
|
@ -81,6 +84,11 @@ color() {
|
||||||
printf '\033['"$codes"'m'
|
printf '\033['"$codes"'m'
|
||||||
}
|
}
|
||||||
wrap_color() {
|
wrap_color() {
|
||||||
|
if [ $RAW_OUTPUT -eq 1 ]; then
|
||||||
|
echo -n "$1"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
text="$1"
|
text="$1"
|
||||||
shift
|
shift
|
||||||
color "$@"
|
color "$@"
|
||||||
|
|
Loading…
Reference in New Issue