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
1 changed files with 9 additions and 5 deletions

View File

@ -2209,12 +2209,13 @@
# Description : Search if a specific string exists in in a file
#
# Input : $1 = search key (string), $2 = file (string)
# Returns : <nothing>
# Returns : True (0) or False (1)
################################################################################
SearchItem() {
ITEM_FOUND=0
if [ $# -eq 2 ]; then
ITEM_FOUND=0
RETVAL=1
if [ $# -eq 2 ]; then
# Don't search in /dev/null, it's too empty there
if [ -f $2 ]; then
# Check if we can find the main type (with or without brackets)
@ -2224,16 +2225,19 @@
ITEM_FOUND=1
LogText "Result: found string"
LogText "Full string: ${FIND}"
RETVAL=0
else
LogText "Result: search string NOT found"
RETVAL=1
fi
else
LogText "Skipping search, file does not exist"
ReportException ${TEST_NO} "Test is trying to search for a string in nonexistent file"
fi
else
else
ReportException ${TEST_NO} "Error in function call to CheckItem"
fi
fi
return ${RETVAL}
}