mirror of
https://github.com/ovh/debian-cis.git
synced 2024-11-22 05:27:01 +01:00
handle ENOENT properly in does_pattern_exist_in_file\(\)
This commit is contained in:
parent
233d1245fc
commit
3e0187094a
13
lib/utils.sh
13
lib/utils.sh
@ -100,11 +100,16 @@ does_pattern_exist_in_file() {
|
||||
local PATTERN=$2
|
||||
|
||||
debug "Checking if $PATTERN is present in $FILE"
|
||||
debug "grep -qE -- '$PATTERN' $FILE"
|
||||
if $(grep -qE -- "$PATTERN" $FILE); then
|
||||
FNRET=0
|
||||
if [ -r "$FILE" ] ; then
|
||||
debug "grep -qE -- '$PATTERN' $FILE"
|
||||
if $(grep -qE -- "$PATTERN" $FILE); then
|
||||
FNRET=0
|
||||
else
|
||||
FNRET=1
|
||||
fi
|
||||
else
|
||||
FNRET=1
|
||||
debug "File $FILE is not readable!"
|
||||
FNRET=2
|
||||
fi
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user