Annotation of 43BSDTahoe/new/rn/Rnmail.SH, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.