9 our $Wanted = \&bad_links;
12 our $Target = q{/usr/local/};
14 # put the main loop into a block so that tests can load this as a module
20 #check_stow($Target, $Wanted);
26 'b|badlinks' => sub { $Wanted = \&bad_links },
27 'a|aliens' => sub { $Wanted = \&aliens },
28 'l|list' => sub { $Wanted = \&list },
29 't|target=s' => \$Target,
36 USAGE: chkstow [options]
39 -b, --badlinks Report symlinks that point to non-existant files.
40 -a, --aliens Report non-symlinks in the target directory.
41 -l, --list List packages in the target directory.
42 -t DIR, --target=DIR Set the target directory to DIR (default
49 #my ($Target, $Wanted) = @_;
53 preprocess => \&skip_dirs,
56 find(\%options, $Target);
58 if ($Wanted == \&list) {
60 delete $Package{'..'};
64 print sort(keys %Package), "\n";
71 # skip stow source and unstowed targets
72 if (-e ".stow" || -e ".notstowed" ) {
73 warn "skipping $File::Find::dir\n";
81 # checking for files that do not link to anything
83 -l && !-e && print "Bogus link: $File::Find::name\n";
86 # checking for files that are not owned by stow
88 !-l && !-d && print "Unstowed file: $File::Find::name\n";
91 # just list the packages in the the target directory
92 # FIXME: what if the stow dir is not called 'stow'?
96 s{\A(?:\.\./)+stow/}{}g;
102 1; # Hey, it's a module!