Fix 5.4.5 pattern search (#108)

fix #107
This commit is contained in:
Thibault Ayanides 2021-08-09 10:49:56 +02:00 committed by GitHub
parent 334d743125
commit 9a2e3a0e0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,7 +31,7 @@ audit() {
debug "$FILE_SEARCHED is a directory" debug "$FILE_SEARCHED is a directory"
# shellcheck disable=2044 # shellcheck disable=2044
for file_in_dir in $(find "$FILE_SEARCHED" -type f); do for file_in_dir in $(find "$FILE_SEARCHED" -type f); do
does_pattern_exist_in_file "$file_in_dir" "^$PATTERN" does_pattern_exist_in_file "$file_in_dir" "$PATTERN"
if [ "$FNRET" != 0 ]; then if [ "$FNRET" != 0 ]; then
debug "$PATTERN is not present in $FILE_SEARCHED/$file_in_dir" debug "$PATTERN is not present in $FILE_SEARCHED/$file_in_dir"
else else
@ -41,7 +41,7 @@ audit() {
fi fi
done done
else else
does_pattern_exist_in_file "$FILE_SEARCHED" "^$PATTERN" does_pattern_exist_in_file "$FILE_SEARCHED" "$PATTERN"
if [ "$FNRET" != 0 ]; then if [ "$FNRET" != 0 ]; then
debug "$PATTERN is not present in $FILE_SEARCHED" debug "$PATTERN is not present in $FILE_SEARCHED"
else else
@ -64,7 +64,7 @@ apply() {
debug "$FILE_SEARCHED is a directory" debug "$FILE_SEARCHED is a directory"
# shellcheck disable=2044 # shellcheck disable=2044
for file_in_dir in $(find "$FILE_SEARCHED" -type f); do for file_in_dir in $(find "$FILE_SEARCHED" -type f); do
does_pattern_exist_in_file "$FILE_SEARCHED/$file_in_dir" "^$PATTERN" does_pattern_exist_in_file "$FILE_SEARCHED/$file_in_dir" "$PATTERN"
if [ "$FNRET" != 0 ]; then if [ "$FNRET" != 0 ]; then
debug "$PATTERN is not present in $FILE_SEARCHED/$file_in_dir" debug "$PATTERN is not present in $FILE_SEARCHED/$file_in_dir"
else else
@ -74,7 +74,7 @@ apply() {
fi fi
done done
else else
does_pattern_exist_in_file "$FILE_SEARCHED" "^$PATTERN" does_pattern_exist_in_file "$FILE_SEARCHED" "$PATTERN"
if [ "$FNRET" != 0 ]; then if [ "$FNRET" != 0 ]; then
debug "$PATTERN is not present in $FILE_SEARCHED" debug "$PATTERN is not present in $FILE_SEARCHED"
else else
@ -87,8 +87,7 @@ apply() {
warn "$PATTERN is not present in $FILES_TO_SEARCH" warn "$PATTERN is not present in $FILES_TO_SEARCH"
touch "$FILE" touch "$FILE"
chmod 644 "$FILE" chmod 644 "$FILE"
add_end_of_file "$FILE" "$PATTERN$VALUE" add_end_of_file "$FILE" "readonly $PATTERN$VALUE"
add_end_of_file "$FILE" "readonly TMOUT"
add_end_of_file "$FILE" "export TMOUT" add_end_of_file "$FILE" "export TMOUT"
else else
ok "$PATTERN is present in $FILES_TO_SEARCH" ok "$PATTERN is present in $FILES_TO_SEARCH"