#!/usr/local/bin/perl eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' if 0; # not running under some shell # public domain code by salzr@certo.com # (formerly rsalz@osf.org, rsalz@bbn.com, mirror!rs) require 'getopts.pl'; sub Usage { print STDERR "@_.\nUsage: $av0 files...\n"; exit(1); } binmode STDOUT; # Parse JCL. $av0 = $0; $av0 =~ s@.*/@@; &Getopts("") || &Usage("Usage error"); # Do work. $dirty = 0; ARGUMENT: foreach $f ( @ARGV ) { if ( ! open(FH, $f) ) { warn "$av0: can't open $f, $!\n"; next ARGUMENT; } binmode FH; if ( $dirty++ == 0 ) { print '# --cut here-- #! /bin/sh # To unshar, remove everything before the "cut here" line # and feed the result to /bin/sh ' } if (-B $f) { $mode = (stat $f)[2]; $mode = (join '', 0, ($mode&0700)>>6, ($mode&0070)>>3, ($mode&0007)); print "sed -e 's/^X//' | uudecode <<'FUNKY_STUFF'\n"; print "begin $mode $f\n"; print pack 'u', $block while read FH, $block, 45; print "end\n"; print "FUNKY_STUFF\n"; } else { print "sed -e 's/^X//' >$f <<'FUNKY_STUFF'\n"; print 'X', $_ while ( ); print "FUNKY_STUFF\n"; } close(FH); } &Usage("No input files") unless $dirty; exit(0); __END__ =head1 NAME shar - create a shell archive of files =head1 SYNOPSIS B file [files...] =head1 DESCRIPTION B creates a shell archive of the I on the command line. The shell archive is a shell script, and executing it will recreate the I. Directories are I recreated. =head1 SEE ALSO B =head1 AUTHOR Rich Salz | salzr@certo.com | rsalz@osf.org | rsalz@bbn.com =head1 COPYRIGHT This code is released to the public domain. =cut