[alt.sources] latest version of rn cancel command

maart@cs.vu.nl (Maarten Litmaath) (01/19/90)

In article <5026@hydra.gatech.EDU>,
	eb18@prism.gatech.EDU (BOECKLER,ERWIN H O) writes:
\how are postings cancelled if they've already been read in one's account?

Cancelling a posted article means posting a cancel message.  From within
`rn' you select the article and type `C'; however, on most rn installations
this scenario doesn't work - despite what the manual says - due to a bug.
BUT!  Below's an rn macro + shell script to cancel articles with the `inews'
program.
If you use the `nn' newsreader (far more user-friendly, IMHO), `C' will work.

Rn cancel macro stuff follows.
Put the following rn macro (between the `cut lines') in the file `.rnmac' in
the directory containing your `.newsrc'.

----------8<----------8<----------8<----------8<----------8<----------
C	%(%m=[ap]?!cancel %A^J:C)
----------8<----------8<----------8<----------8<----------8<----------

Put the following `cancel' command somewhere in your PATH.
Configure the `INEWS' variable to contain the correct path to inews.
If your UNIX is a System-V variant, change the `#!/bin/sh' line into `:'.
If your echo is SYSV and some Message-ID contains a `\' C escape sequence,
you're out of luck. :-(

----------8<----------8<----------8<----------8<----------8<----------
#!/bin/sh
# @(#)cancel 1.2 90/01/13 Maarten Litmaath
# cancel <path-to-article>

INEWS=/usr/lib/news/inews
# figure out if echo is BSD or SYSV
test "x`echo -n x`" = xx && n=-n c= || n= c=\\c

test $# = 1 || {
	echo "Usage: `basename $0` <path-to-article>" >&2
	exit 1
}

NEWSGROUPS=`sed -n -e '/^Newsgroups: /{' -e 's///' -e p -e q -e '}' "$1"`
IDENT=`sed -n -e '/^Message-ID: /{' -e 's///' -e p -e q -e '}' "$1"`
DISTRIBUTION=`
	sed -n -e '/^$/q' -e '/^Distribution: /{' -e s/// -e p -e q -e '}' "$1"
`
test x"$DISTRIBUTION" = x && DISTRIBUTION=world

echo "Confirm cancel of article $IDENT in"
echo $n "$NEWSGROUPS: [ny] $c"
read ans
test x"$ans" = xy && {
	echo "Newsgroups: $NEWSGROUPS"
	echo "Subject: cmsg cancel $IDENT"
	echo "Control: cancel $IDENT"
	echo "Distribution: $DISTRIBUTION"
	echo ""
} | $INEWS -h
-- 
  What do the following have in common:  access(2), SysV echo, O_NONDELAY?  |
  Maarten Litmaath @ VU Amsterdam:  maart@cs.vu.nl,  uunet!mcsun!botter!maart