Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shar: support directory args from find #304

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions bin/shar
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@ binmode STDOUT;

my $dirty = 0;
ARGUMENT: for my $f ( @ARGV ) {
unless ($dirty) {
print '# --cut here--
# To extract, remove everything before the "cut here" line
# and run the command "sh file".
';
$dirty = 1;
}
if (-d $f) {
warn "$Program: '$f' is a directory\n";
print "echo x - $f/\n";
print "mkdir -p $f\n";
next ARGUMENT;
}
unless (open FH, '<', $f) {
Expand All @@ -45,13 +53,6 @@ ARGUMENT: for my $f ( @ARGV ) {
}
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
'
}
print "echo x - $f\n";
if (-B $f) {
my $mode = (stat $f)[2];
Expand Down Expand Up @@ -91,7 +92,8 @@ B<shar> reads input files and writes a shell archive to standard output.
The shell archive is a shell script, and executing it will recreate the I<files>.
File permissions are not preserved for archived files.
Extracted files are created with the default file permissions and owner.
Directories are I<not> recreated.
Directories will be recreated, but directory arguments must be provided before
the files they contain.

=head1 SEE ALSO

Expand Down