my $declaresubs = "sub wanted;\n";
my %init = ();
my ($follow_in_effect,$Skip_And) = (0,0);
+my $print_needed = 1;
while (@ARGV) {
$_ = shift;
} elsif ($_ eq '!') {
$out .= tab . "!";
next;
- } elsif ($_ eq 'name') {
- $out .= tab . '/' . fileglob_to_re(shift) . "/s";
+ } elsif (/^(i)?name$/) {
+ $out .= tab . '/' . fileglob_to_re(shift) . "/s$1";
+ } elsif (/^(i)?path$/) {
+ $out .= tab . '$File::Find::name =~ /' . fileglob_to_re(shift) . "/s$1";
} elsif ($_ eq 'perm') {
my $onum = shift;
$onum =~ /^-?[0-7]+$/
$out .= tab . "-$filetest _";
} elsif ($_ eq 'print') {
$out .= tab . 'print("$name\n")';
+ $print_needed = 0;
} elsif ($_ eq 'print0') {
$out .= tab . 'print("$name\0")';
+ $print_needed = 0;
} elsif ($_ eq 'fstype') {
my $type = shift;
$out .= tab;
$declaresubs .= "sub doexec (\$\@);\n";
$init{doexec} = 1;
}
+ $print_needed = 0;
} elsif ($_ eq 'ok') {
my @cmd = ();
while (@ARGV && $ARGV[0] ne ';')
{ local $" = "','"; $out .= "doexec(1, '@cmd')"; }
$declaresubs .= "sub doexec (\$\@);\n";
$init{doexec} = 1;
+ $print_needed = 0;
} elsif ($_ eq 'prune') {
$out .= tab . '($File::Find::prune = 1)';
} elsif ($_ eq 'xdev') {
my $prog = shift;
$prog =~ s/'/\\'/g;
$out .= tab . "eval {$prog}";
+ $print_needed = 0;
} elsif ($_ eq 'depth') {
$find = 'finddepth';
next;
$out .= tab . "ls";
$declaresubs .= "sub ls ();\n";
$init{ls} = 1;
+ $print_needed = 0;
} elsif ($_ eq 'tar') {
die "-tar must have a filename argument\n" unless @ARGV;
my $file = shift;
}
}
+if ($print_needed) {
+ my $t = tab;
+ if ($t !~ /&&\s*$/) { $t .= '&& ' }
+ $out .= "\n" . $t . 'print("$name\n")';
+}
+
print <<"END";
$startperl
END
+if (exists $init{doexec}) {
+ print <<'END';
+use Cwd ();
+my $cwd = Cwd::cwd();
+
+END
+}
+
if (exists $init{ls}) {
print <<'END';
my @rwx = qw(--- --x -w- -wx r-- r-x rw- rwx);
if (exists $init{doexec}) {
print <<'END';
-use Cwd ();
-my $cwd = Cwd::cwd();
-
sub doexec ($@) {
my $ok = shift;
my @command = @_; # copy so we don't try to s/// aliases to constants
quoted to avoid interpretation by the shell (just as with using
C<find(1)>).
+=item C<-iname GLOB>
+
+Like C<-name>, but the match is case insensitive.
+
+=item C<-path GLOB>
+
+Path name matches specified GLOB wildcard pattern.
+
+=item C<-ipath GLOB>
+
+Like C<-path>, but the match is case insensitive.
+
=item C<-perm PERM>
Low-order 9 bits of permission match octal value PERM.
=item C<-print>
-Print out path of file (always true).
+Print out path of file (always true). If none of C<-exec>, C<-ls>,
+C<-print0>, or C<-ok> is specified, then C<-print> will be added
+implicitly.
=item C<-print0>