-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathunlink.pl
More file actions
29 lines (25 loc) · 743 Bytes
/
unlink.pl
File metadata and controls
29 lines (25 loc) · 743 Bytes
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
#!perl
use strict;
use warnings;
use File::Find;
use File::Spec qw( rel2abs );
use Term::ANSIColor qw( colored );
my $do_it;
my $fmt_msg = "Would unlink %s (-> %s )";
if ( grep {qr{\A--do\z}} @ARGV ) {
$do_it = 1;
$fmt_msg = colored(['bold','red'], " → ") . "Unlinking %s (-> %s )";
}
my $opts = { follow => 0 , no_chdir => 1 };
$opts->{wanted} = sub {
return unless -e $_;
return unless -l $_;
my $dest = readlink $_;
if ( $dest =~ qr{3rd-party/perl-testing-profiles} ) {
printf "${fmt_msg}\n", colored([ 'bold', 'yellow' ], $_ ), colored([ 'green' ], $dest );
if ( $do_it ) {
unlink "$_" or die colored(['bold','red'], "Error unlinking $_, $!");
}
}
};
File::Find::find($opts, "/etc/portage");