From 870ab94923893c72876d921afffdcb0d82dd3e25 Mon Sep 17 00:00:00 2001 From: PHO Date: Fri, 5 Dec 2008 19:12:26 +0900 Subject: [PATCH 1/1] Initial commit: make lint prints only missing files. --- GNUmakefile | 4 + NEVER_PUT_ANYTHING_CONFIDENTIAL_HERE | 0 tools/lint-dotfiles.pl | 119 +++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 GNUmakefile create mode 100644 NEVER_PUT_ANYTHING_CONFIDENTIAL_HERE create mode 100644 tools/lint-dotfiles.pl diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..9bb9a2f --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,4 @@ +lint: + perl ./tools/lint-dotfiles.pl + +.PHONY: lint \ No newline at end of file diff --git a/NEVER_PUT_ANYTHING_CONFIDENTIAL_HERE b/NEVER_PUT_ANYTHING_CONFIDENTIAL_HERE new file mode 100644 index 0000000..e69de29 diff --git a/tools/lint-dotfiles.pl b/tools/lint-dotfiles.pl new file mode 100644 index 0000000..852791b --- /dev/null +++ b/tools/lint-dotfiles.pl @@ -0,0 +1,119 @@ +use strict; +use warnings; +use Smart::Comments; +use List::MoreUtils qw(any); +use File::Spec; + +my @RE_IGNORED = map { + s/\./\\./g; + s/\+/\\+/g; + + s/\?/.?/g; + s/\*/.*?/g; + + qr/^$_$/; + } + grep {length} + map {tr/\n//d; $_} + ; + +my @CURRENT = find($ENV{HOME}, '.', sub {$_[0] =~ m/^\./}); + +sub find { + my $base = shift; + my $dir = shift || '.'; + my $sel = shift || sub {1}; + + my $dirpath = File::Spec->catfile($base, $dir); + opendir my $dh, $dirpath or die "opendir: $dirpath: $!"; + + my @d; + while (my $name = readdir $dh) { + next if $name =~ /^\.\.?$/; + next if !$sel->($name); + + my $abs = File::Spec->rel2abs($name, $dirpath); + my $rel = File::Spec->abs2rel($abs, $base); + + next if any { $rel =~ m/$_/ } @RE_IGNORED; + + if (-d $abs) { + push @d, find($base, $rel); + } + else { + push @d, $rel; + } + } + @d; +} + +foreach my $file (@CURRENT) { + # Is it in the repository? + if (-e $file) { + + } + else { + print "? $file\n"; + } +} + +__DATA__ +*~ +.*cache* +.*history* +.CFUserTextEncoding +.DS_Store +.ICEauthority +.MacOSX +.Trash +.Xauthority +.cabal +.cpan +.dbus +.dvdcss +.easytag +.elisp +.esd_auth +.emacs.d +.eshell +.firefox +.fontconfig* +.fonts +.gconf* +.gimp* +.glimpse* +.gnome2* +.gnucash +.gnupg +.gstreamer-0.10 +.htpasswd +.ido.last* +.jungledisk* +.kde +.localized +.mozilla +.mpd +.mplayer +.nautilus +.navi2ch +.nh-todo +.pan +.projects.ede +.qt +.recently-used* +.rnd +.s9x +.scribus +.skk-* +.snes* +.ssh +.thumbnails +.tome +.trackballs +.uim.d +.unison +.viminfo +.w3m +.xchat2* +.zcomp* +.zfunc -- 2.40.0