#!/usr/bin/perl -n
# This is a dumb unshar script, for systems that don't have  any  shar
# package installed.  It takes a list of files on the command line, or
# reads from standard input.  When we encounter a line  starting  with
# '#!',  the  tail is fed to /bin/sh.  We look for "exit" commands and
# turn off processing; a subsequent "#!" will start a new  /bin/sh  to
# eat  the  next  chunk.   Thus  you can catenate shar files, and this
# script will unpack them correctly.  (I originally tried this as a sh
# script, but it was actually doable in perl.  ;-)

if ($got) {	# Inside a shar section.
	print C;
	if (/^exit\s/) {	# end of shar section.
		$got = 0;
		close C;
	}
} elsif (/^#!/) {	# Start of shar section.
	++$got;
	open (C,"|/bin/sh") || die "Can't run /bin/sh [$!]\n";
}
