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 @@ -1849,6 +1848,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