Simple unshar script
Tom Neff
tneff at bfmny0.UUCP
Tue Jul 11 04:15:09 AEST 1989
More source in our Stamp Out Chatter campaign. I use this as something
to pipe 'rn' shar articles into. There are fancier things with perl
and custom programs, but I either don't have them or can't understand
them :-)
--- y'all cut heah --- y'all cut heah --- y'all cut heah --- y'all cut heah
#! /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: Mon Jul 10 14:07:01 1989
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'unshar'
then
echo shar: "will not over-write existing file 'unshar'"
else
sed 's/^X//' << \SHAR_EOF > 'unshar'
X: '@(#)unshar 1.1'
X
X# PUBLIC DOMAIN - HACK AWAY
X
X# Unpack a SHAR archive, with optional leading and trailing garbage
X
X# This script uses sed(1) and sh(1) to unpack a shell archive from
X# the standard input or a file argument. Results are written to
X# the current directory unless you supply a directory name as the
X# first argument.
X
X# Usage: unshar [ <filename>|<dirname> ]
X
X# Since unshar can be a filter, it's nice with rn or mailers.
X
XTmpsh=/tmp/US$$.sh # change this if needed
X
Xif [ $1 ] && [ -d $1 ]
Xthen
X cd $1 || exit 1
X set ""
Xfi
X
Xsed '/^#/,$!d' $1 > $Tmpsh
Xif [ $? -gt 0 ]
Xthen
X echo "$0: sed error!"
X exit 2
Xfi
X
Xsh $Tmpsh
Xif [ $? -gt 0 ]
Xthen
X echo "$0: sh error!"
X exit 3
Xfi
X
Xrm -f $Tmpsh
Xsync
SHAR_EOF
chmod +x 'unshar'
fi
exit 0
# End of shell archive
--
"My God, Thiokol, when do you \\ Tom Neff
want me to launch -- next April?" \\ uunet!bfmny0!tneff
More information about the Alt.sources
mailing list