summaryrefslogtreecommitdiff
path: root/bin/checklinks
diff options
context:
space:
mode:
Diffstat (limited to 'bin/checklinks')
-rwxr-xr-xbin/checklinks29
1 files changed, 19 insertions, 10 deletions
diff --git a/bin/checklinks b/bin/checklinks
index 358b3e1..af0357c 100755
--- a/bin/checklinks
+++ b/bin/checklinks
@@ -14,6 +14,7 @@ my $remove = 0;
my %substitute;
my $linkfile;
my $exit = 0;
+my $ct_auto = 0;
sub mkdirs {
@@ -146,12 +147,15 @@ sub loop_links {
my $dir;
my $cwd = cwd();
- if (-e 'etc') {
+ if (-d 'etc') {
$dir = 'etc';
}
- else {
+ elsif (!$ct_auto) {
$dir = '.';
}
+ else {
+ return;
+ }
foreach my $entry (dir_content($dir)) {
my $source = $entry;
@@ -166,9 +170,18 @@ sub loop_links {
check_symlink($source, "$cwd/$dir/$entry");
}
}
+ return;
}
+GetOptions(
+ 'ct-auto' => \$ct_auto,
+ 'm|msglevel=i' => \$msglevel,
+ 'p|parameter=s' => \%substitute,
+ 'q|quiet' => sub {$msglevel = 1},
+ 'r|remove' => \$remove,
+);
+
if (-f '.links') {
$linkfile = '.links';
}
@@ -176,16 +189,12 @@ elsif (-f 'links') {
$linkfile = 'links';
}
else {
+ if ($ct_auto) {
+ loop_links();
+ }
exit(0);
}
-GetOptions(
- 'm|msglevel=i' => \$msglevel,
- 'p|parameter=s' => \%substitute,
- 'q|quiet' => sub {$msglevel = 1},
- 'r|remove' => \$remove,
-);
-
open(my $links, '<', $linkfile) or die("Can't open $linkfile: $!");
while (my $line = <$links>) {
chomp($line);
@@ -199,7 +208,7 @@ while (my $line = <$links>) {
next unless ($type ~~ ['soft', 'hard', 'auto']);
if ($type eq 'auto') {
- loop_links($src, $dst);
+ loop_links();
}
else {
if ($remove) {