home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 1 / GoldFishApril1994_CD2.img / d4xx / d473 / cnewssrc / cnews_src.lzh / relay / sh / postnews < prev    next >
Text File  |  1989-10-14  |  2KB  |  102 lines

  1. #! /bin/sh
  2. # postnews - post news article
  3.  
  4. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  5. . ${NEWSCONFIG-/usr/lib/news/bin/config}
  6.  
  7. PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH    # but do not export it
  8. umask 077                # private
  9.  
  10. tmp=/tmp/pn$$
  11. term="rm -f $tmp ; exit 0"
  12. trap "$term" 0 1 2
  13.  
  14. if test " $VISUAL" != " "; then
  15.     edit="$VISUAL"
  16. elif test " $EDITOR" != " "; then
  17.     edit="$EDITOR"
  18. else
  19.     edit=/bin/ed
  20. fi
  21.  
  22. case $# in
  23. 0)
  24.     if test -r $NEWSCTL/postdefltgroup
  25.     then
  26.         defg="`cat $NEWSCTL/postdefltgroup`"
  27.         dprompt=" [$defg]"
  28.     else
  29.         defg=
  30.         dprompt=
  31.     fi
  32.     ans=
  33.     while test " $ans" = " "
  34.     do
  35.         echo "Newsgroup(s)$dprompt? " | tr -d '\012'
  36.         read ans
  37.         case "$ans" in
  38.         '')    if test " $defg" != " "
  39.             then
  40.                 ans="$defg"
  41.             fi
  42.             ;;
  43.         esac
  44.     done
  45.     echo "Newsgroups: $ans" >>$tmp
  46.     ;;
  47.  
  48. 1)
  49.     echo "Newsgroups: $1" >>$tmp
  50.     ;;
  51.  
  52. *)
  53.     echo 'Usage: postnews [newsgroups]' >&2
  54.     exit 2
  55.     ;;
  56. esac
  57.  
  58. subj=
  59. while test " $subj" = " "
  60. do
  61.     echo 'Subject: ' | tr -d '\012'
  62.     read subj
  63. done
  64. echo "Subject: $subj" >>$tmp
  65. if test -r $NEWSCTL/postdefltdist
  66. then
  67.     echo "Distribution: `cat $NEWSCTL/postdefltdist`" >>$tmp
  68. fi
  69.  
  70. echo >>$tmp
  71. echo DELETE THIS LINE "(but DO NOT delete the blank line after the headers above)" >>$tmp
  72. if test -r $NEWSCTL/postdefltdist
  73. then
  74.     echo 'DELETE THIS LINE (You may want to change the "Distribution" header)' >>$tmp
  75. fi
  76. echo REPLACE THIS LINE WITH YOUR TEXT >>$tmp
  77.  
  78. trap : 2
  79. $edit $tmp
  80. trap "$term" 2
  81.  
  82. while egrep '^(DELETE|REPLACE) THIS LINE' $tmp >/dev/null
  83. do
  84.     echo 'This posting does not appear to have been edited properly.'
  85.     echo 'Abandon it [y] ? ' | tr -d '\012'
  86.     read ans
  87.     case "$ans" in
  88.     ''|y*|Y*)
  89.         rm -f $tmp
  90.         exit 0
  91.         ;;
  92.     esac
  93.  
  94.     echo 'Editing again...  Please check it over carefully.'
  95.     trap : 2
  96.     $edit $tmp
  97.     trap "$term" 2
  98. done
  99.  
  100. echo 'Posting...'
  101. inews -h <$tmp
  102.