Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!iuvax!cica!tut.cis.ohio-state.edu!ucbvax!husc6!ogccse!schaefer
From: schaefer@ogccse.ogc.edu (Barton E. Schaefer)
Newsgroups: comp.mail.mush
Subject: Revised Rnmush script
Message-ID: <4191@ogccse.ogc.edu>
Date: 11 Aug 89 18:46:21 GMT
Reply-To: schaefer@ogccse.UUCP (Barton E. Schaefer)
Organization: Oregon Graduate Center, Beaverton, OR
Lines: 203
The recent reappearance of my two-month-old posting of the Rnmush script
has prompted a wave of commentary (and a couple of bug reports). Here
is the "current" version of Rnmush, which has the following changes from
the original:
Uses MAILRECORD (thanks to Ze'ev Shtadler ).
Ignores -h all by itself (i.e. when no file name given).
Handles wrapped or multiple To: lines in the -h file.
Handles wrapped To: lines generated by mush.
Actually *does* include the "Prepared file to include:"!!
This script is still Berzerkeleyized, and will need minor mods for SysV.
To use Rnmush to send replies from RN:
setenv MAILPOSTER "Rnmush -h %h" # csh
or
MAILPOSTER="Rnmush -h %h" ; export MAILPOSTER # sh
#! /bin/sh -
# Rnmush -- script to use mush for Rnmail
#
# Based on Larry Wall's Rnmail
#
# syntax: Rnmush -h headerfile [oldart] or
# Rnmush destination-list or just
# Rnmush
#
# This script creates two other scripts:
# 1) sh script, which takes care of merging the rn header file with
# mush's editor temp file and then calls the regular visual editor;
# 2) mush script, fed via "mush -source", which sets up some environment
# and arranges for the first script to be used as the visual editor.
# system configuration
# your organization name
orgname="/usr/lib/news/organization"
mush=mush
defeditor=/usr/ucb/vi
test=/bin/test
sed=sed
echo=echo
cat=cat
rm=/bin/rm
chmod=chmod
# how to echo without a newline
n="-n"
c=""
dotdir=${DOTDIR-${HOME-$LOGDIR}}
tmpart=$dotdir/.letter
start=$dotdir/.rnmush$$
preedit=$dotdir/.rnvis$$
locked=$dotdir/.rnvlk$$
trap "$rm -f $start $preedit $locked; exit 1" 1 2 3 13 15 21 22 23
# some initialization for the mush script
visual=${VISUAL-${EDITOR-$defeditor}}
orgname=${ORGANIZATION-$orgname}
case $orgname in
/*) orgname=`$cat $orgname` ;;
esac
mailrecord=${MAILRECORD+record="${MAILRECORD}"}
# Use this line for mush 6.4
#$echo set verify autoedit $mailrecord \; unset edit_hdrs > $start
# Change to this line for mush 6.5
$echo set edit_hdrs verify autoedit $mailrecord > $start
headerfile=""
case $# in
0) ;;
*) case $1 in
-h)
headerfile="$2"
case $# in
3) oldart=$3 ;;
1) shift ;;
esac
;;
esac
;;
esac
subject=""
case $headerfile in
'')
case $# in
0)
$echo $n "To: $c"
read to
;;
*)
to="$*"
;;
esac
$echo $n "Subject: $c"
subject="-s `read subject; echo '\"'$subject'\"'`"
$echo $n "$c" > $tmpart
$echo my_hdr Organization: "$orgname" >> $start
$cat < $preedit
if $test ! -f $locked ; then
$cat $tmpart >> \$1
$echo "" > $locked
fi
$visual \$1
EOStrip
;;
*)
# Handle wrapped To: lines
to=`$sed -n -e '1,/^$/ {
/^To:/,/^[A-Za-z]/ {
s/^To: \(.*\)/\1/p
/^[^A-Za-z]/p
}
}' < $headerfile | tr '\012' ' '`
# Use this section for mush 6.4
# $echo unset ask asksub askcc >> $start
# $sed '1,/^$/d' < $headerfile > $tmpart
# subject="-s \"`$sed -e '/^Subject:/p' -e '/.*/d' < $headerfile \
# | $sed 's/^Subject: //'`\""
# $sed -e '1,/^$/p' -e '/.*/d' < $headerfile \
# | $sed -e '/^To:/d' -e '/^Subject:/d' -e '/^$/d' -e 's/^/my_hdr /' \
# >> $start
# $cat < $preedit
#if $test ! -f $locked ; then
#$cat < $tmpart > \$1
#$echo "" > $locked
#fi
#$visual \$1
#EOStrip
#
# Change to this new section for mush 6.5
#
$cat <<'EOStart' >> $start
if $?ask
unset ask
endif
if $?asksub
unset asksub
endif
if $?askcc
unset askcc
endif
EOStart
#
# The code below relies on mush's placement of the To: and Subject:
# headers. If Subject: does not immediately follow To:, this removes
# too many headers. Alternate sed command if you have this problem:
# $sed -e '/^To:/d' -e '/^Subject:/d' -e '/^\$/d' < \$1 > /tmp/$$
# (the alternate does not handle wrapped To: lines properly).
#
$cat < $preedit
if $test ! -f $locked ; then
$sed -e '/^To:/,/^Subject:/d' -e '/^\$/d' < \$1 > /tmp/$$
$cat /tmp/$$ $headerfile $tmpart > \$1
$rm -f /tmp/$$
$echo "" > $locked
fi
$visual \$1
EOStrip
# End of 6.5 section
;;
esac
$cat <> $start
set visual=$preedit
mail $subject $to
quit
EOStart
$chmod +x $preedit
file=h
while $test "$file" = h ; do
$echo ""
$echo $n "Prepared file to include [none]: $c"
read file
case $file in
h)
;;
'')
$echo "" >> $tmpart
;;
*)
$cat $file >> $tmpart
;;
esac
done
$echo ""
$mush -shell -noheaders -readonly -source $start -folder /dev/null
$rm -f $preedit $start $locked
exit 0
--
Bart Schaefer "And if you believe that, you'll believe anything."
-- DangerMouse
CSNET / Internet schaefer@cse.ogc.edu
UUCP ...{sequent,tektronix,verdix}!ogccse!schaefer