From cf5941cd950cea16c413704ba21f289742434d2e Mon Sep 17 00:00:00 2001 From: bill-auger Date: Mon, 11 Feb 2019 03:14:19 -0500 Subject: bugfix/refactor chech.sh --- check.sh | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'check.sh') diff --git a/check.sh b/check.sh index 9e84cc7..bc198f7 100755 --- a/check.sh +++ b/check.sh @@ -9,28 +9,36 @@ readonly CSV_CHAR=':' readonly SEP_CHAR='!' +exit_status=0 -# Verify the blacklist entries are correctly formatted. -bad_entries="$(egrep -v '^[^:]*:[^:]*:(sv|debian|parabola|fsf|fedora)?:[^:]*:.*$' *.txt)" +# Verify the blacklist entries are correctly formatted. -if [[ ! -z "$bad_entries" ]]; then - printf "Incorrectly formatted entries:\n\n%s\n" "$bad_entries" >&2 - exit 1 +printf "checking for entries with syntax errors: ... " >&2 +invalid="$(egrep -v '^[^:]*:[^:]*:(sv|debian|parabola|fsf|fedora)?:[^:]*:.*$' *.txt)" +if [[ -z "$invalid" ]] +then printf "OK\n" >&2 +else printf "\n[Incorrectly formatted entries]:\n\n%s\n\n" "$invalid" >&2 + exit_status=1 fi -unsourced="$(egrep '^[^:]*:[^:]*::[^:]*:.*$' *.txt)" -if [[ ! -z "$unsourced" ]]; then - printf "[citation needed]:\n\n%s\n" "$unsourced" >&2 - exit 1 +printf "checking for entries without reference to detailed description: ... " >&2 +unsourced="$(egrep '^[^:]*:[^:]*::[^:]*:.*$' *.txt)" +if [[ -z "$unsourced" ]] +then printf "OK\n" >&2 +else printf "\n[citation needed]:\n\n%s\n\n" "$unsourced" >&2 + exit_status=1 fi -# TODO: this could be removed someday - see note in 'sort-entries' script +# 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 unsortable="$(grep ${SEP_CHAR} *.txt)" - -if [[ ! -z "$unsortable" ]]; then - printf "[non-uniform sorting] entry contains '$s' char" ${SEP_CHAR} >&2 - exit 1 +if [[ -z "$unsortable" ]] +then printf "OK\n" >&2 +else printf "\n[Entries contain '%s' char]:\n\n%s\n\n" "${SEP_CHAR}" "$unsortable" >&2 + exit_status=1 fi + +exit $exit_status -- cgit v1.2.2