Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/5/84; site uwmacc.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!wjh12!harvard!seismo!uwvax!uwmacc!bllklly
From: bllklly@uwmacc.UUCP (Bill Kelly)
Newsgroups: net.news.b
Subject: Re: rn bug #17--important for usenet admin types
Message-ID: <417@uwmacc.UUCP>
Date: Thu, 25-Oct-84 10:08:12 EDT
Article-I.D.: uwmacc.417
Posted: Thu Oct 25 10:08:12 1984
Date-Received: Fri, 26-Oct-84 09:34:40 EDT
References: <1397@sdcrdcf.UUCP> <107@chalmers.UUCP>
Reply-To: bllklly@maccunix.UUCP (Bill Kelly)
Organization: UWisconsin-Madison Academic Comp Center
Lines: 105
Summary: 

>What about a shell script that takes a bug fix message from Larry, unpacks
>it, installs the patches using rcs, archives the fixes and cleans up? :-)

Maybe it's a little silly, but I already wrote a script to unpack sharred source
and bug fixes from the net.  It's far from perfect in recognizing the
beginning of the script, but it works on 80% or more of the stuff we get,
including Larry's postings.  You need to change the setting of LIB to tell
where you stored the unshar.awk file.  There are some other minor
annoyances, (the worst is that if the article contains a shell script that
isn't sharred, it will run the shell script itself, so there is a potential
danger) but I find it helpful.  (P.S.  It peels off everything before
the actual script and adds it to file COMMENTS in case you're interested in
what the poster had to say about it.)  No claims for portability -- it uses
csh because I'm more familiar with it than sh.

: This is a shar archieve.  Extract with sh, not csh.
: The rest of this file will extract:
: unshar unshar.awk
echo extracting - unshar
sed 's/^X//' > unshar << '/*EOF'
X#!/bin/csh
Xset LIB=~bllklly/util
Xif (! $#argv) then
X	echo -n "File to un-shar? "
X	set fname=$<
Xelse
X	set fname=$1
Xendif
Xset numfiles=$#fname
Xforeach f ($fname)
X    echo "echo awk did not succeed." > /tmp/UNSH$$
X    awk -f $LIB/unshar.awk $f > /tmp/UNSH$$
X    if ( -z /tmp/UNSH$$ ) then
X    	echo awk did not succeed.
X    else
X    	echo "OK, made the shell input, now run ${f}:"
X    	sh /tmp/UNSH$$
X    endif
X    if ( $status && $status != 9876 ) then
X	echo "Errors running /tmp/UNSH$$, will leave it for your perusal"
X    else
X        echo "Done with unshar."
X        rm /tmp/UNSH$$
X        rm -i $f
X    endif
X    @ numfiles = $numfiles - 1
X    if ($numfiles > 0) then
X        echo -n "Hit return to continue. "
X        set junk=$<
X    endif
Xend
/*EOF
echo extracting - unshar.awk
sed 's/^X//' > unshar.awk << '/*EOF'
X# When comments or shell is true, print everything.
X# Until comments or shell is true, print just interesting stuff
X# from the mail header, like From and Subject.
X# "cut" tells whether it looks like a CUT HERE type of file
X# "shell" tells whether a recognizable shar start was found
XBEGIN {shell=0; comments=0; cut=0; print "cat >> COMMENTS << EOF"}
X/^[a-zA-Z].*</ {cut=1}
X/\/ {cut=1}
X/Subject/ {print; next}
X/From/ {print; next}
X/Organization/ {print; next}
X{if (shell || comments) print; else next}
XEND {if (!shell) {
X	if (comments) {
X		print "EOF"
X		print "rm MORECOMMENTS"
X	}
X	print "echo This was not a shar type script!"
X	if (cut) print "echo Looked like it said CUT HERE tho"
X	print "exit 9876"
X     }
X}
/*EOF
-- 

Bill Kelly
{allegra, ihnp4, seismo}!uwvax!uwmacc!bllklly
1210 West Dayton St/U Wisconsin Madison/Mad WI 53706

"Life's like a jigsaw...you get the straight bits, but there's plenty
 missing in the middle." -- Xtc