From 22f99ede81ff8f9814713744769db093b9d65035 Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Thu, 28 Jul 2016 11:06:46 +0200 Subject: [PATCH] Check for number or arguments on ReportSuggestion and ReportWarning --- include/functions | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/include/functions b/include/functions index 7faee3db..ae0f1a88 100644 --- a/include/functions +++ b/include/functions @@ -2073,12 +2073,14 @@ # * url:http://site/link # * text:Additional explanation # * - for none - if [ "$1" = "" ]; then TEST="UNKNOWN"; else TEST="$1"; fi - if [ "$2" = "" ]; then MESSAGE="UNKNOWN"; else MESSAGE="$2"; fi - if [ "$3" = "" ]; then DETAILS="-"; else DETAILS="$3"; fi - if [ "$4" = "" ]; then SOLUTION="-"; else SOLUTION="$4"; fi + if [ $# -eq 0 ]; then echo "Not enough arguments provided for function ReportSuggestion"; ExitFatal; fi + if [ $# -ge 1 ]; then TEST="$1"; else TEST="UNKNOWN"; fi + if [ $# -ge 2 ]; then MESSAGE="$2"; else MESSAGE="UNKNOWN"; fi + if [ $# -ge 3 ]; then DETAILS="$3"; else DETAILS="-"; fi + if [ $# -ge 4 ]; then SOLUTION="$4"; else SOLUTION="-"; fi + if [ $# -ge 5 ]; then echo "Too many arguments for function ReportSuggestion"; ExitFatal; fi Report "suggestion[]=${TEST}|${MESSAGE}|${DETAILS}|${SOLUTION}|" - LogText "Suggestion: ${MESSAGE} [test:$1] [details:${DETAILS}] [solution:${SOLUTION}]" + LogText "Suggestion: ${MESSAGE} [test:${TEST}] [details:${DETAILS}] [solution:${SOLUTION}]" } @@ -2092,11 +2094,11 @@ # Old style # if [ "$2" = "L" -o "$2" = "M" -o "$2" = "H" ]; then - DETAILS="$2" - MESSAGE="$3" - TEST="$1" + if [ $# -ge 1 ]; then TEST="$1"; fi + if [ $# -ge 2 ]; then DETAILS="$2"; fi + if [ $# -ge 3 ]; then DESSAGE="$3"; fi SOLUTION="-" - else + else # New style warning format: #
# @@ -2107,10 +2109,12 @@ # * url:http://site/link # * text:Additional explanation # * - for none - if [ "$1" = "" ]; then TEST="UNKNOWN"; else TEST="$1"; fi - if [ "$2" = "" ]; then MESSAGE="UNKNOWN"; else MESSAGE="$2"; fi - if [ "$3" = "" ]; then DETAILS="-"; else DETAILS="$3"; fi - if [ "$4" = "" ]; then SOLUTION="-"; else SOLUTION="$4"; fi + if [ $# -eq 0 ]; then echo "Not enough arguments provided for function ReportWarning"; ExitFatal; fi + if [ $# -ge 1 ]; then TEST="$1"; else TEST="UNKNOWN"; fi + if [ $# -ge 2 ]; then MESSAGE="$2"; else MESSAGE="UNKNOWN"; fi + if [ $# -ge 3 ]; then DETAILS="$3"; else DETAILS="-"; fi + if [ $# -ge 4 ]; then SOLUTION="$4"; else SOLUTION="-"; fi + if [ $# -ge 5 ]; then echo "Too many arguments for function ReportWarning"; ExitFatal; fi fi Report "warning[]=${TEST}|${MESSAGE}|${DETAILS}|${SOLUTION}|" LogText "Warning: ${MESSAGE} [test:${TEST}] [details:${DETAILS}] [solution:${SOLUTION}]"