diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2019-02-11 03:14:19 -0500 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2019-08-09 18:10:48 -0400 |
commit | 3cf8ef122a8ced76960fdc18ca7d4aff64dae217 (patch) | |
tree | f306ba107b4ef4cbfaa6291c784cc88e6edeae25 /check.sh | |
parent | cbe7c22db78c52cf6ad96831212a5f01aac5edd3 (diff) |
bugfix/refactor chech.sh
Diffstat (limited to 'check.sh')
-rwxr-xr-x | check.sh | 36 |
1 files changed, 22 insertions, 14 deletions
@@ -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 |