#!/bin/bash # Copyright (C) 2014 Michał Masłowski # # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright # notice and this notice are preserved. This file is offered as-is, # without any warranty. 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" ]] then printf "OK\n" >&2 else printf "\n[Incorrectly formatted entries]:\n\n%s\n\n" "$invalid" >&2 exit_status=1 fi 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 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 "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