Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!lll-winken!sun-barr!newstop!texsun!convex!convex.convex.com!felps From: felps@convex.com (Robert Felps) Newsgroups: comp.unix.questions Subject: Re: Looking for SYS V r3 shar/unshar Message-ID: Date: 17 Dec 90 13:24:23 GMT References: <104414@cc.utah.edu> Sender: news@convex.com Lines: 179 In <104414@cc.utah.edu> SJBACKUS@cc.utah.edu writes: >Does anyone know of a version of shar/unshar for SYS V r 3? Here is a Bourne shell script [un]shar and the man page. It's not the lastest [un]shar.c, but it works. --------------------------------- cut here ---------------------------------- #!/bin/sh # @(#) shar 1.0 - create a shell archive file # AUTHOR: Robert Felps # DATE : Aug 27 16:23:50 CDT 1989 # SYNTAX: shar files # OPTS : # ARGS : files - list of files to be archived # FILES : # UPDATED BY: # ON : # CHANGES : # # vi/ex: set ts=4 # # check for existing $SHAR_FILE # SHAR_FILE=sharfile TMP=/tmp/shar.$$ case "$0" in *unshar*) if [ $# -gt 0 ] then while [ -n "$1" ] do if [ -f "$1" ] then awk '/^#!/,/^SOME-NON-EXISTENT-STR/ { print }' $1 > $TMP sh $TMP rm -f $TMP else echo "No file $1 to unarchive!" EXIT=9 fi shift done else if [ -f "$SHAR_FILE" ] then sh "$SHAR_FILE" else echo "No file($1 or $SHAR_FILE) to unarchive!" exit 1 fi fi exit $EXIT ;; *shar*) while [ -n "$1" ] do case "$1" in -o) shift ; SHAR_FILE=$1 ;; -o*) SHAR_FILE=`expr $1 : '..\(.*\)'` ;; *) break ;; esac shift done ;; esac if [ -f "$SHAR_FILE" ] then echo "Sorry, will not overwrite existing \"$SHAR_FILE\"" exit 2 fi if [ $# -eq 0 ] then echo "Must specify files to archive!" exit 3 fi # create the header in the $SHAR_FILE cat > $SHAR_FILE <<\HDR_EOF #!/bin/sh # This is a SHell ARchive(shar), 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 the files: # # List of Archived Files: # HDR_EOF # list the files to be archived for A do if [ -d "$A" ] then echo "# $A (dir)" >> $SHAR_FILE else echo "# $A" >> $SHAR_FILE fi done echo "#" >> $SHAR_FILE echo "# This archive created: `date`" >> $SHAR_FILE echo "#" >> $SHAR_FILE # Do the archiving for A do if [ -d "$A" ] then cat >> $SHAR_FILE <> $SHAR_FILE < $A EXTRACT_EOF # ARCHIVE THE FILE! sed 's/^/X\./' $A >> $SHAR_FILE # insert extracting script for end of archived file cat >> $SHAR_FILE <