[comp.sources.d] Suggestion for shar file posting

creps@silver.bacs.indiana.edu (Steve Creps) (01/24/88)

   After having unshar'ed many programs, one thing I've noticed that
causes extra work is having to edit the file before unshar'ing it.
It would be nice if I could "w" it from rn, then unshar it without
having to do any editing.
   Now my idea: suppose the moderators of sources groups, when putting
the description/comment at the beginning of the file, could prefix these
lines with a pound sign? This would have the effect of making these
comments literally into comments, and sh would just ignore these lines
if they're not removed. This shouldn't take more than about a dozen extra
keystrokes for the moderators, just one keystroke per comment line.
   It would be much appreciated.

-	-	-	-	-	-	-	-	-
Steve Creps on the VAX 8650 running Ultrix 2.0-1 at Indiana University.
creps@silver.bacs.indiana.edu, ...iuvax!silver!creps, creps@iubacs.bitnet
"F-14 Tomcat! There IS no substitute."

mer6g@uvaarpa.virginia.edu (Marc E. Rouleau) (01/24/88)

In article <661@silver.bacs.indiana.edu> creps@silver.UUCP (Steve Creps) writes:
>
> [ a suggestion about making shar file postings easily unpackable by prepending
> a # sign to each description/comment line at the beginning ]
>

If you want to unpack the file "someprog.sh", for example,

	sed -n '/^#/,$p' someprog.sh | /bin/sh

will do the trick.  If you want to unpack a bunch of files, you can use the
following:

	for i in someprog??.sh   # for example
	do
		sed -n '/^#/,$p' $i | /bin/sh
	done

mlandau@bbn.com (Matt Landau) (01/25/88)

In comp.sources.d, creps@silver.UUCP (Steve Creps) writes:
>   After having unshar'ed many programs, one thing I've noticed that
>causes extra work is having to edit the file before unshar'ing it.
>It would be nice if I could "w" it from rn, then unshar it without
>having to do any editing.

Rich $alz, the moderator of comp.sources.unix, has the best set of tools
for packing and unpacking shar files I've yet seen.  One of the programs in
the toolkit is "unshar" -- unshar looks for a line that contains a "cut
here" string and then unpacks the remainder of the file.  It takes a number
of flags to control options such as the directory into which the files
should be unshared.  The bottom line is that you can often just pipe
articles from rn into unshar -d <dir> and have the right thing happen.

You can pick up r$'s tools from your friendly neighborhood comp.sources.unix 
archive site.
--
 Matt Landau			Waiting for a flash of enlightenment
 mlandau@bbn.com			  in all this blood and thunder

preston@felix.UUCP (Preston Bannister) (01/27/88)

In article <661@silver.bacs.indiana.edu> creps@silver.UUCP (Steve Creps) writes:

>   After having unshar'ed many programs, one thing I've noticed that
>causes extra work is having to edit the file before unshar'ing it.
>It would be nice if I could "w" it from rn, then unshar it without
>having to do any editing.
>....

Someone posted a useful little shell script for automatically unpacking
articles containing shar scripts a year or so ago.  I find it extremely
useful.  Usually from 'rn' I can type '|rnget newdir' and the script
will create 'newdir' if necessary and unshar the article into
'newdir'.  

The script is short...

------------- cut here -------------
#!/bin/sh
#
# NAME
#	rnget - get a shar archive from rn output.
#
# SYNOPSIS
#	rnget [-p pattern] [-r file] [f prog] [ directory ]
#
# DESCRIPTION
#	Rnget changes to the given directory (if given) and then
#	reads its standard input and searches for the given pattern
#	(default to "[#:]") at the beginning of a line and passes that
#	and all subsequent lines to the filter, defaulting to the
#	bourne shell, for processing.  Lines prior to the first line
#	matching the pattern are saved to the file, default READ_ME.
#
#	The idea is that the input is a shar file contained inside
#	of a news article, with a scan done before hand for the
#	beginning of the shar.  For shars that don't begin with '#'
#	or ':' -p can be used to specify something else.
#
#	Note:  If the directory does not exist, it is created.
prog="$0"
usage="usage: $prog [-p pattern] [-r file ] [-f prog] [directory]"
pattern="/^[:#]/"
readme="READ_ME"
filter=/bin/sh
while [ $# -gt 0 ]; do
	if [ flag$1 = flag-p ]; then
		shift
		if [ $# -lt 1 ]; then
			echo $usage
			exit 1
		fi
		pattern="/^$1/"
		echo "$prog: Trigger pattern is $pattern."
		shift
	elif [ flag$1 = flag-f ]; then
		shift
		if [ $# -lt 1 ]; then
			echo $usage
			exit 1
		fi
		filter=$1
		echo "$prog: Filter is $filter."
		shift
	elif [ flag$1 = flag-r ]; then
		shift
		if [ $# -lt 1 ]; then
			echo $usage
			exit 1
		fi
		readme="$1"
		echo "$prog: Header information is in $readme."
		shift
	else		# got a directory
		if [ -f $1 ]; then
			echo "$prog: $1 is not a directory!!"
			exit 2
		fi
		if [ ! -d $1 ]; then
			mkdir $1 > /dev/null 2>&1
			if [ $? -ne 0 ]; then
				echo "$prog: Could not create directory $1."
				exit 2
			fi
		fi
		cd $1
		echo "$prog: Directory is $1."
		shift
	fi
done
# rm -f $readme
awk "
BEGIN	{
	skip = 1; copy = 2;
	state = skip;
}
state == skip && $pattern	{
	state = copy;
}
state == skip	{
	print \$0 >> \"$readme\";
}
state == copy	{
	print \$0
}" | $filter
if [ $? -ne 0 ]; then
	echo "$prog:  error in writing to shell"
fi

--
Preston L. Bannister
USENET	   :	ucbvax!trwrb!felix!preston
BIX	   :	plb
CompuServe :	71350,3505
GEnie      :	p.bannister

rick@pcrat.UUCP (Rick Richardson) (01/27/88)

If you can't get Rich's unshar, this shell will suffice.  Just
	|unshar
or, more likely:
	|unshar -d /tmp/newgame


#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	unshar
# This archive created: Wed Jan 27 09:16:08 1988
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'unshar'
then
	echo shar: "will not over-write existing file 'unshar'"
else
cat << \SHAR_EOF > 'unshar'
files=
dir=.
while [ $# != 0 ]
do
	case $1 in 
	-d)	shift; dir=$1;;
	*)	files="$files $1";;
	esac
	shift
done
if [ "Q$dir" != Q. ]
then
	mkdir $dir
fi
if [ "Q$files" = Q ]
then
	sed '1,/^[#:]/d' | (\cd $dir; sh)
else
	for i in $files
	do
		echo $i
		sed '1,/^[#:]/d' <$i | (\cd $dir; sh)
	done
fi
SHAR_EOF
fi
exit 0
#	End of shell archive
-- 
	Rick Richardson, President, PC Research, Inc.
(201) 542-3734 (voice, nights)   OR   (201) 834-1378 (voice, days)
		uunet!pcrat!rick

cutter@cutsys.UUCP (Bernie Hoffstadt ) (01/29/88)

In article <661@silver.bacs.indiana.edu> creps@silver.UUCP (Steve Creps) writes:
>
>   After having unshar'ed many programs, one thing I've noticed that
>causes extra work is having to edit the file before unshar'ing it.
>It would be nice if I could "w" it from rn, then unshar it without
>having to do any editing.


	It's really not a bad idea, and should probably be done in any
case, but it would seem that Steve hasn't heard of the unshar utility
(by Michael Mauldin).  This nice little tool is usually smart enough to
pick out the goodies from just about any mail or news file.  Since I
usually s)ave rather than w)rite (the header info is sometimes useful),
the commenting wouldn't do me any good anyway.  If you can't locate the
sources, I have them, tho' my version is pretty old, 1/29/85, and there
might be something newer out.

-- 
Bernie Hoffstadt   (503) 752-5929 *** Internet: cutter%cutsys.UUCP@CS.ORST.EDU
1437 N.W. 9th st.   -or- 753-1646 ***   -or-    cutter@jacobs.CS.ORST.EDU
Corvallis, Oregon  97330  ****** UUCP: {tektronix,hp-pcd}!orstcs!cutsys!cutter 

?) Seaman) (01/30/88)

In article <2127@tekred.TEK.COM>, billr@tekred.TEK.COM (Bill Randle) writes:
< In article creps@silver.UUCP (Steve Creps) writes:
< >   Now my idea: suppose the moderators of sources groups, when putting
< >the description/comment at the beginning of the file, could prefix these
< >lines with a pound sign? [ ... ]
< 
< What I like to use is the "unshar" program from Rich Salz (I beleive
< there are others as well).  This program saves the header info in a
< seperate file then passes the real meat on to "sh".
< 
< 	-Bill Randle

That sounds good to me too, but I couldn't compile Rich's unshar on my
3B15, since it contains a large amount of 4.2 BSD dependent code.  Does
anyone have a version running under System V?

-- 
Chris Seaman            |    o\  /o
crs@cpsc6a.att.com <or> |      ||         See "Attack of the Killer Smiley"!
..!ihnp4!cpsc6a!crs     |   \vvvvvv/     Coming Soon to a newsgroup near you!
                        |    \____/ 

osm@metavax.UUCP (Owen Scott Medd) (02/03/88)

In article <450@cpsc6b.cpsc6a.att.com> crs@cpsc6b.cpsc6a.att.com
(Chris Seaman) writes:
>< What I like to use is the "unshar" program from Rich Salz (I beleive
>< there are others as well).  This program saves the header info in a
>< seperate file then passes the real meat on to "sh".
>< 
>< 	-Bill Randle
>That sounds good to me too, but I couldn't compile Rich's unshar on my
>3B15, since it contains a large amount of 4.2 BSD dependent code.  Does
>anyone have a version running under System V?

I've ported Rich's code to the Microsoft C compiler (version 5.0), with
very little problems.  I needed a copy of the directory handling routines
(I grabbed the ones that pdtar used for MSDOS, other versions are available
from Doug Gwyn), but otherwise the ANSI/SysV routines in MSC seemed to
do the trick.

If anyone is interested in getting a copy of this, I can e-mail the
package to them.

Owen
-- 
USMail:   Meta Systems, Ltd.  315 East Eisenhower Parkway, Ann Arbor, MI  48108
Phone:	  +1 313 663 6027
UUCP:	  uunet!umix!metavax!osm
Internet: osm%metavax.uucp@umix.cc.umich.edu