From 2f07fa1d87a612bac783197eefb9ce1bb66bd223 Mon Sep 17 00:00:00 2001 From: mboelen <michael@cisofy.com> Date: Mon, 25 Apr 2016 11:10:23 +0200 Subject: [PATCH] Allow show-warnings-only and --(show-)warnings-only option --- include/consts | 1 + include/functions | 12 +++++++----- include/parameters | 5 +++++ include/profiles | 7 +++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/consts b/include/consts index 47245bb1..f7fa3735 100644 --- a/include/consts +++ b/include/consts @@ -159,6 +159,7 @@ unset LANG SHOW_PROGRAM_DETAILS=1 SHOW_REPORT=1 SHOW_SETTINGS_FILE=0 + SHOW_WARNINGS_ONLY=0 SKIP_TESTS="" SKIPPED_TESTS_ROOTONLY="" SSHKEYSCANBINARY="" diff --git a/include/functions b/include/functions index 5a1030fe..2ce81d8a 100644 --- a/include/functions +++ b/include/functions @@ -440,8 +440,7 @@ # Returns : Nothing ################################################################################ - Display() - { + Display() { INDENT=0; TEXT=""; RESULT=""; COLOR=""; SPACES=0; SHOWDEBUG=0 while [ $# -ge 1 ]; do case $1 in @@ -489,8 +488,11 @@ fi if [ ! "${TEXT}" = "" ]; then - # Show warnings always, and other messages if no quiet is being used - if [ ${QUIET} -eq 0 -o "${RESULT}" = "WARNING" ]; then + local SHOW=0 + if [ ${QUIET} -eq 0 ]; then SHOW=1; fi + if [ "${RESULT}" = "WARNING" -a ${SHOW_WARNINGS_ONLY} -eq 1 ]; then SHOW=1; fi + + if [ ${SHOW} -eq 1 ]; then # Display (counting with -m instead of -c, to support language locale) LINESIZE=`echo "${TEXT}" | wc -m | tr -d ' '` if [ ${SHOWDEBUG} -eq 1 ]; then DEBUGTEXT=" [${PURPLE}DEBUG${NORMAL}]"; else DEBUGTEXT=""; fi @@ -504,7 +506,7 @@ fi fi fi - } + } ################################################################################ diff --git a/include/parameters b/include/parameters index 689f4564..5bd07304 100644 --- a/include/parameters +++ b/include/parameters @@ -303,6 +303,11 @@ fi ;; + # Warnings + --warnings-only | --show-warnings-only) + SHOW_WARNINGS_ONLY=1 + ;; + # Drop out when using wrong option(s) *) # Wrong option used, we bail out later diff --git a/include/profiles b/include/profiles index 7d076d9c..4af35974 100644 --- a/include/profiles +++ b/include/profiles @@ -175,6 +175,13 @@ SHOW_TOOL_TIPS="${VALUE}" ;; + # Show warnings only + show-warnings-only) + SHOW_WARNINGS_ONLY=1 + FIND=`echo "${VALUE}" | egrep "^(1|yes)"` && SHOW_WARNINGS_ONLY=1 + Debug "Show warnings only set to ${SHOW_WARNINGS_ONLY}" + ;; + # Which tests to skip (skip-test=ABCD-1234 or skip-test=ABCD-1234:subtest) skip-test) SKIP_TESTS="${SKIP_TESTS} ${VALUE}"