#!/home/opt/bin/perl

use Cwd;


die "$usage $!" if (!@ARGV);
$usage="must enter type of lock";
$debug=0;
$string=shift(@ARGV);
$startdir="/home/cvs/cvsroot/wind";

if (!$ARGV[0]){
#if ($ARGV[0] =~ /\*/ || !$ARGV[0]){
#  $path=&cwd();  #this will start the search in the current working directory
  $path=$startdir;
}
elsif ($ARGV[0] =~ /^\//){
  $path=shift; #this will start the search from the location input on the command line.
}

use File::Find;

find(\&wanted, "$path");  #ARGV must be passed in on the command line.

sub wanted{
  my $file = $_;
#  push(@
  if (-d "#cvs.lock" && -e $string){
    chmod(0777,$string);
    chmod(0777,'#cvs.lock');
    print("removing $string and #cvs.lock\n");
    unlink $string || warn"Could not unlink: $string $!\n";
    rmdir '#cvs.lock' || warn"Could not remove: $#cvs.lock $!\n";
  print("removing lock: $string in: $_\n");
#  system("grep $string $_");
  }
}
