Annotation of 43BSD/contrib/rn/Pnews.SH, revision 1.1.1.1

1.1       root        1: case $CONFIG in
                      2:     '') . config.sh ;;
                      3: esac
                      4: echo "Extracting Pnews (with variable substitutions)"
                      5: $spitshell >Pnews <<!GROK!THIS!
                      6: $startsh
                      7: # $Header: Pnews.SH,v 4.3.1.3 85/08/01 14:24:06 lwall Exp $
                      8: #
                      9: # $Log:        Pnews.SH,v $
                     10: # Revision 4.3.1.3  85/08/01  14:24:06  lwall
                     11: # Added AUTHORCOPY.  Temp file is no longer in /tmp.  'e editor' added.
                     12: # 
                     13: # Revision 4.3.1.2  85/05/17  10:36:46  lwall
                     14: # Removed some extra backslashes.
                     15: # 
                     16: # Revision 4.3.1.1  85/05/10  11:30:21  lwall
                     17: # Branch for patches.
                     18: # 
                     19: # Revision 4.3  85/05/01  12:20:33  lwall
                     20: # Baseline for release with 4.3bsd.
                     21: # 
                     22: #
                     23: # syntax: Pnews -h headerfile                  or
                     24: #        Pnews -h headerfile oldarticle        or
                     25: #         Pnews newsgroup title                        or just
                     26: #         Pnews
                     27: 
                     28: export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
                     29: 
                     30: # System dependencies
                     31: 
                     32: mailer="${mailer-/bin/mail}"
                     33: # if you change this to something that does signatures, take out signature code
                     34: 
                     35: case $portable in
                     36: define)
                     37: # your site name
                     38: sitename=\`$hostcmd\`
                     39: # where recordings, distributions and moderators are kept
                     40: lib=\`$filexp $lib\`
                     41: # where important rn things are kept
                     42: rnlib=\`$filexp $rnlib\`
                     43: ;;
                     44: undef)
                     45: # your site name
                     46: sitename="$sitename"
                     47: # where recordings, distributions and moderators are kept
                     48: lib="$lib"
                     49: # where important rn things are kept
                     50: rnlib="$rnlib"
                     51: ;;
                     52: esac
                     53: 
                     54: # your organization name
                     55: orgname="$orgname"
                     56: # what pager you use--if you have kernal paging use cat
                     57: pager="\${PAGER-$pager}"
                     58: # how you derive full names, bsd, usg, or other
                     59: nametype="$nametype"
                     60: # default editor
                     61: defeditor="$defeditor"
                     62: # how not to echo with newline
                     63: n="$n"
                     64: c="$c"
                     65: 
                     66: # You should also look at the distribution warnings below marked !DIST!
                     67: # to make sure any distribution regions you are a member of are included.
                     68: # The following are some prototypical distribution groups.  If you do not
                     69: # use them all set the unused ones to a non-null string such as 'none'.
                     70: loc="$locpref"
                     71: org="$orgpref"
                     72: city="$citypref"
                     73: state="$statepref"
                     74: cntry="$cntrypref"
                     75: cont="$contpref"
                     76: 
                     77: test=${test-test}
                     78: sed=${sed-sed}
                     79: echo=${echo-echo}
                     80: cat=${cat-cat}
                     81: egrep=${egrep-egrep}
                     82: grep=${grep-grep}
                     83: rm=${rm-rm}
                     84: tr=${tr-tr}
                     85: inews=${inews-inews}
                     86: 
                     87: !GROK!THIS!
                     88: $spitshell >>Pnews <<'!NO!SUBS!'
                     89: dotdir=${DOTDIR-${HOME-$LOGDIR}}
                     90: tmpart=$dotdir/.article
                     91: 
                     92: if $test -f $dotdir/.pnewsexpert; then
                     93:     expertise=expert
                     94: else
                     95:     $cat <<'EOM'
                     96: I see you've never used this version of Pnews before.  I will give you extra
                     97: help this first time through, but then you must remember what you learned.
                     98: If you don't understand any question, type h and a CR (carriage return) for
                     99: help.
                    100: 
                    101: If you've never posted an article to the net before, it is HIGHLY recommended
                    102: that you read the netiquette document found in net.announce.newusers so
                    103: that you'll know to avoid the commonest blunders.  To do that, interrupt
                    104: Pnews, and get to the top-level prompt of rn.  Say "g net.announce.newusers"
                    105: and you are on your way.
                    106: 
                    107: EOM
                    108:     expertise=beginner
                    109: fi
                    110: 
                    111: case $cntry in
                    112:   can) stpr=Province ;;
                    113:   *)   stpr=State ;;
                    114: esac
                    115: 
                    116: headerfile=""
                    117: case $# in
                    118: 0) ;;
                    119: *)  case $1 in
                    120:     -h)
                    121:        headerfile="$2"
                    122:        shift
                    123:        shift
                    124:        case $# in
                    125:        0)
                    126:            oldart=""
                    127:            ;;
                    128:        *)
                    129:            oldart="$1"
                    130:            shift
                    131:            ;;
                    132:        esac
                    133:        ;;
                    134:     esac
                    135:     ;;
                    136: esac
                    137: 
                    138: case $headerfile in
                    139: '')
                    140:     . $rnlib/Pnews.header
                    141:     ;;
                    142: *)
                    143:     $cat < $headerfile  > $tmpart
                    144:     ;;
                    145: esac
                    146:     rescue="sleep 1; $cat $tmpart >>${HOME-$LOGDIR}/dead.article ; $echo Article appended to ${HOME-$LOGDIR}/dead.article ; exit"
                    147:     trap "$rescue" 1
                    148:     trap "$rescue" 2
                    149: 
                    150: $echo ""
                    151: set X `$sed < $tmpart -n -e '/^Distribution: /{' -e p -e q -e '}' -e '/^$/q'`
                    152: shift
                    153: case $# in
                    154: 0|1)
                    155:     set X `$sed < $tmpart -n -e '/^Newsgroups: /{' -e p -e q -e '}'`
                    156:     shift
                    157:     case $# in
                    158:     0|1)
                    159:        set "x net.whatever"
                    160:        ;;
                    161:     esac
                    162:     ;;
                    163: *)
                    164:     set $1 $2.whatever
                    165:     ;;
                    166: esac
                    167: shift
                    168: 
                    169: #: play recorded message
                    170: #if $test -s ${lib}/recording ; then
                    171: #     ng=`$echo $1 | $sed "s/,.*//"`
                    172: #    _rec1=${lib}/`$sed -n "/^$ng/s/^.*        //p" ${lib}/recording`
                    173: #    _tmp=`$echo $ng |$sed "s/\..*//"`
                    174: #    _rec2=${lib}/`$cat -s ${lib}/recording|$grep ${_tmp}.all|$sed "s/^.*      //"`
                    175: #    if $test -f ${_rec1} ; then
                    176: #      $cat -s ${_rec1}
                    177: #    fi
                    178: #    if $test -f ${_rec2} ; then
                    179: #      $cat -s ${_rec2}
                    180: #    fi
                    181: #fi
                    182: 
                    183: # tell them what we think they are doing... !DIST!
                    184: case $1 in
                    185: net.*)
                    186:     $echo 'This program posts news to many hundreds of machines throughout the world.'
                    187:     ;;
                    188: $cont.*)
                    189:     $echo 'This program posts news to many machines throughout the continent.'
                    190:     ;;
                    191: $cntry.*)
                    192:     $echo 'This program posts news to many machines throughout the country.'
                    193:     ;;
                    194: $state.*)
                    195:     $echo 'This program posts news to many machines throughout the state.'
                    196:     ;;
                    197: $city.*)
                    198:     $echo 'This program posts news to many machines throughout the city.'
                    199:     ;;
                    200: $org.*)
                    201:     $echo 'This program posts news to machines throughout the organization.'
                    202:     ;;
                    203: $loc.*)
                    204:     $echo 'This program posts news to machines throughout the local organization.'
                    205:     ;;
                    206: *.*)
                    207:     $echo 'This program may post news to many machines.'
                    208:     ;;
                    209: *)
                    210:     $echo 'This program posts news to everyone on the machine.'
                    211:     ;;
                    212: esac
                    213: ans=""
                    214: while $test "$ans" = "" ; do
                    215:     $echo $n "Are you absolutely sure that you want to do this? [ny] $c"
                    216:     read ans
                    217:     case $ans in
                    218:     y*) ;;
                    219:     f*) suppressmess=y ;;
                    220:     h*) $cat <<'EOH'
                    221: 
                    222: Type n or CR to exit, y to post.
                    223: 
                    224: EOH
                    225:        ans="" ;;
                    226:     *) exit ;;
                    227:     esac
                    228: done
                    229: 
                    230: file=h
                    231: while $test "$file" = h ; do
                    232:     $echo ""
                    233:     $echo $n "Prepared file to include [none]: $c"
                    234:     read file
                    235:     case $file in
                    236:     h)
                    237:        $cat <<'EOH'
                    238: 
                    239: If you have already produced the body of your article, type the filename
                    240: for it here.  If you just want to proceed directly to the editor, type a
                    241: RETURN.  In any event, you will be allowed to edit as many times as you
                    242: want before you send off the article.
                    243: EOH
                    244:        ;;
                    245:     '')
                    246:        $echo "" >> $tmpart
                    247:        state=edit
                    248:        ;;
                    249:     *)
                    250:        $cat $file >>$tmpart
                    251:        state=ask
                    252:        ;;
                    253:     esac
                    254: done
                    255: 
                    256: $echo ""
                    257: 
                    258: while true ; do
                    259:     case $state in
                    260:     edit)
                    261:        case $expertise in
                    262:        beginner)
                    263:            $cat </dev/null >$dotdir/.pnewsexpert
                    264:            $cat <<'EOMessage'
                    265: A temporary file has been created for you to edit.  Be sure to leave at
                    266: least one blank line between the header and the body of your message.
                    267: (And until a certain bug is fixed all over the net, don't start the body of
                    268: your message with any indentation, or it may get eaten.)
                    269: 
                    270: Within the header may be fields that you don't understand.  If you don't
                    271: understand a field (or even if you do), you can simply leave it blank, and
                    272: it will go away when the article is posted.
                    273: 
                    274: Type return to get the default editor, or type the name of your favorite
                    275: editor.
                    276: 
                    277: EOMessage
                    278:            ;;
                    279:        esac
                    280:        case "${VISUAL-${EDITOR-}}" in
                    281:        '')
                    282:            tmp=h
                    283:            ;;
                    284:        *)
                    285:            tmp=''
                    286:            ;;
                    287:        esac
                    288:        while $test "$tmp" = h ; do
                    289:            $echo $n "Editor [${VISUAL-${EDITOR-$defeditor}}]: $c"
                    290:            read tmp
                    291:            case $tmp in
                    292:            h)
                    293:                $cat <<'EOH'
                    294: 
                    295: Type a return to get the default editor, or type the name of the editor you
                    296: prefer.  The default editor depends on the VISUAL and EDITOR environment
                    297: variables.
                    298: 
                    299: EOH
                    300:                ;;
                    301:            '')
                    302:                ;;
                    303:            *)
                    304:                VISUAL=$tmp
                    305:                export VISUAL
                    306:                ;;
                    307:            esac
                    308:        done
                    309:        trap : 2
                    310:        ${VISUAL-${EDITOR-$defeditor}} $tmpart $oldart
                    311:        trap "$rescue" 2
                    312:        state=ask
                    313:        ;;
                    314:        
                    315:     ask)
                    316:        $echo ""
                    317:        $echo $n "Send, abort, edit, or list? $c"
                    318:        read ans
                    319:        
                    320:        case "$ans" in
                    321:        a*)
                    322:            state=rescue
                    323:            ;;
                    324:        e*)
                    325:            set $ans
                    326:            case $# in
                    327:            2)  VISUAL="$2" ;;
                    328:            esac
                    329:            state=edit
                    330:            ;;
                    331:        l*)
                    332:            $pager $tmpart
                    333:            state=ask
                    334:            ;;
                    335:        s*)
                    336:            state=send
                    337:            ;;
                    338:        h*)
                    339:            $cat <<'EOH'
                    340: 
                    341: Type s to send the article, a to abort and append the article to dead.article,
                    342: e to edit the article again, or l to list the article.
                    343: 
                    344: To invoke an alternate editor, type 'e editor'.
                    345: EOH
                    346:        esac
                    347:        ;;
                    348:     
                    349:     send)
                    350:        set X `$sed < $tmpart -n -e '/^Newsgroups: /{' -e p -e q -e '}'`
                    351:        shift
                    352:        case $# in
                    353:        2)
                    354:            state=cleanup
                    355:            if $test -f $lib/moderators; then
                    356:                tryinews=no
                    357:                shift
                    358:                case "$1" in
                    359:                *,*) set `$echo $1 | tr ',' ' '`;;
                    360:                esac
                    361:                for newsgroup in $*; do
                    362: # the following screwy sed should prevent Eunice from hanging on no match
                    363:                    moderator=`$sed <$lib/moderators \
                    364:                    -e "/^$newsgroup[   ]/!s/.*//" \
                    365:                    -e "s/^$newsgroup[  ]//"`
                    366:                    case ${moderator}X in
                    367:                    X)  tryinews=yes
                    368:                        ;;
                    369:                    *)
                    370:                        $echo Mailing to moderator $moderator
                    371:                        case "$sign" in
                    372:                        n*) ;;
                    373:                        *)
                    374:                            if $test -f $dotdir/.signature; then
                    375:                                echo $n "Append .signature file? [y] $c"
                    376:                                read ans
                    377:                                case $ans in
                    378:                                ''|y*)
                    379:                                    echo "-- " >> $tmpart
                    380:                                    cat $dotdir/.signature >> $tmpart
                    381:                                    ;;
                    382:                                esac
                    383:                            fi
                    384:                            sign=no
                    385:                            ;;
                    386:                        esac
                    387:                        case "$mailer" in
                    388:                        *recmail)
                    389:                            $echo To: $moderator | $cat - $tmpart | $mailer
                    390:                            ;;
                    391:                        *)
                    392:                            $mailer $moderator < $tmpart
                    393:                            ;;
                    394:                        esac
                    395:                        case $? in
                    396:                        0) ;;
                    397:                        *)
                    398:                            $echo Unable to mail to moderator $moderator
                    399:                            state=rescue
                    400:                            ;;
                    401:                        esac
                    402:                        ;;
                    403:                    esac
                    404:                done
                    405:            else
                    406:                tryinews=yes
                    407:            fi
                    408:            case "$tryinews" in
                    409:            yes)
                    410:                if $inews -h < $tmpart ; then
                    411:                    : null
                    412:                else
                    413:                    state=rescue
                    414:                fi
                    415:                ;;
                    416:            esac
                    417:            ;;
                    418:        *)
                    419:            $echo ""
                    420:            $echo "Malformed Newsgroups line."
                    421:            $echo ""
                    422:            sleep 1
                    423:            state=edit
                    424:            ;;
                    425:        esac
                    426:        ;;
                    427:     rescue)
                    428:        $cat $tmpart >> ${HOME-$LOGDIR}/dead.article
                    429:        $echo "Article appended to ${HOME-$LOGDIR}/dead.article"
                    430:        $echo "A copy may be temporarily found in $tmpart"
                    431:        exit
                    432:        ;;
                    433:     cleanup)
                    434:        case "${AUTHORCOPY-none}" in
                    435:        none)
                    436:            ;;
                    437:        *)  if $cat $tmpart >> $AUTHORCOPY; then
                    438:                $echo "Article appended to $AUTHORCOPY"
                    439:                $echo "" >> $AUTHORCOPY
                    440:                $echo "" >> $AUTHORCOPY
                    441:            else
                    442:                $echo "Cannot append to $AUTHORCOPY"
                    443:            fi
                    444:            ;;
                    445:        esac
                    446:        exit
                    447:        ;;
                    448:     esac
                    449: done
                    450: !NO!SUBS!
                    451: $eunicefix Pnews
                    452: chmod 755 Pnews
                    453: $spitshell >Pnews.header <<'!NO!SUBS!'
                    454: case $# in
                    455: 0)
                    456:     ng=h
                    457:     while $test "$ng" = h ; do
                    458:        $echo ""
                    459:        $echo $n "Newsgroup(s): $c"
                    460:        read ng
                    461:        case $ng in
                    462:        h)
                    463:            $cat <<'EOH'
                    464: 
                    465: Type the name of one or more newsgroups to which you wish to post an article.
                    466: If you want to post to multiple newsgroups, it is better to do them all at
                    467: once than to post to each newsgroup individually, which defeats the news
                    468: reading programs' strategies of eliminating duplicates.
                    469: 
                    470: Separate multiple newsgroup names with commas.
                    471: EOH
                    472:            ;;
                    473:        esac
                    474:     done
                    475:     ;;
                    476: *)
                    477:     ng=$1
                    478:     shift
                    479:     ;;
                    480: esac
                    481: case $ng in
                    482: *\ *)
                    483:     ng=`$echo "$ng" | $sed 's/[, ] */,/g'`
                    484:     ;;
                    485: esac
                    486: case $ng in
                    487: net.*|fa.*|mod.*)
                    488:     defdist=net
                    489:     dist=h
                    490:     ;;
                    491: *.*)
                    492:     defdist=`expr "X$ng" : 'X\([a-z0-9]*\)'`
                    493:     dist=h
                    494:     ;;
                    495: *)
                    496:     defdist=''
                    497:     dist=''
                    498:     ;;
                    499: esac
                    500: 
                    501: while $test "$dist" = h ; do
                    502:     if $test -f $lib/distributions; then
                    503:        $echo " "
                    504:        $echo "Your local distribution prefixes are:"
                    505:        $cat $lib/distributions
                    506:     else
                    507:        $egrep -v '[     ]none$' <<EOM
                    508: 
                    509: Your local distribution prefixes are:
                    510:     Local organization:        $loc
                    511:     Organization:              $org
                    512:     City:                      $city
                    513:     $stpr:             $state
                    514:     Country:           $cntry
                    515:     Continent:         $cont
                    516:     Everywhere:                net,mod,fa
                    517: 
                    518: EOM
                    519:     fi
                    520:     $echo $n "Distribution ($defdist): $c"
                    521:     read dist
                    522:     case $dist in
                    523:     '') dist=$defdist ;;
                    524:     esac
                    525:     case $dist in
                    526:     h)
                    527:        $cat <<'EOH'
                    528: 
                    529: The Distribution line may be used to limit the distribution of an article
                    530: to some subset of the systems that would receive the article based only on
                    531: the Newsgroups line.  For example, if you want to sell your car in net.auto,
                    532: and you live in New Jersey, you might want to put "nj" on the Distribution
                    533: line to avoid advertising in California, which has enough problems of its own.
                    534: The actual area designators to use depend on where you are, of course.
                    535: EOH
                    536:        ;;
                    537:     ''|$loc*|$org*|$city*|$state*|$cntry*|$cont*|fa*|mod*)
                    538:        ;;
                    539:     net*|world*)
                    540:        dist=''
                    541:        ;;
                    542:     *)  
                    543:        if $test -f $lib/distributions && \
                    544:          $egrep "^$dist[       ]" $lib/distributions >$tmpart && \
                    545:          $test -s $tmpart; then
                    546:            : null
                    547:        else
                    548:            $echo "Unrecognized distribution prefix--type h for help."
                    549:            dist=h
                    550:        fi
                    551:        ;;
                    552:     esac
                    553: done
                    554: 
                    555: case $ng in
                    556: *net.general*)
                    557:     follow=`echo "$ng" | sed 's/net\.general/net.followup/g'`
                    558:     ;;
                    559: *)
                    560:     follow=""
                    561:     ;;
                    562: esac
                    563: 
                    564: case $# in
                    565: 0)
                    566:     title=h
                    567:     while $test "$title" = h ; do
                    568:        $echo ""
                    569:        $echo $n "Title/Subject: $c"
                    570:        read title
                    571:        case $title in
                    572:        h)
                    573:            $cat <<'EOH'
                    574: 
                    575: Type the title for your article.  Please make it as informative as possible
                    576: (within reason) so that people who aren't interested won't have to read the
                    577: article to find out they aren't interested.  This includes marking movie
                    578: spoilers as (spoiler), and rotated jokes as (rot 13).
                    579: EOH
                    580:        ;;
                    581:        esac
                    582:     done
                    583:     ;;
                    584: *)
                    585:     title="$*"
                    586:     ;;
                    587: esac
                    588: 
                    589: # now build a file with a header for them to edit
                    590: 
                    591: set X ${USER-${LOGNAME-`who am i`}}
                    592: shift
                    593: logname=$1
                    594: case $logname in
                    595: *!*) logname=`expr "$logname" : '!\(.*\)$'` ;;
                    596: esac
                    597: case ${NAME-$nametype} in
                    598: bsd)
                    599:     fullname=`$sed </etc/passwd -e "/^$logname:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:\([^,:;]*\).*"'$'"/\1/" -e "q" -e "}" -e "d"`
                    600:     case $fullname in
                    601:     *'&'*) : GACK
                    602:        lname=`$echo $logname | $tr 'a-z' 'A-Z'`
                    603:        lname=`$echo $lname $logname | $sed 's/^\(.\)[^ ]* ./\1/'`
                    604:        fullname=`$echo "$fullname" | $sed "s/&/${lname}/"`
                    605:        ;;
                    606:     esac
                    607:     ;;
                    608: usg)
                    609:     fullname=`$sed </etc/passwd -e "/^$logname:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:\([^(:]*\).*"'$'"/\1/" -e "s/^.*-//" -e "q" -e "}" -e "d"`
                    610:     ;;
                    611: *)
                    612:     fullname=${NAME-`$cat $dotdir/.fullname`}
                    613:     ;;
                    614: esac
                    615: 
                    616: orgname=${ORGANIZATION-$orgname}
                    617: case $orgname in
                    618: /*) orgname=`$cat $orgname` ;;
                    619: esac
                    620: 
                    621: $cat > $tmpart <<EOHeader
                    622: Newsgroups: $ng
                    623: Subject: $title
                    624: Expires: 
                    625: References: 
                    626: Sender: 
                    627: Reply-To: $logname@$sitename.UUCP ($fullname)
                    628: Followup-To: $follow
                    629: Distribution: $dist
                    630: Organization: $orgname
                    631: Keywords: 
                    632: 
                    633: EOHeader
                    634: 
                    635: !NO!SUBS!
                    636: $eunicefix Pnews.header

unix.superglobalmegacorp.com

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