Add return value to SearchItem() function

This commit is contained in:
Michael Boelen 2016-08-11 18:46:17 +02:00
parent ed4dd3bf60
commit bba7cfe200

View File

@ -2209,11 +2209,12 @@
# Description : Search if a specific string exists in in a file # Description : Search if a specific string exists in in a file
# #
# Input : $1 = search key (string), $2 = file (string) # Input : $1 = search key (string), $2 = file (string)
# Returns : <nothing> # Returns : True (0) or False (1)
################################################################################ ################################################################################
SearchItem() { SearchItem() {
ITEM_FOUND=0 ITEM_FOUND=0
RETVAL=1
if [ $# -eq 2 ]; then if [ $# -eq 2 ]; then
# Don't search in /dev/null, it's too empty there # Don't search in /dev/null, it's too empty there
if [ -f $2 ]; then if [ -f $2 ]; then
@ -2224,8 +2225,10 @@
ITEM_FOUND=1 ITEM_FOUND=1
LogText "Result: found string" LogText "Result: found string"
LogText "Full string: ${FIND}" LogText "Full string: ${FIND}"
RETVAL=0
else else
LogText "Result: search string NOT found" LogText "Result: search string NOT found"
RETVAL=1
fi fi
else else
LogText "Skipping search, file does not exist" LogText "Skipping search, file does not exist"
@ -2234,6 +2237,7 @@
else else
ReportException ${TEST_NO} "Error in function call to CheckItem" ReportException ${TEST_NO} "Error in function call to CheckItem"
fi fi
return ${RETVAL}
} }