aboutsummaryrefslogtreecommitdiffstats
path: root/remove_stale.pl
diff options
context:
space:
mode:
authorPeter Karlsson <peterk>2001-03-22 22:35:12 +0000
committerPeter Karlsson <peterk>2001-03-22 22:35:12 +0000
commit730b9415c308710dcfca26eafd1fb10ce98cee0c (patch)
treee64dea3e2044a41ba2546172b42962fbf7b37a6e /remove_stale.pl
parentc71f6968357774d72189afa23851a4e1f512f475 (diff)
Reversed order of deletions, just to make sure. Also added a check if the
installed file actually does exist. Report totals. CVS version numbers remove_stale.pl: 1.1 -> 1.2
Diffstat (limited to 'remove_stale.pl')
-rwxr-xr-xremove_stale.pl27
1 files changed, 19 insertions, 8 deletions
diff --git a/remove_stale.pl b/remove_stale.pl
index 1157ed996aa..6400d18bb78 100755
--- a/remove_stale.pl
+++ b/remove_stale.pl
@@ -25,7 +25,10 @@ unless (-d 'english' && getopts('d'))
}
# Recurse.
-&recurse('.');
+my $files = &recurse('.') || 'No';
+print "\n$files stale translations found.\n";
+print "Use -d option to remove files.\n"
+ if $files ne 'No' && !$opt_d;
# Done.
exit;
@@ -37,7 +40,7 @@ sub recurse
my $directory = shift;
# Don't try to do anything in the WNPP and l10n directories.
- return if $directory =~ /wnpp$/ or $directory =~ /l10n$/;
+ return 0 if $directory =~ /wnpp$/ or $directory =~ /l10n$/;
# Load all entries for this directory.
opendir THISDIR, $directory
@@ -67,6 +70,7 @@ sub recurse
# Locate all HTML files, and find out which ones do not correspond
# to a WML file, and does not live in the CVS by itself.
my @subdirs = ();
+ my $count = 0;
my $direntry;
foreach $direntry (@entries)
{
@@ -98,6 +102,7 @@ sub recurse
unless ($haswml || $incvs)
{
# File has no reason for being here.
+ $count ++;
# Name of file installed by make install.
my $installed = $direntry;
@@ -106,16 +111,20 @@ sub recurse
# Remove or report.
if ($opt_d)
{
- print "$direntry is stale ... removing\n";
+ if (-f $installed)
+ {
+ print "Removing $installed\n";
+ unlink $installed
+ or die "Unable to remove $installed: $!\n";
+ }
+
+ print "Removing $direntry\n";
unlink $direntry
or die "Unable to remove $direntry: $!\n";
- print " also removing $installed\n";
- unlink $installed
- or die "Unable to remove $installed: $!\n";
}
else
{
- print "$direntry is stale (use -d to remove)\n";
+ print "$direntry is stale\n";
print " installed file is $installed\n";
print " (does not exist)\n"
unless -f $installed;
@@ -132,6 +141,8 @@ sub recurse
my $subdir;
foreach $subdir (@subdirs)
{
- recurse($subdir);
+ $count += recurse($subdir);
}
+
+ return $count;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy