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