[net.sources] make shell archives

mlr@ihuxn.UUCP (09/21/83)

I know that some programs to create shell archives have been
posted to the net, but I have a cheap and dirty shell script
that will take files and make a sh archivable file out of
them. I hope that you enjoy it. 

Simply strip off the above comments.

############################################################
#							   #
#			 MKSHAR				   #
#							   #
#		   Make Shell Archives			   #
#							   #
#		    Michael L. Robins			   #
#							   #
#     	           September 20, 1983			   #
#							   #
############################################################

if [ $# -lt 2 ]
then
	cat << !
	usage: mkshar outfile file1 file2 ...

	mkshar will use the named outfile and create
	a file that when invoked with sh will extract
	file1 file2 ... from outfile.ar.
	Only printable files are allowed.
!
	exit 1
fi
append=0
OUTFILE=$1.ar
if [ -w $OUTFILE ]
then
	echo "FILE ($OUTFILE) ALREADY EXISTS"
	echo "Hit <CR> to append, anything else to exit \c"
	read ans
		if [ -z $ans ]
			then
				echo "Appending to $OUTFILE"
				append=1
				continue
			else
				echo "mkshar:Terminated"
				exit 1
		fi
fi
shift
if [ $append = 0 ]
then
	cat << ! >> $OUTFILE

############################################################
#
#			$OUTFILE
#
# To extract the files from this shell archive file
# simply create a directory for this file
# and move the archive file to it
# and enter the command
#
# sh filename.ar
# 
# Do not use csh
# The files will be extracted automatically
#
############################################################

!
fi
while [ "$1"x != x ]
do

# Make sure the file is printable and not outfile.ar file

	file $1 | egrep "text" >/dev/null
	if [ $? -ne 0 ]
		then
			echo "($1) ignored: Not printable"
			shift
			continue 1
	fi
	if [ $1 = $OUTFILE ]
		then
			echo "($1) ignored: can not be archived"
			shift
			continue 1
	fi
	echo "Archiving $1 --> $OUTFILE"
	echo "echo \"Extracting $1 <-- $OUTFILE\"" >> $OUTFILE
	echo "cat << \\===$1=== > $1" >> $OUTFILE
	cat $1 >> $OUTFILE
	echo "" >> $OUTFILE
	echo "===$1===" >> $OUTFILE
	echo "# ----------" >> $OUTFILE
	shift
done
-- 
			M.L. Robins ihuxn!mlr