check.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # Copyright (C) 2014 Michał Masłowski <mtjm@mtjm.eu>
  3. #
  4. # Copying and distribution of this file, with or without modification,
  5. # are permitted in any medium without royalty provided the copyright
  6. # notice and this notice are preserved. This file is offered as-is,
  7. # without any warranty.
  8. readonly CSV_CHAR=':'
  9. readonly SEP_CHAR='!'
  10. exit_status=0
  11. # Verify the blacklist entries are correctly formatted.
  12. printf "checking for entries with syntax errors: ... " >&2
  13. invalid="$(egrep -v '^[^:]*:[^:]*:(sv|debian|parabola|fsf|fedora)?:[^:]*:.*$' *.txt)"
  14. if [[ -z "$invalid" ]]
  15. then printf "OK\n" >&2
  16. else printf "\n[Incorrectly formatted entries]:\n\n%s\n\n" "$invalid" >&2
  17. exit_status=1
  18. fi
  19. printf "checking for entries without reference to detailed description: ... " >&2
  20. unsourced="$(egrep '^[^:]*:[^:]*::[^:]*:.*$' *.txt)"
  21. if [[ -z "$unsourced" ]]
  22. then printf "OK\n" >&2
  23. else printf "\n[citation needed]:\n\n%s\n\n" "$unsourced" >&2
  24. exit_status=1
  25. fi
  26. # TODO: this check could be removed someday - see note in 'sort-entries' script
  27. printf "checking for entries that the 'sort-entries' script would mutate: ... " >&2
  28. unsortable="$(grep ${SEP_CHAR} *.txt)"
  29. if [[ -z "$unsortable" ]]
  30. then printf "OK\n" >&2
  31. else printf "\n[Entries contain '%s' char]:\n\n%s\n\n" "${SEP_CHAR}" "$unsortable" >&2
  32. exit_status=1
  33. fi
  34. exit $exit_status