handy "rn" macro for editing/reposting news articles with corrections

Steve Hayman sahayman at iuvax.cs.indiana.edu
Tue May 21 08:06:55 AEST 1991


Here is a handy shell script and rn macro definition that lets you
edit and repost news articles.  I like to use this when I've posted
something and notice a typo or want to make some other small correction.

Go to the article with rn, type 'E' .  You're placed in the editor looking
at a copy of your article.  Make the change you want, write it out.
The script says "Post it? [y/n]" and then "Cancel the original? [y/n]".
and will take care of posting and cancellation for you.

No warranties, etc etc.  I like it, it works for me.  Your mileage may vary.

put this in your .rnmac file

# Edit.  Edit the current article, repost, cancel the original.
E	!/u/sahayman/scripts/EditArticle %A '%i' ^M


and here is the EditArticle script.  You may need to change the
definition of 'inews' if yours isn't in /usr/lib/news/inews.


#!/bin/sh
# EditArticle
# Edit and re-post the current news message; cancel the original.
# I have an rn macro, "E", that runs this program.
# Based on an idea by ksbooth
#
# Put this in your .rnmac file:
# E	!/pathname/of/this/program %A '%i' ^M
#
# steve hayman
# sahayman at cs.indiana.edu
# 1991 05 20

# don't export PATH, we want the original PATH inside the 'vi', for instance
PATH=/usr/local/bin:/usr/ucb:/bin:/usr/bin 

TMP=/tmp/Edit.$$
trap exit 1 2 3 15
trap 'rm -f $TMP' 0

Usage="Usage: $0 article-path message-id"

inews="/usr/lib/news/inews -h"

Orig=${1?"$Usage"}
MessageID=${2?"$Usage"}

# Delete header lines that will not be relevant any more
egrep -v '^(Lines|Message-ID|Path|From|Sender|Date): ' $Orig >$TMP

${EDITOR-vi} $TMP

echo -n 'Post it? [y/n] '
read postit
case "$postit" in
""|y*|Y*)		$inews  <$TMP
		rm $TMP ;;
esac


echo -n 'Cancel the original? [y/n] '
read cancel
case "$cancel" in
""|y*|Y*)		
    
    sed -n -e '/^Newsgroups: /p' -e '/^References: /p' \
	    -e '/^Distribution: /p' \
	    -e "/^Subject: /s/.*/Subject: cmsg cancel $MessageID/p" <$Orig |
		$inews 
	;;
esac



More information about the Alt.sources mailing list