Commit | Line | Data |
---|---|---|
25a197fc C |
1 | case $CONFIG in |
2 | '') . config.sh ;; | |
3 | esac | |
4 | echo "Extracting Rnmail (with variable substitutions)" | |
5 | $spitshell >Rnmail <<!GROK!THIS! | |
6 | $startsh | |
7 | # $Header: Rnmail.SH,v 4.3.1.3 85/05/20 16:25:17 lwall Exp $ | |
8 | # | |
9 | # $Log: Rnmail.SH,v $ | |
10 | # Revision 4.3.1.3 85/05/20 16:25:17 lwall | |
11 | # Shouldn't ask editor if EDITOR or VISUAL defined. | |
12 | # | |
13 | # Revision 4.3.1.2 85/05/17 10:36:19 lwall | |
14 | # Added "-- " before .signature. | |
15 | # | |
16 | # Revision 4.3.1.1 85/05/10 11:30:38 lwall | |
17 | # Branch for patches. | |
18 | # | |
19 | # Revision 4.3 85/05/01 11:34:18 lwall | |
20 | # Baseline for release with 4.3bsd. | |
21 | # | |
22 | # | |
23 | # syntax: Rnmail -h headerfile [oldart] or | |
24 | # Rnmail destination-list or just | |
25 | # Rnmail | |
26 | ||
27 | export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$) | |
28 | ||
29 | # System dependencies | |
30 | ||
31 | mailer="${mailer-/bin/mail}" | |
32 | # if you change this to something that does signatures, take out signature code | |
33 | ||
34 | # your site name | |
35 | case $portable in | |
36 | define) sitename=\`$hostcmd\` ;; | |
37 | undef) sitename="$sitename" ;; | |
38 | esac | |
39 | # your organization name | |
40 | orgname="$orgname" | |
41 | # what pager you use--if you have kernal paging use cat | |
42 | pager="\${PAGER-$pager}" | |
43 | # how you derive full names, bsd, usg, or other | |
44 | nametype="$nametype" | |
45 | # default editor | |
46 | defeditor="$defeditor" | |
47 | # how not to do a newline with echo | |
48 | n="$n" | |
49 | c="$c" | |
50 | ||
51 | test=${test-test} | |
52 | sed=${sed-sed} | |
53 | echo=${echo-echo} | |
54 | cat=${cat-cat} | |
55 | grep=${grep-grep} | |
56 | rm=${rm-rm} | |
57 | ||
58 | !GROK!THIS! | |
59 | $spitshell >>Rnmail <<'!NO!SUBS!' | |
60 | tmpart=/tmp/rnmail$$ | |
61 | dotdir=${DOTDIR-${HOME-$LOGDIR}} | |
62 | ||
63 | headerfile="" | |
64 | case $# in | |
65 | 0) ;; | |
66 | *) case $1 in | |
67 | -h) | |
68 | headerfile="$2" | |
69 | case $# in | |
70 | 3) oldart=$3 ;; | |
71 | esac | |
72 | ;; | |
73 | esac | |
74 | ;; | |
75 | esac | |
76 | ||
77 | case $headerfile in | |
78 | '') | |
79 | case $# in | |
80 | 0) | |
81 | to=h | |
82 | while $test "$to" = h ; do | |
83 | $echo "" | |
84 | $echo $n "To: $c" | |
85 | read to | |
86 | case $to in | |
87 | h) | |
88 | $cat <<'EOH' | |
89 | ||
90 | Type the net address of those people that you wish the message sent to. | |
91 | Note that you will be asked later for additional addresses of people to | |
92 | whom the message is not addressed but you wish to get copies. | |
93 | ||
94 | Separate multiple addresses with spaces. | |
95 | ||
96 | EOH | |
97 | ;; | |
98 | esac | |
99 | done | |
100 | ;; | |
101 | *) | |
102 | to="$*" | |
103 | ;; | |
104 | esac | |
105 | to=`$echo "$to" | $sed 's/ */ /g'` | |
106 | ||
107 | title=h | |
108 | while $test "$title" = h ; do | |
109 | $echo "" | |
110 | $echo $n "Title/Subject: $c" | |
111 | read title | |
112 | case $title in | |
113 | h) | |
114 | $cat <<'EOH' | |
115 | ||
116 | Type the title for your message. | |
117 | EOH | |
118 | ;; | |
119 | esac | |
120 | done | |
121 | ||
122 | # now build a file with a header for them to edit | |
123 | ||
124 | orgname=${ORGANIZATION-$orgname} | |
125 | case $orgname in | |
126 | /*) orgname=`$cat $orgname` ;; | |
127 | esac | |
128 | ||
129 | $cat > $tmpart <<EOHeader | |
130 | To: $to | |
131 | Subject: $title | |
132 | Organization: $orgname | |
133 | Cc: | |
134 | Bcc: | |
135 | ||
136 | EOHeader | |
137 | ||
138 | ;; | |
139 | *) | |
140 | $cat < $headerfile > $tmpart | |
141 | ;; | |
142 | esac | |
143 | ||
144 | ||
145 | file=h | |
146 | while $test "$file" = h ; do | |
147 | $echo "" | |
148 | $echo $n "Prepared file to include [none]: $c" | |
149 | read file | |
150 | case $file in | |
151 | h) | |
152 | $cat <<'EOH' | |
153 | ||
154 | If you have already produced the body of your message, type the filename | |
155 | for it here. If you just want to proceed directly to the editor, type a | |
156 | RETURN. In any event, you will be allowed to edit as many times as you | |
157 | want before you send off the message. | |
158 | EOH | |
159 | ;; | |
160 | '') | |
161 | $echo "" >> $tmpart | |
162 | state=edit | |
163 | ;; | |
164 | *) | |
165 | $cat $file >>$tmpart | |
166 | state=ask | |
167 | ;; | |
168 | esac | |
169 | done | |
170 | ||
171 | $echo "" | |
172 | ||
173 | while true ; do | |
174 | case $state in | |
175 | edit) | |
176 | rescue="sleep 1; $cat $tmpart >>${HOME-$LOGDIR}/dead.letter ; $echo saved in ${HOME-$LOGDIR}/dead.letter ; $rm -f $tmpart; exit" | |
177 | trap "$rescue" 1 | |
178 | trap : 2 | |
179 | case "${VISUAL-${EDITOR-}}" in | |
180 | '') | |
181 | tmp=h | |
182 | ;; | |
183 | *) | |
184 | tmp='' | |
185 | ;; | |
186 | esac | |
187 | while $test "$tmp" = h ; do | |
188 | $echo $n "Editor [${VISUAL-${EDITOR-$defeditor}}]: $c" | |
189 | read tmp | |
190 | case $tmp in | |
191 | h) | |
192 | $cat <<'EOH' | |
193 | ||
194 | Type a return to get the default editor, or type the name of the editor you | |
195 | prefer. The default editor depends on the VISUAL and EDITOR environment | |
196 | variables. | |
197 | ||
198 | EOH | |
199 | ;; | |
200 | '') | |
201 | ;; | |
202 | *) | |
203 | VISUAL=$tmp | |
204 | export VISUAL | |
205 | ;; | |
206 | esac | |
207 | done | |
208 | ${VISUAL-${EDITOR-$defeditor}} $tmpart $oldart | |
209 | trap "$rescue" 2 | |
210 | state=ask | |
211 | ;; | |
212 | ||
213 | ask) | |
214 | $echo "" | |
215 | $echo $n "Send, abort, edit, or list? $c" | |
216 | read ans | |
217 | ||
218 | case $ans in | |
219 | a*) | |
220 | state=rescue | |
221 | ;; | |
222 | e*) | |
223 | state=edit | |
224 | ;; | |
225 | l*) | |
226 | $pager $tmpart | |
227 | state=ask | |
228 | ;; | |
229 | s*) | |
230 | state=send | |
231 | ;; | |
232 | h*) | |
233 | $cat <<'EOH' | |
234 | ||
235 | Type s to send the message, a to abort and append the message to dead.letter, | |
236 | e to edit the message again, or l to list the message. | |
237 | EOH | |
238 | esac | |
239 | ;; | |
240 | ||
241 | send) | |
242 | if $test -f $dotdir/.signature; then | |
243 | echo $n "Append .signature file? [y] $c" | |
244 | read ans | |
245 | case $ans in | |
246 | ''|y*) | |
247 | echo "-- " >> $tmpart | |
248 | cat $dotdir/.signature >> $tmpart | |
249 | ;; | |
250 | esac | |
251 | fi | |
252 | case $mailer in | |
253 | *sendmail) | |
254 | $mailer -t <$tmpart | |
255 | ;; | |
256 | # but recmail does not know about Bcc, alas | |
257 | *recmail) | |
258 | $mailer <$tmpart | |
259 | ;; | |
260 | *) | |
261 | set X `$sed <$tmpart -n -e '/^To:/{' -e 's/To: *//p' -e q -e '}'` | |
262 | shift | |
263 | set X "$@" `$sed <$tmpart -n -e '/^Cc:/{' -e 's/Cc: *//p' -e q -e '}'` | |
264 | shift | |
265 | set X "$@" `$sed <$tmpart -n -e '/^Bcc:/{' -e 's/Bcc: *//p' -e q -e '}'` | |
266 | shift | |
267 | $grep -v "^Bcc:" <$tmpart | $mailer "$@" | |
268 | ;; | |
269 | esac | |
270 | case $? in | |
271 | 0) | |
272 | state=cleanup | |
273 | ;; | |
274 | *) | |
275 | state=rescue | |
276 | ;; | |
277 | esac | |
278 | ;; | |
279 | rescue) | |
280 | $cat $tmpart >> ${HOME-$LOGDIR}/dead.letter | |
281 | $echo "Message saved to ${HOME-$LOGDIR}/dead.letter" | |
282 | state=cleanup | |
283 | ;; | |
284 | cleanup) | |
285 | $rm -f $tmpart | |
286 | exit | |
287 | ;; | |
288 | esac | |
289 | done | |
290 | !NO!SUBS! | |
291 | $eunicefix Rnmail | |
292 | chmod 755 Rnmail |