From 765b2f1a538b8e0725a48945e4efacf767bf2035 Mon Sep 17 00:00:00 2001 From: PHO Date: Sat, 6 Dec 2008 00:17:40 +0900 Subject: [PATCH] tools/find-missing.pl --- GNUmakefile | 2 +- tools/find-missing.pl | 23 +++++++++++++++++++++++ tools/{lint-dotfiles.pl => list-files.pl} | 21 ++++++++++----------- 3 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 tools/find-missing.pl rename tools/{lint-dotfiles.pl => list-files.pl} (88%) diff --git a/GNUmakefile b/GNUmakefile index 9bb9a2f..42f1663 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,4 @@ lint: - perl ./tools/lint-dotfiles.pl + perl ./tools/list-files.pl | perl ./tools/find-missing.pl .PHONY: lint \ No newline at end of file diff --git a/tools/find-missing.pl b/tools/find-missing.pl new file mode 100644 index 0000000..552b77b --- /dev/null +++ b/tools/find-missing.pl @@ -0,0 +1,23 @@ +use strict; +use warnings; +use Smart::Comments; + +sub main { + while (defined(my $rel = <>)) { + chomp $rel; + my $saved = rel2saved($rel); + + if (!-e $saved) { + print "? $rel\n"; + } + } +} + +sub rel2saved { + my $rel = shift; + + $rel =~ tr/./_/; + return "./dot-files/$rel"; +} + +main(); diff --git a/tools/lint-dotfiles.pl b/tools/list-files.pl similarity index 88% rename from tools/lint-dotfiles.pl rename to tools/list-files.pl index 852791b..673d43b 100644 --- a/tools/lint-dotfiles.pl +++ b/tools/list-files.pl @@ -17,7 +17,15 @@ my @RE_IGNORED = map { map {tr/\n//d; $_} ; -my @CURRENT = find($ENV{HOME}, '.', sub {$_[0] =~ m/^\./}); +main(); + +sub main { + my @current = find($ENV{HOME}, '.', sub {$_[0] =~ m/^\./}); + + foreach (@current) { + print "$_\n"; + } +} sub find { my $base = shift; @@ -36,6 +44,7 @@ sub find { my $rel = File::Spec->abs2rel($abs, $base); next if any { $rel =~ m/$_/ } @RE_IGNORED; + next if !-f $abs; if (-d $abs) { push @d, find($base, $rel); @@ -47,16 +56,6 @@ sub find { @d; } -foreach my $file (@CURRENT) { - # Is it in the repository? - if (-e $file) { - - } - else { - print "? $file\n"; - } -} - __DATA__ *~ .*cache* -- 2.40.0