home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume04 / spelchck.sh < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  2.7 KB

  1. From decwrl!purdue!mailrus!ukma!cwjcc!hal!ncoast!allbery Tue Oct  4 07:33:22 PDT 1988
  2. Article 654 of comp.sources.misc:
  3. Path: granite!decwrl!purdue!mailrus!ukma!cwjcc!hal!ncoast!allbery
  4. From: badri@ur-valhalla.UUCP (Badri Lokanathan)
  5. Newsgroups: comp.sources.misc
  6. Subject: v04i112: SUPERSEDES v04i111: A convenient spelling filter based on 'spell' (revised)
  7. Keywords: spell,vi
  8. Message-ID: <1509@valhalla.ee.rochester.edu>
  9. Date: 4 Oct 88 01:13:07 GMT
  10. Sender: allbery@ncoast.UUCP
  11. Reply-To: badri@ur-valhalla.UUCP (Badri Lokanathan)
  12. Organization: UR Dept. of Electrical Engg, Rochester NY 14627
  13. Lines: 59
  14. Approved: allbery@ncoast.UUCP
  15. Supersedes: <1505@valhalla.ee.rochester.edu>
  16.  
  17. Posting-number: Volume 4, Issue 112
  18. Submitted-by: "Badri Lokanathan" <badri@ur-valhalla.UUCP>
  19. Archive-name: spell_check.sh
  20.  
  21. (To the moderator: I posted an earlier version which was incomplete and
  22. buggy; I am not even sure if it reached you. Please cancel it.)
  23. [Superseded; let's see if this works as claimed.  ++bsa]
  24.  
  25. The following shell script, based on spell, is convenient for highlighting
  26. spelling errors, either in a vi session or stand alone. I wrote it so
  27. that I could pipe text from within a vi session through it.
  28. (Note that you cannot just say
  29.         !}spell
  30. in vi since it would destroy your text!)
  31. [It may anyway.  Many "vi"'s have a bug when large amounts of text are piped
  32. to/from a command.  You have been warned!  ++bsa]
  33.  
  34. ------------%< cut here and save in spell_check ----------------------------
  35. #!/bin/sh
  36. ############################################################################
  37. #    A sh script to allow spelling checks either in vi or stand alone   #
  38. #    Usage: spell_check < file or within vi,                   #
  39. #        !}spell_check        or                   #
  40. #        :(addressed lines)!spell_check                   #
  41. #                                       #
  42. #       Wrongly spelled words will be surrounded as ###bad-word###         #
  43. #    WARNING: Do not try and sell this tiny shell script to some        #
  44. #       poor sucker!                               #
  45. #    Badri Lokanathan, 30 September 1988                                #
  46. ############################################################################
  47. doc=/tmp/splchk.$$
  48. scr=/tmp/sedscr.$$
  49.  
  50. trap 'rm -f $doc $scr; exit 1' 1 2 15
  51. cat > $doc
  52.  
  53. cat > $scr <<HEAD
  54. s/^/ /
  55. s/\$/ /
  56. HEAD
  57.  
  58. spell < $doc |
  59.     sed -e 's/^/s;\\([     ][^a-zA-Z0-9]*\\)\\(/
  60.         s/$/\\)\\([^a-zA-Z0-9]*[     ]\\);\\1###\\2###\\3;g/
  61.         s/ $//' >> $scr
  62.  
  63. cat >> $scr <<TAIL
  64. s/^ //
  65. s/ \$//
  66. TAIL
  67.  
  68. sed -f $scr $doc
  69. rm -f $doc $scr
  70.  
  71. -- 
  72. "I care about my fellow man              {) badri@valhalla.ee.rochester.edu
  73.  Being taken for a ride,                //\\ {ames,cmcl2,columbia,cornell,
  74.  I care that things start changing     ///\\\ garp,harvard,ll-xn,rutgers}!
  75.  But there's no one on my side."-UB40   _||_   rochester!ur-valhalla!badri
  76.  
  77.  
  78.