home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / maint / sysck < prev   
Text File  |  1994-09-08  |  2KB  |  45 lines

  1. #! /bin/sh
  2. # sysck file... - check sys file for B-Newsisms and other errors
  3. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  4. . ${NEWSCONFIG-/etc/news/bin/config}
  5. PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH:/usr/local/bin ; export PATH
  6. awk=gawk    # gawk is preferred as it can handle arbitrarily-long lines
  7.  
  8. # first, a pass over the raw input
  9. $awk '
  10. /^[     ][     ]*$/ { print FILENAME ", line " NR ": non-empty blank line" }
  11.  
  12. # start of possibly-continued comment
  13. /^#.*\\$/    { commcont = 1; start = NR; next }
  14. # uncommented continuation line - fix/complain
  15. /^[^#]/ && commcont > 0 && start > 0 {
  16.     print FILENAME ", line " start ": uncommented continuations follow"
  17.     start = 0        # no more complaints
  18. }
  19. /^#/ || commcont == 0    {  }    # commented or non-continuation line - ok
  20. /^[\t ]/ && contin == 0 {
  21.     print FILENAME " line " NR " begins with whitespace;"
  22.     print "probably previous line lacks trailing backslash"
  23. }
  24. /.*\\$/        { contin = 1; next }        # continued line
  25. {
  26.     contin = 0; commcont = 0    # uncontinued line
  27. }
  28. ' $*
  29.  
  30. # then a pass over the canonicalised input
  31. $awk -f $NEWSBIN/canonsys.awk $* | $awk -F: '
  32. $3 ~ /A/ { print "unsupported A flag in " $1 " entry; see relay/anews" }
  33. $3 ~ /H/ { print "unsupported H flag in " $1 " entry; incredible!" }
  34. $3 ~ /I/ && $2 !~ /ihave/ {
  35.     if ($3 ~ /F/)
  36.         print "FI flags in " $1 " entry; rewrite as n flag"
  37.     else if ($1 !~ /\.wehave(\/.*)?$/)
  38.         print "ihave/sendme specified in " $1 " entry; see doc/ihave"
  39. }
  40. $3 ~ /N/ { print "unsupported N flag in " $1 " entry; see I flag" }
  41. $3 ~ /M/ { print "unsupported M flag in " $1 " entry; see newsbatch(8)" }
  42. $3 ~ /O/ { print "unsupported O flag in " $1 " entry; see newsbatch(8)" }
  43. $3 ~ /S/ { print "unsupported S flag in " $1 " entry for command " $4 "; omit?" }
  44. '
  45.