Compare commits
2 Commits
9f6182ca9f
...
a9e4013969
Author | SHA1 | Date | |
---|---|---|---|
a9e4013969 | |||
02da3cf54d |
@ -1,25 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
INPUT_RULES=$(cat input-rules)
|
||||
{
|
||||
while read -r LINE
|
||||
do
|
||||
GREP_EXPR=$( printf "%s" "$LINE" | tr ',' '|' )
|
||||
PASS_RULES=0
|
||||
# Loop through rules and find a breaking rule
|
||||
while read -r RULE
|
||||
do
|
||||
GREPC=$( printf "%s" "$LINE" | grep -c "$RULE" )
|
||||
if [[ $GREPC -ne 1 ]]
|
||||
then
|
||||
#printf "%s rule violated for %s \n" "$RULE" "$LINE"
|
||||
PASS_RULES=1
|
||||
break
|
||||
fi
|
||||
# Filter rules that only has included pages
|
||||
done <<< "$( < input-rules grep -E "($GREP_EXPR)\\|($GREP_EXPR)" | sed 's/|/,.*/')"
|
||||
|
||||
BEEG_AWK_EXPR=$(
|
||||
printf "%s" "$INPUT_RULES" |
|
||||
grep -E "($GREP_EXPR)\\|($GREP_EXPR)" |
|
||||
sed -E 's/(.*)\|(.*)/\1,.*\2/; s&^&/&; s&$&/&' |
|
||||
paste -s -d '@' |
|
||||
sed 's/@/ \&\& /g'
|
||||
)
|
||||
AWK_MATCH=$( printf "%s" "$LINE" | awk "$BEEG_AWK_EXPR" | wc -c )
|
||||
|
||||
# Don't process for valid lines
|
||||
[[ $PASS_RULES -eq 0 ]] && continue
|
||||
if [[ $AWK_MATCH -gt 0 ]] ; then continue; fi
|
||||
printf "%s\n" "$LINE"
|
||||
|
||||
done < input-updates
|
||||
|
Reference in New Issue
Block a user