mirror of
https://github.com/docker/docker-bench-security.git
synced 2025-01-19 08:42:33 +01:00
add option -m to disable colors in output
This commit is contained in:
parent
f81bc4d6d2
commit
482397e8d7
2 changed files with 33 additions and 2 deletions
|
@ -11,7 +11,6 @@
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Load dependencies
|
# Load dependencies
|
||||||
. ./output_lib.sh
|
|
||||||
. ./helper_lib.sh
|
. ./helper_lib.sh
|
||||||
|
|
||||||
# Setup the paths
|
# Setup the paths
|
||||||
|
@ -38,6 +37,7 @@ usage () {
|
||||||
usage: ${myname} [options]
|
usage: ${myname} [options]
|
||||||
|
|
||||||
-h optional Print this help message
|
-h optional Print this help message
|
||||||
|
-m optional Disable colors in output
|
||||||
-l PATH optional Log output in PATH
|
-l PATH optional Log output in PATH
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
@ -45,15 +45,20 @@ EOF
|
||||||
# Get the flags
|
# Get the flags
|
||||||
# If you add an option here, please
|
# If you add an option here, please
|
||||||
# remember to update usage() above.
|
# remember to update usage() above.
|
||||||
while getopts hl: args
|
outputlib='output_lib.sh'
|
||||||
|
|
||||||
|
while getopts hml: args
|
||||||
do
|
do
|
||||||
case $args in
|
case $args in
|
||||||
h) usage; exit 0 ;;
|
h) usage; exit 0 ;;
|
||||||
|
m) outputlib='textout_lib.sh' ;;
|
||||||
l) logger="$OPTARG" ;;
|
l) logger="$OPTARG" ;;
|
||||||
*) usage; exit 1 ;;
|
*) usage; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
. ./${outputlib}
|
||||||
|
|
||||||
if [ -z "$logger" ]; then
|
if [ -z "$logger" ]; then
|
||||||
logger="${myname}.log"
|
logger="${myname}.log"
|
||||||
fi
|
fi
|
||||||
|
|
26
textout_lib.sh
Normal file
26
textout_lib.sh
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
bldred=''
|
||||||
|
bldgrn=''
|
||||||
|
bldblu=''
|
||||||
|
bldylw=''
|
||||||
|
txtrst=''
|
||||||
|
|
||||||
|
logit () {
|
||||||
|
printf "%b\n" "$1" | tee -a "$logger"
|
||||||
|
}
|
||||||
|
|
||||||
|
info () {
|
||||||
|
printf "%b\n" "${bldblu}[INFO]${txtrst} $1" | tee -a "$logger"
|
||||||
|
}
|
||||||
|
|
||||||
|
pass () {
|
||||||
|
printf "%b\n" "${bldgrn}[PASS]${txtrst} $1" | tee -a "$logger"
|
||||||
|
}
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
printf "%b\n" "${bldred}[WARN]${txtrst} $1" | tee -a "$logger"
|
||||||
|
}
|
||||||
|
|
||||||
|
yell () {
|
||||||
|
printf "%b\n" "${bldylw}$1${txtrst}\n"
|
||||||
|
}
|
Loading…
Reference in a new issue