mirror of
https://github.com/ovh/debian-cis.git
synced 2024-11-23 05:55:38 +01:00
handle ENOENT properly in does_pattern_exist_in_file\(\)
This commit is contained in:
parent
438b047d0e
commit
f94dff5f3f
@ -100,12 +100,17 @@ 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"
|
||||||
|
if [ -r "$FILE" ] ; then
|
||||||
debug "grep -qE -- '$PATTERN' $FILE"
|
debug "grep -qE -- '$PATTERN' $FILE"
|
||||||
if $(grep -qE -- "$PATTERN" $FILE); then
|
if $(grep -qE -- "$PATTERN" $FILE); then
|
||||||
FNRET=0
|
FNRET=0
|
||||||
else
|
else
|
||||||
FNRET=1
|
FNRET=1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
debug "File $FILE is not readable!"
|
||||||
|
FNRET=2
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user