summaryrefslogtreecommitdiff
path: root/bin/checklinks
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-07-16 16:45:10 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2009-07-16 16:45:10 +0200
commit00ef8525200cd887f206ebdaf973058ee4581742 (patch)
treecd2c493125d7b229d3fa6edea0213d0c3cc2559f /bin/checklinks
parent81c0fa5c3b74568b8f3ccf57f214ccbfc52ae20b (diff)
checklinks: --remove: unlink hardlink sources as well
Diffstat (limited to 'bin/checklinks')
-rwxr-xr-xbin/checklinks17
1 files changed, 10 insertions, 7 deletions
diff --git a/bin/checklinks b/bin/checklinks
index 0a3337a..0e20186 100755
--- a/bin/checklinks
+++ b/bin/checklinks
@@ -37,7 +37,7 @@ while(<$links>) {
my ($type, $src, $dst) = split;
next unless ($type eq 'soft' or $type eq 'hard');
if ($remove) {
- remove_link($src);
+ remove_link($type, $src, $dst);
} elsif ($type eq 'soft') {
check_symlink($src, $dst);
} elsif ($type eq 'hard') {
@@ -47,11 +47,14 @@ while(<$links>) {
close($links);
sub remove_link {
- my $link = shift;
-
- if (-l "$base/$link") {
- unlink("$base/$link") or warn("cannot unlink $base/$link: $!");
- print_format('removed', $link, '', 'red', 1);
+ my ($type, $src, $dst) = @_;
+
+ if (
+ ($type eq 'soft' and -l "$base/$src")
+ or ($type eq 'hard' and -e "$base/$src" and -e "$base/$dst")
+ ) {
+ unlink("$base/$src") or warn("cannot unlink $base/$src: $!");
+ print_format('removed', $src, '', 'red', 1);
}
return;
}
@@ -178,7 +181,7 @@ Shortcut for C<< --msglevel=1 >>
=item B<-r>, B<--remove>
-Remove all symlinks. Hardlinks will be left as they are.
+Remove all link sources (hardlinks: only if their destination exists)
=back