Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Boelen <michael.boelen@cisofy.com>2016-07-18 20:58:32 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2016-07-18 20:58:32 +0300
commit7f25a1f00e10f606c008e442a6c5574ea2e82a66 (patch)
tree2a414a00fe31a37d6d9c6e19b2f487c2872b055b /include
parentd5890b8a753df6985878d4fae69c9fa5e164a2b8 (diff)
Remove colors properly with one function (contribution: Mike Slifcak at Pindrop
Diffstat (limited to 'include')
-rw-r--r--include/functions35
-rw-r--r--include/helper_show4
-rw-r--r--include/parameters6
3 files changed, 38 insertions, 7 deletions
diff --git a/include/functions b/include/functions
index ccdc9180..65a91aba 100644
--- a/include/functions
+++ b/include/functions
@@ -67,6 +67,7 @@
# PortIsListening Check if machine is listening on specified protocol and port
# Progress Show progress on screen
# RandomString Show a random string
+# RemoveColors Reset all colors
# RemovePIDFile Remove PID file
# RemoveTempFiles Remove temporary files
# Report Add string of data to report file
@@ -444,8 +445,6 @@
}
-
-
################################################################################
# Name : Display()
# Description : Show text on screen, with markup
@@ -1850,6 +1849,38 @@
################################################################################
+ # Name : RemoveColors()
+ # RemoveColors Clear color settings for --no-colors (see include/consts)
+ ################################################################################
+
+ RemoveColors() {
+ COLORS=0 # disable most color selections
+ NORMAL=""
+ WARNING=""
+ SECTION=""
+ NOTICE=""
+ OK=""
+ BAD=
+
+ # Normal color names
+ CYAN=""
+ BLUE=""
+ BROWN=""
+ DARKGRAY=""
+ GRAY=""
+ GREEN=""
+ LIGHTBLUE=""
+ MAGENTA=""
+ PURPLE=""
+ RED=""
+ YELLOW=""
+ WHITE=""
+
+ # Colors with background
+ BG_BLUE=
+ }
+
+ ################################################################################
# Name : RemovePIDFile()
################################################################################
diff --git a/include/helper_show b/include/helper_show
index 2a9ef418..9338a4ed 100644
--- a/include/helper_show
+++ b/include/helper_show
@@ -200,7 +200,7 @@ if [ $# -gt 0 ]; then
case $1 in
"--brief" | "--br") BRIEF_OUTPUT=1 ;;
"--configured-only" | "--co") CONFIGURED_ONLY_OUTPUT=1 ;;
- "--nocolors" | "--nc") COLORED_OUTPUT=0 ;;
+ "--nocolors" | "--no-colors" | "--nc") COLORED_OUTPUT=0; COLORS=0 ;;
*)
${ECHOCMD} "${RED}Error${NORMAL}: Invalid argument provided to 'lynis show settings'\n\n"
${ECHOCMD} "Suggestions:"
@@ -209,7 +209,7 @@ if [ $# -gt 0 ]; then
;;
esac
done
- if [ ${COLORED_OUTPUT} -eq 0 ]; then BLUE=""; CYAN=""; GRAY=""; WHITE=""; fi
+ if [ ${COLORED_OUTPUT} -eq 0 ]; then RemoveColors; fi
# Sort all settings and display them
SETTINGS=$(sort ${SETTINGS_FILE} | sed 's/ /:space:/g')
for LINE in ${SETTINGS}; do
diff --git a/include/parameters b/include/parameters
index e6b27b52..f2840014 100644
--- a/include/parameters
+++ b/include/parameters
@@ -162,8 +162,8 @@
# Cronjob support
--cronjob | --cron)
CRONJOB=1
- CHECK=1; QUICKMODE=1; NEVERBREAK=1 # Use some defaults (-c, -Q, no colors)
- NORMAL=""; WARNING=""; SECTION=""; NOTICE=""; OK=""; BAD=""; CYAN=""; MAGENTA=""; PURPLE=""; YELLOW=""; WHITE=""; GREEN=""; RED="" # Remove colors
+ CHECK=1; QUICKMODE=1; COLORS=0; NEVERBREAK=1 # Use some defaults (-c, -Q, no colors)
+ RemoveColors
;;
# Perform tests with additional debugging information on screen
@@ -225,7 +225,7 @@
# Don't use colors
--no-colors | --nocolors)
COLORS=0
- BG_BLUE=""; NORMAL=""; WARNING=""; SECTION=""; NOTICE=""; OK=""; BAD=""; BLUE=""; CYAN=""; LIGHTBLUE=""; MAGENTA=""; PURPLE=""; YELLOW=""; WHITE=""; GREEN=""; RED=""
+ RemoveColors
;;
# Disable logging