home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LANGUAGE / ADA / LOVELACE / hspell < prev    next >
Text File  |  1996-10-02  |  1KB  |  61 lines

  1. #!/bin/sh
  2.  
  3. # HTML spell checker.
  4. # This takes a list of filenames of HTML files and checks
  5. # the spelling of each. It ignores words found in the
  6. # okayword file.
  7.  
  8. # Note - this program only works on Unix systems, since it
  9. # depends on /bin/sh, spell, and so on. Sorry.
  10.  
  11. # This also takes an option "-x filename"; the filename following
  12. # -x is eXcluded from the spellcheck.  The -x option must be given before
  13. # the actual filename, or it won't work.
  14. # Currently only one file may be excluded.
  15.  
  16. # Re-sort okayword, since it must be sorted.
  17. # It's easy to forget to re-sort that file, so let's use some
  18. # time and sort it ourselves.
  19.  
  20. sort -u okayword > okayword.srt
  21. if cmp -s okayword okayword.srt
  22. then
  23.  # Okayword was already sorted.
  24.  rm okayword.srt
  25. else
  26.  echo "File okayword had to be re-sorted."
  27.  mv okayword.srt okayword
  28. fi
  29.  
  30. /bin/rm -fr ,errs
  31.  
  32. if [ "a$1" = 'a-x' ]
  33. then
  34.   exclude=$2
  35.   shift ; shift
  36. else
  37.   exclude=""
  38. fi
  39.  
  40. for file in $*
  41. do
  42.  if [ "$file" != "$exclude" ]
  43.  then
  44.   # sed -e 's/<[^>]*>//g' -e 's/&[a-z][a-z]*;//' $file | spell +okayword > ,temp
  45.   rmhtml $file | spell +okayword > ,temp
  46.   if [ -s ,temp ]
  47.   then
  48.    # We found some errors, add them to ,errs
  49.    sed -e "s/^/${file}:/" ,temp >> ,errs
  50.   fi
  51.  fi
  52. done
  53.  
  54. if [ -s ,errs ]
  55. then
  56.   more ,errs
  57.   exit 2 # Return an error code.
  58. else
  59.   exit 0
  60. fi
  61.