mirror of
https://github.com/ovh/debian-cis.git
synced 2024-12-24 15:05:24 +01:00
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:
commit
78569b5583
13
lib/utils.sh
13
lib/utils.sh
@ -100,11 +100,16 @@ does_pattern_exist_in_file() {
|
|||||||
local PATTERN=$2
|
local PATTERN=$2
|
||||||
|
|
||||||
debug "Checking if $PATTERN is present in $FILE"
|
debug "Checking if $PATTERN is present in $FILE"
|
||||||
debug "grep -qE -- '$PATTERN' $FILE"
|
if [ -r "$FILE" ] ; then
|
||||||
if $(grep -qE -- "$PATTERN" $FILE); then
|
debug "grep -qE -- '$PATTERN' $FILE"
|
||||||
FNRET=0
|
if $(grep -qE -- "$PATTERN" $FILE); then
|
||||||
|
FNRET=0
|
||||||
|
else
|
||||||
|
FNRET=1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
FNRET=1
|
debug "File $FILE is not readable!"
|
||||||
|
FNRET=2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user