Added new function ContainsString to search for the needle in the haystack

This commit is contained in:
mboelen 2016-04-13 11:48:02 +02:00
parent 0288c6df34
commit 991083c13f
1 changed files with 16 additions and 0 deletions

View File

@ -30,6 +30,7 @@
# CheckUpdates Determine if a new version of Lynis is available
# CreateTempFile Create a temporary file
# counttests Count number of performed tests
# ContainsString Find the needle (string) in the haystack (another string)
# Debug Display additional information on the screen (not suited for cronjob)
# DigitsOnly Return only the digits from a string
# DirectoryExists Check if a directory exists on the disk
@ -155,6 +156,21 @@
fi
}
################################################################################
# Name : ContainsString()
# Description : Search a specific string (or regular expression) in another
# Returns : (0 - True, 1 - False)
################################################################################
ContainsString() {
if [ $# -ne 2 ]; then ReportException "ContainsString" "Incorrect number of arguments for ContainsStrings function"; fi
RETVAL=1
local FIND=`echo "$2" | egrep "$1"`
if [ ! "${FIND}" = "" ]; then RETVAL=0; fi
return $RETVAL
}
################################################################################
# Name : TestCase_Equal()
# Description : Test case for checking if value whether value is equal to value