diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2010-03-27 19:43:25 +0100 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2010-03-27 19:43:25 +0100 |
commit | 06e95a7635c559a631515683a9dbfaeee8cda0c7 (patch) | |
tree | 7f2e6490d382e59e1b72202629a3150438542491 /bin/checklinks | |
parent | 5eab75f69c3a816489e0ee3bbd60e0b53d833bb3 (diff) |
Treat etc/ special: automatically "install" the dotfiles in it
Diffstat (limited to 'bin/checklinks')
-rwxr-xr-x | bin/checklinks | 29 |
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) { |