Provide infrastructure for PERL_ASYNC_CHECK() style safe signals.
[p5sagit/p5-mst-13.2.git] / x2p / find2perl.PL
index 99bb3af..4d74d06 100644 (file)
@@ -37,6 +37,7 @@ my \$perlpath = "$Config{perlpath}";
 print OUT <<'!NO!SUBS!';
 use strict;
 use vars qw/$statdone/;
+use File::Spec::Functions 'curdir';
 my $startperl = "#! $perlpath -w";
 
 #
@@ -57,7 +58,7 @@ my @roots = ();
 while ($ARGV[0] =~ /^[^-!(]/) {
     push(@roots, shift);
 }
-@roots = ('.') unless @roots;
+@roots = (curdir()) unless @roots;
 for (@roots) { $_ = &quote($_) }
 my $roots = join(', ', @roots);
 
@@ -90,7 +91,7 @@ while (@ARGV) {
         $out .= &tab . "!";
         next;
     } elsif ($_ eq 'name') {
-        $out .= &tab . '/' . &fileglob_to_re(shift) . "/";
+        $out .= &tab . '/' . &fileglob_to_re(shift) . "/s";
     } elsif ($_ eq 'perm') {
         my $onum = shift;
         $onum =~ /^-?[0-7]+$/
@@ -139,9 +140,9 @@ while (@ARGV) {
     } elsif ($_ eq 'size') {
         $_ = shift;
         my $n = 'int(((-s _) + 511) / 512)';
-        if (s/c$//) {
+        if (s/c\z//) {
             $n = 'int(-s _)';
-        } elsif (s/k$//) {
+        } elsif (s/k\z//) {
             $n = 'int(((-s _) + 1023) / 1024)';
         }
         $out .= &tab . &n($n, $_);
@@ -215,7 +216,7 @@ while (@ARGV) {
         $initfile .= "open($fh, " . &quote('> ' . $file) .
                      qq{) || die "Can't open $fh: \$!\\n";\n};
         $init{tar} = 1;
-    } elsif (/^(n?)cpio$/) {
+    } elsif (/^(n?)cpio\z/) {
         die "-$_ must have a filename argument\n" unless @ARGV;
         my $file = shift;
         my $fh = 'FH' . $file;
@@ -662,7 +663,7 @@ sub fileglob_to_re {
     my $x = shift;
     $x =~ s#([./^\$()])#\\$1#g;
     $x =~ s#([?*])#.$1#g;
-    "^$x\$";
+    "^$x\\z";
 }
 
 sub n {
@@ -674,6 +675,7 @@ sub n {
 
 sub quote {
     my $string = shift;
+    $string =~ s/\\/\\\\/g;
     $string =~ s/'/\\'/g;
     "'$string'";
 }
@@ -842,12 +844,9 @@ a distinct argument, so it may need to be surrounded by whitespace and/or
 quoted from interpretation by the shell using a backslash (just as with
 using C<find(1)>).
 
-=item C<-eval EXPR ;>
+=item C<-eval EXPR>
 
-Has the perl script eval() the EXPR.  The C<;> must be passed as
-a distinct argument, so it may need to be surrounded by whitespace and/or
-quoted from interpretation by the shell using a backslash (just as with
-using C<find(1)>).
+Has the perl script eval() the EXPR.  
 
 =item C<-ls>