diff --git a/include/functions b/include/functions index 8ec84597..fbfacbd6 100644 --- a/include/functions +++ b/include/functions @@ -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