home *** CD-ROM | disk | FTP | other *** search
/ ftp.freefriends.org / ftp.freefriends.org.tar / ftp.freefriends.org / arnold / Source / mush.rstevens.tar.gz / mush.tar / digestify < prev    next >
Text File  |  1992-03-31  |  4KB  |  146 lines

  1. #! /bin/csh -f
  2. #
  3. # Mush digestifier.  Makes a folder or a list of messages into a digest.
  4. #
  5. if ! $?thisfolder then
  6.     exec mush -F! $0 $*
  7. endif
  8. #
  9. # A "digest" is a collection of E-mail messages bundled together into a
  10. # single message for ease of redistribution.  The individual messages
  11. # in the digest are called "articles".  Each article has a small set of
  12. # essential headers (usually From:, Date:, and Subject:) and is divided
  13. # from the preceding and following articles by an "article separator"
  14. # string (usually eight hyphens, "--------").  The Mush built-in command
  15. # "undigest" unpacks most digests, including those made by this script.
  16. #
  17. # Usage:
  18. #  From your shell:        digestify -f mailbox
  19. #  From within mush:    
  20. #    First:        cmd digest "set digest = '\!*' ; source digestify"
  21. #    Then:        digest [msg-list]
  22. #    Or:        message-selection-command | digest
  23. #
  24. # Note that by default it makes a digest of the ENTIRE folder!
  25. #
  26.  
  27. #
  28. # Rudimentary sanity checks
  29. #
  30. if ! $?version
  31.     echo "You must have Mush version 7.0 or higher to run this script"
  32.     exit
  33. endif
  34. if ! $?thisfolder
  35.     echo "You can't use this script as an init file; try using -F"
  36.     exit
  37. endif
  38.  
  39. #
  40. # Set up defaults
  41. #
  42. if ! $?digest
  43.     set digest = *
  44.     if $?interact
  45.     unset interact        # Assume non-interactive if no input list
  46.     endif
  47. else
  48.     set interact        # Note that this is interactive
  49.     if "X$digest" == X
  50.         set digest = *        # Default to all messages for empty input
  51.     else
  52.     $digest | set digest    # Pre-expand message numbers
  53.     endif
  54. endif
  55.  
  56. #
  57. # Suppress any "that isn't set" messages from "unset"
  58. #
  59. if $?warning
  60.     set savewarn
  61. endif
  62. unset warning oldpre oldpost oldindent oldign oldshow
  63.  
  64. #
  65. # Save everything in case the user wants it back.
  66. # Could wrap all this with "if $?interact" but this script
  67. # might be read by "mush -F", in which case we need this.
  68. #
  69. if $?pre_indent_str
  70.     set oldpre = "$pre_indent_str"
  71. endif
  72. if $?post_indent_str
  73.     set oldpost = "$post_indent_str"
  74. endif
  75. if $?indent_str
  76.     set oldindent = "$indent_str"
  77. endif
  78. if $?alwaysignore
  79.     set oldign = "$alwaysignore"
  80. endif
  81. if $?show_hdrs
  82.     set oldshow = "$show_hdrs"
  83. endif
  84. if $?quiet
  85.     set oldquiet = "$quiet"
  86. endif
  87. if $?no_expand
  88.     set savenoex
  89. endif
  90.  
  91. #
  92. # Prepare to form the digest.
  93. #
  94. set indent_str no_expand alwaysignore=include quiet=await,newmail
  95. unset post_indent_str
  96. alias DIGEST $thisfolder        # Any target in place of $thisfolder
  97. set pre_indent_str="--------"        # Insert your digest separator here
  98. set show_hdrs=from,date,subject        # Add any other headers you want
  99.  
  100. #
  101. # Now do it.  All that work for a two-line operation ....
  102. # NOTE: If you change DIGEST above, remove the "await" command here!
  103. # Backslashes prevent any cmd expansion from confusing us.
  104. #
  105. \delete $digest
  106. \mail -UH /dev/null -I $digest -s "Digest of $thisfolder" DIGEST; \await -T 1
  107.  
  108. #
  109. # Clean out the deleted stuff if not interactive
  110. #
  111. if ! $?interact
  112.     \update
  113. endif
  114.  
  115. #
  116. # Be neat and put everything back the way it was.
  117. #
  118. unset indent_str no_expand alwaysignore quiet pre_indent_str show_hdrs
  119. unalias DIGEST
  120. if $?savenoex
  121.     set no_expand
  122. endif
  123. if $?oldquiet
  124.     set quiet = "$oldquiet"
  125. endif
  126. if $?oldpre
  127.     set pre_indent_str = "$oldpre"
  128. endif
  129. if $?oldpost
  130.     set post_indent_str = "$oldpost"
  131. endif
  132. if $?oldindent
  133.     set indent_str = "$oldindent"
  134. endif
  135. if $?oldign
  136.     set alwaysignore = "$oldign"
  137. endif
  138. if $?oldshow
  139.     set show_hdrs = "$oldshow"
  140. endif
  141. unset oldpre oldpost oldindent oldign oldshow oldquiet nonoex digest
  142. if $?savewarn
  143.     unset savewarn
  144.     set warning
  145. endif
  146.