summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2019-10-07 03:32:52 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2019-10-07 03:36:31 -0400
commitb03091d1190b10ed45f0ba432de176759f08e62b (patch)
tree91c65ef702e7e2e0a7346bcd09f764f93c5a4d9d
parent361f51cd3d215f63e2f7fd537fc0a536abdb6b64 (diff)
add entry counts to check.sh
-rwxr-xr-xcheck.sh32
1 files changed, 17 insertions, 15 deletions
diff --git a/check.sh b/check.sh
index bc198f7..48a8f8a 100755
--- a/check.sh
+++ b/check.sh
@@ -6,38 +6,40 @@
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
+# blacklist::check.sh Verify the blacklist entries are correctly formatted.
+
+readonly REF_REGEX='^[^:]*:[^:]*::[^:]*:.*$'
+readonly SYNTAX_REGEX='^[^:]*:[^:]*:(sv|debian|parabola|fsf|fedora)?:[^:]*:.*$'
readonly CSV_CHAR=':'
readonly SEP_CHAR='!'
exit_status=0
-
-# Verify the blacklist entries are correctly formatted.
-
-printf "checking for entries with syntax errors: ... " >&2
-invalid="$(egrep -v '^[^:]*:[^:]*:(sv|debian|parabola|fsf|fedora)?:[^:]*:.*$' *.txt)"
-if [[ -z "$invalid" ]]
+printf "\n\nchecking for entries without reference to detailed description: ... " >&2
+unsourced="$(egrep ${REF_REGEX} *.txt)"
+if [[ -z "$unsourced" ]]
then printf "OK\n" >&2
-else printf "\n[Incorrectly formatted entries]:\n\n%s\n\n" "$invalid" >&2
+else printf "\n[citation needed]:\n\n%s\n\n" "$unsourced" >&2
+ echo "entries needing citation: $(grep -c '\n' <<<${unsourced})"
exit_status=1
fi
-
-printf "checking for entries without reference to detailed description: ... " >&2
-unsourced="$(egrep '^[^:]*:[^:]*::[^:]*:.*$' *.txt)"
-if [[ -z "$unsourced" ]]
+printf "\n\nchecking for entries with syntax errors: ... " >&2
+invalid="$(egrep -v ${SYNTAX_REGEX} *.txt)"
+if [[ -z "$invalid" ]]
then printf "OK\n" >&2
-else printf "\n[citation needed]:\n\n%s\n\n" "$unsourced" >&2
+else printf "\n[Incorrectly formatted entries]:\n\n%s\n\n" "$invalid" >&2
+ echo "entries improperly formatted: $(grep -c '\n' <<<${invalid})"
exit_status=1
fi
-
# TODO: this check could be removed someday - see note in 'sort-entries' script
-printf "checking for entries that the 'sort-entries' script would mutate: ... " >&2
+printf "\n\nchecking for entries that the 'sort-entries' script would mutate: ... " >&2
unsortable="$(grep ${SEP_CHAR} *.txt)"
if [[ -z "$unsortable" ]]
then printf "OK\n" >&2
-else printf "\n[Entries contain '%s' char]:\n\n%s\n\n" "${SEP_CHAR}" "$unsortable" >&2
+else printf "\n[Entries containing '%s' char]:\n\n%s\n\n" "${SEP_CHAR}" "$unsortable" >&2
+ echo "entries containing $SEP_CHAR('${SEP_CHAR}'): $(grep -c '\n' <<<${unsortable})"
exit_status=1
fi