Installer: Early check whether the installation directory is writable
[msysgit.git] / bin / find2perl
blob44f4ab6d4a3633a27e1b54e5406821385643b9c2
1 #!/usr/bin/perl
2 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
3 if $running_under_some_shell;
4 (my $perlpath = <<'/../') =~ s/\s*\z//;
5 /usr/bin/perl
6 /../
7 use strict;
8 use vars qw/$statdone/;
9 use File::Spec::Functions 'curdir';
10 my $startperl = "#! $perlpath -w";
13 # Modified September 26, 1993 to provide proper handling of years after 1999
14 # Tom Link <tml+@pitt.edu>
15 # University of Pittsburgh
17 # Modified April 7, 1998 with nasty hacks to implement the troublesome -follow
18 # Billy Constantine <wdconsta@cs.adelaide.edu.au> <billy@smug.adelaide.edu.au>
19 # University of Adelaide, Adelaide, South Australia
21 # Modified 1999-06-10, 1999-07-07 to migrate to cleaner perl5 usage
22 # Ken Pizzini <ken@halcyon.com>
24 # Modified 2000-01-28 to use the 'follow' option of File::Find
26 sub tab ();
27 sub n ($$);
28 sub fileglob_to_re ($);
29 sub quote ($);
31 my @roots = ();
32 while ($ARGV[0] =~ /^[^-!(]/) {
33 push(@roots, shift);
35 @roots = (curdir()) unless @roots;
36 for (@roots) { $_ = quote($_) }
37 my $roots = join(', ', @roots);
39 my $find = "find";
40 my $indent_depth = 1;
41 my $stat = 'lstat';
42 my $decl = '';
43 my $flushall = '';
44 my $initfile = '';
45 my $initnewer = '';
46 my $out = '';
47 my $declaresubs = "sub wanted;\n";
48 my %init = ();
49 my ($follow_in_effect,$Skip_And) = (0,0);
50 my $print_needed = 1;
52 while (@ARGV) {
53 $_ = shift;
54 s/^-// || /^[()!]/ || die "Unrecognized switch: $_\n";
55 if ($_ eq '(') {
56 $out .= tab . "(\n";
57 $indent_depth++;
58 next;
59 } elsif ($_ eq ')') {
60 --$indent_depth;
61 $out .= tab . ")";
62 } elsif ($_ eq 'follow') {
63 $follow_in_effect= 1;
64 $stat = 'stat';
65 $Skip_And= 1;
66 } elsif ($_ eq '!') {
67 $out .= tab . "!";
68 next;
69 } elsif (/^(i)?name$/) {
70 $out .= tab . '/' . fileglob_to_re(shift) . "/s$1";
71 } elsif (/^(i)?path$/) {
72 $out .= tab . '$File::Find::name =~ /' . fileglob_to_re(shift) . "/s$1";
73 } elsif ($_ eq 'perm') {
74 my $onum = shift;
75 $onum =~ /^-?[0-7]+$/
76 || die "Malformed -perm argument: $onum\n";
77 $out .= tab;
78 if ($onum =~ s/^-//) {
79 $onum = sprintf("0%o", oct($onum) & 07777);
80 $out .= "((\$mode & $onum) == $onum)";
81 } else {
82 $onum =~ s/^0*/0/;
83 $out .= "((\$mode & 0777) == $onum)";
85 } elsif ($_ eq 'type') {
86 (my $filetest = shift) =~ tr/s/S/;
87 $out .= tab . "-$filetest _";
88 } elsif ($_ eq 'print') {
89 $out .= tab . 'print("$name\n")';
90 $print_needed = 0;
91 } elsif ($_ eq 'print0') {
92 $out .= tab . 'print("$name\0")';
93 $print_needed = 0;
94 } elsif ($_ eq 'fstype') {
95 my $type = shift;
96 $out .= tab;
97 if ($type eq 'nfs') {
98 $out .= '($dev < 0)';
99 } else {
100 $out .= '($dev >= 0)'; #XXX
102 } elsif ($_ eq 'user') {
103 my $uname = shift;
104 $out .= tab . "(\$uid == \$uid{'$uname'})";
105 $init{user} = 1;
106 } elsif ($_ eq 'group') {
107 my $gname = shift;
108 $out .= tab . "(\$gid == \$gid{'$gname'})";
109 $init{group} = 1;
110 } elsif ($_ eq 'nouser') {
111 $out .= tab . '!exists $uid{$uid}';
112 $init{user} = 1;
113 } elsif ($_ eq 'nogroup') {
114 $out .= tab . '!exists $gid{$gid}';
115 $init{group} = 1;
116 } elsif ($_ eq 'links') {
117 $out .= tab . n('$nlink', shift);
118 } elsif ($_ eq 'inum') {
119 $out .= tab . n('$ino', shift);
120 } elsif ($_ eq 'size') {
121 $_ = shift;
122 my $n = 'int(((-s _) + 511) / 512)';
123 if (s/c\z//) {
124 $n = 'int(-s _)';
125 } elsif (s/k\z//) {
126 $n = 'int(((-s _) + 1023) / 1024)';
128 $out .= tab . n($n, $_);
129 } elsif ($_ eq 'atime') {
130 $out .= tab . n('int(-A _)', shift);
131 } elsif ($_ eq 'mtime') {
132 $out .= tab . n('int(-M _)', shift);
133 } elsif ($_ eq 'ctime') {
134 $out .= tab . n('int(-C _)', shift);
135 } elsif ($_ eq 'exec') {
136 my @cmd = ();
137 while (@ARGV && $ARGV[0] ne ';')
138 { push(@cmd, shift) }
139 shift;
140 $out .= tab;
141 if ($cmd[0] =~m#^(?:(?:/usr)?/bin/)?rm$#
142 && $cmd[$#cmd] eq '{}'
143 && (@cmd == 2 || (@cmd == 3 && $cmd[1] eq '-f'))) {
144 if (@cmd == 2) {
145 $out .= '(unlink($_) || warn "$name: $!\n")';
146 } elsif (!@ARGV) {
147 $out .= 'unlink($_)';
148 } else {
149 $out .= '(unlink($_) || 1)';
151 } else {
152 for (@cmd)
153 { s/'/\\'/g }
154 { local $" = "','"; $out .= "doexec(0, '@cmd')"; }
155 $declaresubs .= "sub doexec (\$\@);\n";
156 $init{doexec} = 1;
158 $print_needed = 0;
159 } elsif ($_ eq 'ok') {
160 my @cmd = ();
161 while (@ARGV && $ARGV[0] ne ';')
162 { push(@cmd, shift) }
163 shift;
164 $out .= tab;
165 for (@cmd)
166 { s/'/\\'/g }
167 { local $" = "','"; $out .= "doexec(1, '@cmd')"; }
168 $declaresubs .= "sub doexec (\$\@);\n";
169 $init{doexec} = 1;
170 $print_needed = 0;
171 } elsif ($_ eq 'prune') {
172 $out .= tab . '($File::Find::prune = 1)';
173 } elsif ($_ eq 'xdev') {
174 $out .= tab . '!($File::Find::prune |= ($dev != $File::Find::topdev))'
176 } elsif ($_ eq 'newer') {
177 my $file = shift;
178 my $newername = 'AGE_OF' . $file;
179 $newername =~ s/\W/_/g;
180 $newername = '$' . $newername;
181 $out .= tab . "(-M _ < $newername)";
182 $initnewer .= "my $newername = -M " . quote($file) . ";\n";
183 } elsif ($_ eq 'eval') {
184 my $prog = shift;
185 $prog =~ s/'/\\'/g;
186 $out .= tab . "eval {$prog}";
187 $print_needed = 0;
188 } elsif ($_ eq 'depth') {
189 $find = 'finddepth';
190 next;
191 } elsif ($_ eq 'ls') {
192 $out .= tab . "ls";
193 $declaresubs .= "sub ls ();\n";
194 $init{ls} = 1;
195 $print_needed = 0;
196 } elsif ($_ eq 'tar') {
197 die "-tar must have a filename argument\n" unless @ARGV;
198 my $file = shift;
199 my $fh = 'FH' . $file;
200 $fh =~ s/\W/_/g;
201 $out .= tab . "tar(*$fh, \$name)";
202 $flushall .= "tflushall;\n";
203 $declaresubs .= "sub tar;\nsub tflushall ();\n";
204 $initfile .= "open($fh, " . quote('> ' . $file) .
205 qq{) || die "Can't open $fh: \$!\\n";\n};
206 $init{tar} = 1;
207 } elsif (/^(n?)cpio\z/) {
208 die "-$_ must have a filename argument\n" unless @ARGV;
209 my $file = shift;
210 my $fh = 'FH' . $file;
211 $fh =~ s/\W/_/g;
212 $out .= tab . "cpio(*$fh, \$name, '$1')";
213 $find = 'finddepth';
214 $flushall .= "cflushall;\n";
215 $declaresubs .= "sub cpio;\nsub cflushall ();\n";
216 $initfile .= "open($fh, " . quote('> ' . $file) .
217 qq{) || die "Can't open $fh: \$!\\n";\n};
218 $init{cpio} = 1;
219 } else {
220 die "Unrecognized switch: -$_\n";
223 if (@ARGV) {
224 if ($ARGV[0] eq '-o') {
225 { local($statdone) = 1; $out .= "\n" . tab . "||\n"; }
226 $statdone = 0 if $indent_depth == 1 && exists $init{delayedstat};
227 $init{saw_or} = 1;
228 shift;
229 } else {
230 $out .= " &&" unless $Skip_And || $ARGV[0] eq ')';
231 $out .= "\n";
232 shift if $ARGV[0] eq '-a';
237 if ($print_needed) {
238 my $t = tab;
239 if ($t !~ /&&\s*$/) { $t .= '&& ' }
240 $out .= "\n" . $t . 'print("$name\n")';
244 print <<"END";
245 $startperl
246 eval 'exec $perlpath -S \$0 \${1+"\$@"}'
247 if 0; #\$running_under_some_shell
249 use strict;
250 use File::Find ();
252 # Set the variable \$File::Find::dont_use_nlink if you're using AFS,
253 # since AFS cheats.
255 # for the convenience of &wanted calls, including -eval statements:
256 use vars qw/*name *dir *prune/;
257 *name = *File::Find::name;
258 *dir = *File::Find::dir;
259 *prune = *File::Find::prune;
261 $declaresubs
265 if (exists $init{doexec}) {
266 print <<'END';
267 use Cwd ();
268 my $cwd = Cwd::cwd();
273 if (exists $init{ls}) {
274 print <<'END';
275 my @rwx = qw(--- --x -w- -wx r-- r-x rw- rwx);
276 my @moname = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
281 if (exists $init{user} || exists $init{ls} || exists $init{tar}) {
282 print "my (%uid, %user);\n";
283 print "while (my (\$name, \$pw, \$uid) = getpwent) {\n";
284 print ' $uid{$name} = $uid{$uid} = $uid;', "\n"
285 if exists $init{user};
286 print ' $user{$uid} = $name unless exists $user{$uid};', "\n"
287 if exists $init{ls} || exists $init{tar};
288 print "}\n\n";
291 if (exists $init{group} || exists $init{ls} || exists $init{tar}) {
292 print "my (%gid, %group);\n";
293 print "while (my (\$name, \$pw, \$gid) = getgrent) {\n";
294 print ' $gid{$name} = $gid{$gid} = $gid;', "\n"
295 if exists $init{group};
296 print ' $group{$gid} = $name unless exists $group{$gid};', "\n"
297 if exists $init{ls} || exists $init{tar};
298 print "}\n\n";
301 print $initnewer, "\n" if $initnewer ne '';
302 print $initfile, "\n" if $initfile ne '';
303 $flushall .= "exit;\n";
304 if (exists $init{declarestat}) {
305 $out = <<'END' . $out;
306 my ($dev,$ino,$mode,$nlink,$uid,$gid);
311 if ( $follow_in_effect ) {
312 $out =~ s/lstat\(\$_\)/lstat(_)/;
313 print <<"END";
314 $decl
315 # Traverse desired filesystems
316 File::Find::$find( {wanted => \\&wanted, follow => 1}, $roots);
317 $flushall
319 sub wanted {
320 $out;
324 } else {
325 print <<"END";
326 $decl
327 # Traverse desired filesystems
328 File::Find::$find({wanted => \\&wanted}, $roots);
329 $flushall
331 sub wanted {
332 $out;
338 if (exists $init{doexec}) {
339 print <<'END';
341 sub doexec ($@) {
342 my $ok = shift;
343 my @command = @_; # copy so we don't try to s/// aliases to constants
344 for my $word (@command)
345 { $word =~ s#{}#$name#g }
346 if ($ok) {
347 my $old = select(STDOUT);
348 $| = 1;
349 print "@command";
350 select($old);
351 return 0 unless <STDIN> =~ /^y/;
353 chdir $cwd; #sigh
354 system @command;
355 chdir $File::Find::dir;
356 return !$?;
362 if (exists $init{ls}) {
363 print <<'INTRO', <<"SUB", <<'END';
365 sub sizemm {
366 my $rdev = shift;
367 sprintf("%3d, %3d", ($rdev >> 8) & 0xff, $rdev & 0xff);
370 sub ls () {
371 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
372 INTRO
373 \$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat(_);
375 my $pname = $name;
377 $blocks
378 or $blocks = int(($size + 1023) / 1024);
380 my $perms = $rwx[$mode & 7];
381 $mode >>= 3;
382 $perms = $rwx[$mode & 7] . $perms;
383 $mode >>= 3;
384 $perms = $rwx[$mode & 7] . $perms;
385 substr($perms, 2, 1) =~ tr/-x/Ss/ if -u _;
386 substr($perms, 5, 1) =~ tr/-x/Ss/ if -g _;
387 substr($perms, 8, 1) =~ tr/-x/Tt/ if -k _;
388 if (-f _) { $perms = '-' . $perms; }
389 elsif (-d _) { $perms = 'd' . $perms; }
390 elsif (-l _) { $perms = 'l' . $perms; $pname .= ' -> ' . readlink($_); }
391 elsif (-c _) { $perms = 'c' . $perms; $size = sizemm($rdev); }
392 elsif (-b _) { $perms = 'b' . $perms; $size = sizemm($rdev); }
393 elsif (-p _) { $perms = 'p' . $perms; }
394 elsif (-S _) { $perms = 's' . $perms; }
395 else { $perms = '?' . $perms; }
397 my $user = $user{$uid} || $uid;
398 my $group = $group{$gid} || $gid;
400 my ($sec,$min,$hour,$mday,$mon,$timeyear) = localtime($mtime);
401 if (-M _ > 365.25 / 2) {
402 $timeyear += 1900;
403 } else {
404 $timeyear = sprintf("%02d:%02d", $hour, $min);
407 printf "%5lu %4ld %-10s %3d %-8s %-8s %8s %s %2d %5s %s\n",
408 $ino,
409 $blocks,
410 $perms,
411 $nlink,
412 $user,
413 $group,
414 $size,
415 $moname[$mon],
416 $mday,
417 $timeyear,
418 $pname;
426 if (exists $init{cpio} || exists $init{tar}) {
427 print <<'END';
429 my %blocks = ();
431 sub flush {
432 my ($fh, $varref, $blksz) = @_;
434 while (length($$varref) >= $blksz) {
435 no strict qw/refs/;
436 syswrite($fh, $$varref, $blksz);
437 substr($$varref, 0, $blksz) = '';
438 ++$blocks{$fh};
446 if (exists $init{cpio}) {
447 print <<'INTRO', <<"SUB", <<'END';
449 my %cpout = ();
450 my %nc = ();
452 sub cpio {
453 my ($fh, $fname, $nc) = @_;
454 my $text = '';
455 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
456 $atime,$mtime,$ctime,$blksize,$blocks);
457 local (*IN);
459 if ( ! defined $fname ) {
460 $fname = 'TRAILER!!!';
461 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
462 $atime,$mtime,$ctime,$blksize,$blocks) = (0) x 13;
463 } else {
464 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
465 INTRO
466 \$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat(_);
468 if (-f _) {
469 open(IN, "./$_\0") || do {
470 warn "Couldn't open $fname: $!\n";
471 return;
473 } else {
474 $text = readlink($_);
475 $size = 0 unless defined $text;
479 $fname =~ s#^\./##;
480 $nc{$fh} = $nc;
481 if ($nc eq 'n') {
482 $cpout{$fh} .=
483 sprintf("%06o%06o%06o%06o%06o%06o%06o%06o%011lo%06o%011lo%s\0",
484 070707,
485 $dev & 0777777,
486 $ino & 0777777,
487 $mode & 0777777,
488 $uid & 0777777,
489 $gid & 0777777,
490 $nlink & 0777777,
491 $rdev & 0177777,
492 $mtime,
493 length($fname)+1,
494 $size,
495 $fname);
496 } else {
497 $cpout{$fh} .= "\0" if length($cpout{$fh}) & 1;
498 $cpout{$fh} .= pack("SSSSSSSSLSLa*",
499 070707, $dev, $ino, $mode, $uid, $gid, $nlink, $rdev, $mtime,
500 length($fname)+1, $size,
501 $fname . (length($fname) & 1 ? "\0" : "\0\0"));
504 if ($text ne '') {
505 $cpout{$fh} .= $text;
506 } elsif ($size) {
507 my $l;
508 flush($fh, \$cpout{$fh}, 5120)
509 while ($l = length($cpout{$fh})) >= 5120;
510 while (sysread(IN, $cpout{$fh}, 5120 - $l, $l)) {
511 flush($fh, \$cpout{$fh}, 5120);
512 $l = length($cpout{$fh});
514 close IN;
518 sub cflushall () {
519 for my $fh (keys %cpout) {
520 cpio($fh, undef, $nc{$fh});
521 $cpout{$fh} .= "0" x (5120 - length($cpout{$fh}));
522 flush($fh, \$cpout{$fh}, 5120);
523 print $blocks{$fh} * 10, " blocks\n";
530 if (exists $init{tar}) {
531 print <<'INTRO', <<"SUB", <<'END';
533 my %tarout = ();
534 my %linkseen = ();
536 sub tar {
537 my ($fh, $fname) = @_;
538 my $prefix = '';
539 my $typeflag = '0';
540 my $linkname;
541 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
542 INTRO
543 \$atime,\$mtime,\$ctime,\$blksize,\$blocks) = $stat(_);
545 local (*IN);
547 if ($nlink > 1) {
548 if ($linkname = $linkseen{$fh, $dev, $ino}) {
549 if (length($linkname) > 100) {
550 warn "$0: omitting file with linkname ",
551 "too long for tar output: $linkname\n";
552 return;
554 $typeflag = '1';
555 $size = 0;
556 } else {
557 $linkseen{$fh, $dev, $ino} = $fname;
560 if ($typeflag eq '0') {
561 if (-f _) {
562 open(IN, "./$_\0") || do {
563 warn "Couldn't open $fname: $!\n";
564 return;
566 } else {
567 $linkname = readlink($_);
568 if (defined $linkname) { $typeflag = '2' }
569 elsif (-c _) { $typeflag = '3' }
570 elsif (-b _) { $typeflag = '4' }
571 elsif (-d _) { $typeflag = '5' }
572 elsif (-p _) { $typeflag = '6' }
576 if (length($fname) > 100) {
577 ($prefix, $fname) = ($fname =~ m#\A(.*?)/(.{,100})\Z(?!\n)#);
578 if (!defined($fname) || length($prefix) > 155) {
579 warn "$0: omitting file with name too long for tar output: ",
580 $fname, "\n";
581 return;
585 $size = 0 if $typeflag ne '0';
586 my $header = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155",
587 $fname,
588 sprintf("%7o ", $mode & 0777),
589 sprintf("%7o ", $uid & 0777777),
590 sprintf("%7o ", $gid & 0777777),
591 sprintf("%11o ", $size),
592 sprintf("%11o ", $mtime),
593 ' 'x8,
594 $typeflag,
595 defined $linkname ? $linkname : '',
596 "ustar\0",
597 "00",
598 $user{$uid},
599 $group{$gid},
600 ($rdev >> 8) & 0xff,
601 $rdev & 0xff,
602 $prefix,
604 substr($header, 148, 8) = sprintf("%7o ", unpack("%16C*", $header));
605 my $l = length($header) % 512;
606 $tarout{$fh} .= $header;
607 $tarout{$fh} .= "\0" x (512 - $l) if $l;
609 if ($size) {
610 flush($fh, \$tarout{$fh}, 10240)
611 while ($l = length($tarout{$fh})) >= 10240;
612 while (sysread(IN, $tarout{$fh}, 10240 - $l, $l)) {
613 my $slop = length($tarout{$fh}) % 512;
614 $tarout{$fh} .= "\0" x (512 - $slop) if $slop;
615 flush($fh, \$tarout{$fh}, 10240);
616 $l = length($tarout{$fh});
618 close IN;
622 sub tflushall () {
623 my $len;
624 for my $fh (keys %tarout) {
625 $len = 10240 - length($tarout{$fh});
626 $len += 10240 if $len < 1024;
627 $tarout{$fh} .= "\0" x $len;
628 flush($fh, \$tarout{$fh}, 10240);
635 exit;
637 ############################################################################
639 sub tab () {
640 my $tabstring;
642 $tabstring = "\t" x ($indent_depth/2) . ' ' x ($indent_depth%2 * 4);
643 if (!$statdone) {
644 if ($_ =~ /^(?:name|print|prune|exec|ok|\(|\))/) {
645 $init{delayedstat} = 1;
646 } else {
647 my $statcall = '(($dev,$ino,$mode,$nlink,$uid,$gid) = '
648 . $stat . '($_))';
649 if (exists $init{saw_or}) {
650 $tabstring .= "(\$nlink || $statcall) &&\n" . $tabstring;
651 } else {
652 $tabstring .= "$statcall &&\n" . $tabstring;
654 $statdone = 1;
655 $init{declarestat} = 1;
658 $tabstring =~ s/^\s+/ / if $out =~ /!$/;
659 $tabstring;
662 sub fileglob_to_re ($) {
663 my $x = shift;
664 $x =~ s#([./^\$()+])#\\$1#g;
665 $x =~ s#([?*])#.$1#g;
666 "^$x\\z";
669 sub n ($$) {
670 my ($pre, $n) = @_;
671 $n =~ s/^-/< / || $n =~ s/^\+/> / || $n =~ s/^/== /;
672 $n =~ s/ 0*(\d)/ $1/;
673 "($pre $n)";
676 sub quote ($) {
677 my $string = shift;
678 $string =~ s/\\/\\\\/g;
679 $string =~ s/'/\\'/g;
680 "'$string'";
683 __END__
685 =head1 NAME
687 find2perl - translate find command lines to Perl code
689 =head1 SYNOPSIS
691 find2perl [paths] [predicates] | perl
693 =head1 DESCRIPTION
695 find2perl is a little translator to convert find command lines to
696 equivalent Perl code. The resulting code is typically faster than
697 running find itself.
699 "paths" are a set of paths where find2perl will start its searches and
700 "predicates" are taken from the following list.
702 =over 4
704 =item C<! PREDICATE>
706 Negate the sense of the following predicate. The C<!> must be passed as
707 a distinct argument, so it may need to be surrounded by whitespace and/or
708 quoted from interpretation by the shell using a backslash (just as with
709 using C<find(1)>).
711 =item C<( PREDICATES )>
713 Group the given PREDICATES. The parentheses must be passed as distinct
714 arguments, so they may need to be surrounded by whitespace and/or
715 quoted from interpretation by the shell using a backslash (just as with
716 using C<find(1)>).
718 =item C<PREDICATE1 PREDICATE2>
720 True if _both_ PREDICATE1 and PREDICATE2 are true; PREDICATE2 is not
721 evaluated if PREDICATE1 is false.
723 =item C<PREDICATE1 -o PREDICATE2>
725 True if either one of PREDICATE1 or PREDICATE2 is true; PREDICATE2 is
726 not evaluated if PREDICATE1 is true.
728 =item C<-follow>
730 Follow (dereference) symlinks. The checking of file attributes depends
731 on the position of the C<-follow> option. If it precedes the file
732 check option, an C<stat> is done which means the file check applies to the
733 file the symbolic link is pointing to. If C<-follow> option follows the
734 file check option, this now applies to the symbolic link itself, i.e.
735 an C<lstat> is done.
737 =item C<-depth>
739 Change directory traversal algorithm from breadth-first to depth-first.
741 =item C<-prune>
743 Do not descend into the directory currently matched.
745 =item C<-xdev>
747 Do not traverse mount points (prunes search at mount-point directories).
749 =item C<-name GLOB>
751 File name matches specified GLOB wildcard pattern. GLOB may need to be
752 quoted to avoid interpretation by the shell (just as with using
753 C<find(1)>).
755 =item C<-iname GLOB>
757 Like C<-name>, but the match is case insensitive.
759 =item C<-path GLOB>
761 Path name matches specified GLOB wildcard pattern.
763 =item C<-ipath GLOB>
765 Like C<-path>, but the match is case insensitive.
767 =item C<-perm PERM>
769 Low-order 9 bits of permission match octal value PERM.
771 =item C<-perm -PERM>
773 The bits specified in PERM are all set in file's permissions.
775 =item C<-type X>
777 The file's type matches perl's C<-X> operator.
779 =item C<-fstype TYPE>
781 Filesystem of current path is of type TYPE (only NFS/non-NFS distinction
782 is implemented).
784 =item C<-user USER>
786 True if USER is owner of file.
788 =item C<-group GROUP>
790 True if file's group is GROUP.
792 =item C<-nouser>
794 True if file's owner is not in password database.
796 =item C<-nogroup>
798 True if file's group is not in group database.
800 =item C<-inum INUM>
802 True file's inode number is INUM.
804 =item C<-links N>
806 True if (hard) link count of file matches N (see below).
808 =item C<-size N>
810 True if file's size matches N (see below) N is normally counted in
811 512-byte blocks, but a suffix of "c" specifies that size should be
812 counted in characters (bytes) and a suffix of "k" specifes that
813 size should be counted in 1024-byte blocks.
815 =item C<-atime N>
817 True if last-access time of file matches N (measured in days) (see
818 below).
820 =item C<-ctime N>
822 True if last-changed time of file's inode matches N (measured in days,
823 see below).
825 =item C<-mtime N>
827 True if last-modified time of file matches N (measured in days, see below).
829 =item C<-newer FILE>
831 True if last-modified time of file matches N.
833 =item C<-print>
835 Print out path of file (always true). If none of C<-exec>, C<-ls>,
836 C<-print0>, or C<-ok> is specified, then C<-print> will be added
837 implicitly.
839 =item C<-print0>
841 Like -print, but terminates with \0 instead of \n.
843 =item C<-exec OPTIONS ;>
845 exec() the arguments in OPTIONS in a subprocess; any occurrence of {} in
846 OPTIONS will first be substituted with the path of the current
847 file. Note that the command "rm" has been special-cased to use perl's
848 unlink() function instead (as an optimization). The C<;> must be passed as
849 a distinct argument, so it may need to be surrounded by whitespace and/or
850 quoted from interpretation by the shell using a backslash (just as with
851 using C<find(1)>).
853 =item C<-ok OPTIONS ;>
855 Like -exec, but first prompts user; if user's response does not begin
856 with a y, skip the exec. The C<;> must be passed as
857 a distinct argument, so it may need to be surrounded by whitespace and/or
858 quoted from interpretation by the shell using a backslash (just as with
859 using C<find(1)>).
861 =item C<-eval EXPR>
863 Has the perl script eval() the EXPR.
865 =item C<-ls>
867 Simulates C<-exec ls -dils {} ;>
869 =item C<-tar FILE>
871 Adds current output to tar-format FILE.
873 =item C<-cpio FILE>
875 Adds current output to old-style cpio-format FILE.
877 =item C<-ncpio FILE>
879 Adds current output to "new"-style cpio-format FILE.
881 =back
883 Predicates which take a numeric argument N can come in three forms:
885 * N is prefixed with a +: match values greater than N
886 * N is prefixed with a -: match values less than N
887 * N is not prefixed with either + or -: match only values equal to N
889 =head1 SEE ALSO
891 find
893 =cut