From 94adb3eca92373e358bdb0d094513ebd19fecc47 Mon Sep 17 00:00:00 2001
From: Ben Allen <ballen@sans.org>
Date: Wed, 17 Feb 2016 20:21:08 -0600
Subject: [PATCH] add option -m to disable colors in output

Signed-off-by: Mr. Secure <ben.github@mrsecure.org>
---
 docker-bench-security.sh |  9 +++++++--
 textout_lib.sh           | 26 ++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 textout_lib.sh

diff --git a/docker-bench-security.sh b/docker-bench-security.sh
index f7c0a1d..cd19081 100755
--- a/docker-bench-security.sh
+++ b/docker-bench-security.sh
@@ -11,7 +11,6 @@
 # ------------------------------------------------------------------------------
 
 # Load dependencies
-. ./output_lib.sh
 . ./helper_lib.sh
 
 # Setup the paths
@@ -38,6 +37,7 @@ usage () {
   usage: ${myname} [options]
 
   -h           optional  Print this help message
+  -m           optional  Disable colors in output
   -l PATH      optional  Log output in PATH
 EOF
 }
@@ -45,15 +45,20 @@ EOF
 # Get the flags
 # If you add an option here, please
 # remember to update usage() above.
-while getopts hl: args
+outputlib='output_lib.sh'
+
+while getopts hml: args
 do
   case $args in
   h) usage; exit 0 ;;
+  m) outputlib='textout_lib.sh' ;;
   l) logger="$OPTARG" ;;
   *) usage; exit 1 ;;
   esac
 done
 
+. ./${outputlib}
+
 if [ -z "$logger" ]; then
   logger="${myname}.log"
 fi
diff --git a/textout_lib.sh b/textout_lib.sh
new file mode 100644
index 0000000..45a8836
--- /dev/null
+++ b/textout_lib.sh
@@ -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"
+}