Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!bfmny0!tneff From: tneff@bfmny0.UUCP (Tom Neff) Newsgroups: alt.sources Subject: Simple unshar script Summary: works as filter, strips article headers, allows dest directory Message-ID: <14459@bfmny0.UUCP> Date: 10 Jul 89 18:15:09 GMT Reply-To: tneff@bfmny0.UU.NET (Tom Neff) Followup-To: alt.sources.d Organization: ^ Lines: 67 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 [ | ] 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