2
0

check-qerror.sh 635 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. # This script verifies that qerror definitions and table entries are
  3. # alphabetically ordered.
  4. check_order() {
  5. errmsg=$1
  6. shift
  7. # sort -C verifies order but does not print a message. sort -c does print a
  8. # message. These options are both in POSIX.
  9. if ! "$@" | sort -C; then
  10. echo "$errmsg"
  11. "$@" | sort -c
  12. exit 1
  13. fi
  14. return 0
  15. }
  16. check_order 'Definitions in qerror.h must be in alphabetical order:' \
  17. grep '^#define QERR_' qerror.h
  18. check_order 'Entries in qerror.c:qerror_table must be in alphabetical order:' \
  19. sed -n '/^static.*qerror_table\[\]/,/^};/s/QERR_/&/gp' qerror.c