1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#!/usr/local/bin/perl -w
use File::Find;
use Cwd;
my $path = getcwd;
foreach (@ARGV)
{
s/\./\\./;
}
my $re = '^(?:'.join('|',@ARGV).')$';
$re = qr/$re/;
find(\&wanted,"$path/mTk");
sub wanted
{
if ($_ =~ $re)
{
my $file = "$File::Find::name";
unless (-w $file)
{
system('p4','edit',$file);
}
my $cmd = $ENV{'EDITOR'}.' '.$file;
invoke($cmd);
print "$cmd\n";
}
}
sub invoke
{
if ($^O eq 'MSWin32')
{
system(1,@_);
}
else
{
if ($pid = fork)
{
return $pid;
}
else
{
exec(@_);
}
}
}
|