home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / armlinux / alpha / PARTITIONS / USR_GZ / usr / bin / newsgroups < prev    next >
Encoding:
Text File  |  1995-05-14  |  2.0 KB  |  74 lines

  1. #!/bin/sh
  2. # $Id: newsgroups.SH,v 3.0 1992/02/01 03:09:32 davison Trn $
  3. # This software is Copyright 1991 by Stan Barber. 
  4. #
  5. # Permission is hereby granted to copy, reproduce, redistribute or otherwise
  6. # use this software as long as: there is no monetary profit gained
  7. # specifically from the use or reproduction of this software, it is not
  8. # sold, rented, traded or otherwise marketed, and this copyright notice is
  9. # included prominently in any copy made. 
  10. #
  11. # The author make no claims as to the fitness or correctness of this software
  12. # for any use whatsoever, and it is provided as is. Any use of this software
  13. # is at the user's own risk. 
  14.  
  15. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  16.  
  17. : syntax: newsgroups [pattern] [pipeflag]
  18.  
  19. : System Dependencies
  20.  
  21. : You might want to change pager to a "make column" program if you have one.
  22. : On the other hand, if your kernel does paging, cat would probably do.
  23. pager="/bin/more"
  24.  
  25.  
  26. active="/tmp/active.$$"
  27. rnlib=/usr/lib/trn
  28. case $rnlib in
  29. ~*) rnlib=`/usr/lib/trn/filexp $rnlib` ;;
  30. esac
  31. nntplist=/usr/bin/nntplist
  32.  
  33. : End of system dependencies, hopefully
  34.  
  35. if $nntplist -o $active ACTIVE; then
  36.     : nothing
  37. else
  38.     exit 1
  39. fi
  40.  
  41. if test $# -ge 2 ; then
  42.     pager=/bin/cat
  43. else
  44.     /bin/echo "Completely unsubscribed newsgroups:"
  45. fi
  46.  
  47. dotdir=${DOTDIR-${HOME-$LOGDIR}}
  48. newsrc=$dotdir/.newsrc
  49.  
  50. : Throwing .newsrc into the pot twice is a lovely hack to prevent
  51. : bogus newsgroups from showing up as unsubscribed.
  52.  
  53. /bin/cat $newsrc $newsrc $active | \
  54. /usr/bin/sed -n    -e '/^options/d' \
  55.     -e '/^[     ]/d' \
  56.     -e '/^control/d' \
  57.     -e '/^to\./d' \
  58.      -e '/ x$/d' \
  59.     -e 's/^\([^ !:]*\)[ !:].*$/\1/' \
  60.     -e "/.*$1/p" | \
  61. /usr/bin/sort | /usr/bin/uniq -u | $pager
  62. /bin/rm -f $active
  63. if test $# -ge 2 ; then
  64.     exit
  65. fi
  66. /bin/echo  "[Type return to continue] \c"
  67. read tmp
  68. /bin/echo ""
  69. /bin/echo "Unsubscribed but mentioned in $newsrc:"
  70. /usr/bin/sed -n < $newsrc \
  71.     -e "/$1.*!/"'s/^\([^!]*\)!.*$/\1/p' | \
  72. /usr/bin/sort | $pager
  73.