]> gitweb @ CieloNegro.org - sugar.git/blob - tools/lint-dotfiles.pl
852791b6cc72373ac9b442dcebd9d5d10cf167a1
[sugar.git] / tools / lint-dotfiles.pl
1 use strict;
2 use warnings;
3 use Smart::Comments;
4 use List::MoreUtils qw(any);
5 use File::Spec;
6
7 my @RE_IGNORED = map {
8     s/\./\\./g;
9     s/\+/\\+/g;
10
11     s/\?/.?/g;
12     s/\*/.*?/g;
13
14     qr/^$_$/;
15   }
16   grep {length}
17   map  {tr/\n//d; $_}
18   <DATA>;
19
20 my @CURRENT = find($ENV{HOME}, '.', sub {$_[0] =~ m/^\./});
21
22 sub find {
23     my $base = shift;
24     my $dir  = shift || '.';
25     my $sel  = shift || sub {1};
26
27     my $dirpath = File::Spec->catfile($base, $dir);
28     opendir my $dh, $dirpath or die "opendir: $dirpath: $!";
29
30     my @d;
31     while (my $name = readdir $dh) {
32         next if $name =~ /^\.\.?$/;
33         next if !$sel->($name);
34
35         my $abs = File::Spec->rel2abs($name, $dirpath);
36         my $rel = File::Spec->abs2rel($abs, $base);
37
38         next if any { $rel =~ m/$_/ } @RE_IGNORED;
39
40         if (-d $abs) {
41             push @d, find($base, $rel);
42         }
43         else {
44             push @d, $rel;
45         }
46     }
47     @d;
48 }
49
50 foreach my $file (@CURRENT) {
51     # Is it in the repository?
52     if (-e $file) {
53
54     }
55     else {
56         print "? $file\n";
57     }
58 }
59
60 __DATA__
61 *~
62 .*cache*
63 .*history*
64 .CFUserTextEncoding
65 .DS_Store
66 .ICEauthority
67 .MacOSX
68 .Trash
69 .Xauthority
70 .cabal
71 .cpan
72 .dbus
73 .dvdcss
74 .easytag
75 .elisp
76 .esd_auth
77 .emacs.d
78 .eshell
79 .firefox
80 .fontconfig*
81 .fonts
82 .gconf*
83 .gimp*
84 .glimpse*
85 .gnome2*
86 .gnucash
87 .gnupg
88 .gstreamer-0.10
89 .htpasswd
90 .ido.last*
91 .jungledisk*
92 .kde
93 .localized
94 .mozilla
95 .mpd
96 .mplayer
97 .nautilus
98 .navi2ch
99 .nh-todo
100 .pan
101 .projects.ede
102 .qt
103 .recently-used*
104 .rnd
105 .s9x
106 .scribus
107 .skk-*
108 .snes*
109 .ssh
110 .thumbnails
111 .tome
112 .trackballs
113 .uim.d
114 .unison
115 .viminfo
116 .w3m
117 .xchat2*
118 .zcomp*
119 .zfunc