X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=x2p%2Ffind2perl.PL;h=5add931397aa4741b1e0e3f3180523506c2a66f6;hb=102b13d314016f7ec14c00406088a88475fe52db;hp=4c5df7da94b3d2741c49c8daae8ff1959842e203;hpb=fb8eeed8cb12743f5c60d9d4d0405913307f1b9b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/x2p/find2perl.PL b/x2p/find2perl.PL index 4c5df7d..5add931 100644 --- a/x2p/find2perl.PL +++ b/x2p/find2perl.PL @@ -80,6 +80,7 @@ my $out = ''; my $declaresubs = "sub wanted;\n"; my %init = (); my ($follow_in_effect,$Skip_And) = (0,0); +my $print_needed = 1; while (@ARGV) { $_ = shift; @@ -98,8 +99,10 @@ while (@ARGV) { } 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]+$/ @@ -117,8 +120,10 @@ while (@ARGV) { $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; @@ -183,6 +188,7 @@ while (@ARGV) { $declaresubs .= "sub doexec (\$\@);\n"; $init{doexec} = 1; } + $print_needed = 0; } elsif ($_ eq 'ok') { my @cmd = (); while (@ARGV && $ARGV[0] ne ';') @@ -191,9 +197,10 @@ while (@ARGV) { $out .= tab; for (@cmd) { s/'/\\'/g } - { local $" = "','"; $out .= "doexec(0, '@cmd')"; } + { 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') { @@ -210,6 +217,7 @@ while (@ARGV) { my $prog = shift; $prog =~ s/'/\\'/g; $out .= tab . "eval {$prog}"; + $print_needed = 0; } elsif ($_ eq 'depth') { $find = 'finddepth'; next; @@ -217,6 +225,7 @@ while (@ARGV) { $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; @@ -258,6 +267,12 @@ while (@ARGV) { } } +if ($print_needed) { + my $t = tab; + if ($t !~ /&&\s*$/) { $t .= '&& ' } + $out .= "\n" . $t . 'print("$name\n")'; +} + print <<"END"; $startperl @@ -280,6 +295,14 @@ $declaresubs 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); @@ -348,9 +371,6 @@ END 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 @@ -765,6 +785,18 @@ File name matches specified GLOB wildcard pattern. GLOB may need to be quoted to avoid interpretation by the shell (just as with using C). +=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. @@ -810,7 +842,7 @@ True if (hard) link count of file matches N (see below). True if file's size matches N (see below) N is normally counted in 512-byte blocks, but a suffix of "c" specifies that size should be -counted in characters (bytes) and a suffix of "k" specifes that +counted in characters (bytes) and a suffix of "k" specifies that size should be counted in 1024-byte blocks. =item C<-atime N> @@ -833,7 +865,9 @@ True if last-modified time of file matches N. =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>