Merge pull request #11 from speed47/dev/fix_does_pattern_exist_in_file

handle ENOENT properly in does_pattern_exist_in_file()
This commit is contained in:
Thibault Dewailly 2017-05-19 18:30:21 +02:00 committed by GitHub
commit 78569b5583

View File

@ -100,12 +100,17 @@ does_pattern_exist_in_file() {
local PATTERN=$2
debug "Checking if $PATTERN is present in $FILE"
if [ -r "$FILE" ] ; then
debug "grep -qE -- '$PATTERN' $FILE"
if $(grep -qE -- "$PATTERN" $FILE); then
FNRET=0
else
FNRET=1
fi
else
debug "File $FILE is not readable!"
FNRET=2
fi
}