allbery@ncoast.UUCP (Brandon S. Allbery) (01/31/88)
Comp.sources.misc: Volume 2, Issue 29 Submitted-By: The Moderator <allbery@ncoast.UUCP> Archive-Name: mkshar Comp.sources.misc: Volume 2, Issue 29 Submitted-By: The Moderator <allbery@ncoast.UUCP> Archive-Name: mkshar I have received quite a number of postings recently that weren't in "shar" format. Some of them (man pages, etc.) are quite at risk for being munched if they aren't shar'ed or if the shar program used doesn't insert a protective character in front of a line; also, it can be difficult to detect some transmission errors. This is my "shar" program. It can split shars into multiple files automatically based on size; it does overwrite protection; and it does a character count on the transmitted files to catch transmission errors. Please -- use this or some other *good* shar program (K&P "bundle" won't do, not in these days of non-UNIX machines on the net) to pack your submissions to comp.sources.misc. Or to any other source group, for that matter. If you don't, you're the one who loses. (This is shar'ed with mkshar, by the way.) #--------------------------------CUT HERE------------------------------------- #! /bin/sh # # This is a shell archive. Save this into a file, edit it # and delete all lines above this comment. Then give this # file to sh by executing the command "sh file". The files # will be extracted into the current directory owned by # you with default permissions. # # The files contained herein are: # # -rwxr-xr-x 1 allbery System 2638 Jan 30 16:43 mkshar # echo 'x - mkshar' if test -f mkshar; then echo 'shar: not overwriting mkshar'; else sed 's/^X//' << '________This_Is_The_END________' > mkshar X: #! /bin/sh X# X# shar - make a "shell archive" for net.sources, etc. X# X XFILE=/tmp/shar$$ XTFILE=/tmp/sharx$$ Xhead=shar Xsize=0 Xverbose=1 X Xcat > "$TFILE" << '________This_Is_The_End________' X#--------------------------------CUT HERE------------------------------------- X#! /bin/sh X# X# This is a shell archive. Save this into a file, edit it X# and delete all lines above this comment. Then give this X# file to sh by executing the command "sh file". The files X# will be extracted into the current directory owned by X# you with default permissions. X# X# The files contained herein are: X# X________This_Is_The_End________ Xecho "#" > "$FILE" Xwhile [ "$#" -gt 0 ]; do X case "$1" in X -v) verbose=0 X ;; X -s) size="$2" X shift X ;; X -h) head="$2" X shift X ;; X *) if [ ! -r "$1" ]; then X echo "shar: can't read $1" >&2 X else X files="$files $1" X fi X esac X shift Xdone Xif [ "$files" = "" ]; then X echo "usage: shar [-v] [-s size] [-h header] files..." >&2 X exit 1 Xfi Xif [ "$size" -ne 0 ]; then X count=1 Xelse X count= Xfi Xif [ "$verbose" = 1 ]; then X echo "o - $head$count" Xfi Xfor file in $files; do X f=`basename $file` X case "$verbose" in X 1) echo "a - $f" X esac X if [ "$size" -ne 0 ]; then X set -- `ls -l "$FILE"` X csize=$5 X set -- `ls -l "$file"` X if [ "$size" -lt `expr "$csize" + $5` ]; then X echo "exit 0" >> "$FILE" X cat "$TFILE" "$FILE" > "$head$count" X cat > "$TFILE" << '________This_Is_The_End________' X#--------------------------------CUT HERE------------------------------------- X#! /bin/sh X# X# This is a shell archive. Save this into a file, edit it X# and delete all lines above this comment. Then give this X# file to sh by executing the command "sh file". The files X# will be extracted into the current directory owned by X# you with default permissions. X# X# The files contained herein are: X# X________This_Is_The_End________ X echo "#" > "$FILE" X count=`expr $count + 1` X if [ "$verbose" = 1 ]; then X echo "o - $head$count" X fi X fi X fi X echo '# \c' >> "$TFILE" X ls -l "$file" >> "$TFILE" X wcl=`wc -l < $f | sed 's/^ *//'` X echo "echo 'x - $f'" >> "$FILE" X echo "if test -f $f; then echo 'shar: not overwriting $f'; else" >> "$FILE" X echo "sed 's/^X//' << '________This_Is_The_END________' > $f" >> "$FILE" X sed 's/^/X/' < "$file" >> "$FILE" X echo '________This_Is_The_END________' >> "$FILE" X echo 'if test `wc -l < '"$f"'` -ne '"$wcl"'; then' >> "$FILE" X echo " echo 'shar: $f was damaged during transit (should have been $wcl bytes)'" >> "$FILE" X echo "fi" >> "$FILE" X echo "fi ; : end of overwriting check" >> "$FILE" Xdone Xecho "exit 0" >> "$FILE" Xcat "$TFILE" "$FILE" > "$head$count" Xrm "$FILE" "$TFILE" ________This_Is_The_END________ if test `wc -l < mkshar` -ne 103; then echo 'shar: mkshar was damaged during transit (should have been 103 bytes)' fi fi ; : end of overwriting check exit 0