| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
find - Greple module to use find command |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
greple -Mfind find-options -- greple-options ... |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Provide B command option with ending C<-->. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
B will invoke B command with provided options and read |
|
14
|
|
|
|
|
|
|
its output from STDIN, with option B<--readlist>. So |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
greple -Mfind . -type f -- pattern |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
is equivalent to: |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
find . -type f | greple --readlist pattern |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
If the first argument start with C, it is taken as a command name |
|
23
|
|
|
|
|
|
|
and executed in place of B. You can search git managed files |
|
24
|
|
|
|
|
|
|
like this: |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
greple -Mfind !git ls-files -- pattern |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
L |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
L |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
L |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
package App::Greple::find; |
|
40
|
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
1037
|
use v5.24; |
|
|
1
|
|
|
|
|
3
|
|
|
42
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
36
|
|
|
43
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
63
|
|
|
44
|
1
|
|
|
1
|
|
4
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
38
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
1
|
|
|
1
|
|
3
|
use App::Greple::Common; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
341
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $path; |
|
49
|
|
|
|
|
|
|
my $chdir; |
|
50
|
|
|
|
|
|
|
my $debug; |
|
51
|
|
|
|
|
|
|
my @pid; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub set { |
|
54
|
0
|
|
|
0
|
0
|
|
my %arg = @_; |
|
55
|
0
|
0
|
|
|
|
|
$path = $arg{path} if defined $arg{path}; |
|
56
|
0
|
0
|
|
|
|
|
$chdir = $arg{chdir} if defined $arg{chdir}; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub initialize { |
|
60
|
0
|
|
|
0
|
0
|
|
my $module = shift; |
|
61
|
0
|
|
|
|
|
|
my $argv = shift; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ($chdir) { |
|
64
|
0
|
0
|
|
|
|
|
chdir $chdir or die "chdir: $!"; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my @find; |
|
68
|
0
|
|
|
|
|
|
while (@$argv) { |
|
69
|
0
|
0
|
|
|
|
|
last if $argv->[0] =~ /^--(man|show)$/; |
|
70
|
0
|
|
|
|
|
|
my $arg = shift @$argv; |
|
71
|
0
|
0
|
|
|
|
|
last if $arg eq '--'; |
|
72
|
0
|
|
|
|
|
|
push @find, $arg; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
0
|
0
|
|
|
|
|
return unless @find; |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $pid = open STDIN, '-|' // croak "process fork failed"; |
|
77
|
0
|
|
|
|
|
|
push @pid, $pid; |
|
78
|
0
|
0
|
|
|
|
|
return if $pid; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
unless ($find[0] =~ s/^!//) { |
|
81
|
0
|
0
|
|
|
|
|
unshift @find, $path if defined $path; |
|
82
|
0
|
|
|
|
|
|
unshift @find, 'find'; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
0
|
0
|
|
|
|
|
if (@pid > 1) { |
|
85
|
0
|
|
|
|
|
|
print while <>; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
0
|
0
|
|
|
|
|
exec @find or croak "Can't exec $find[0]"; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__DATA__ |