1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#!/usr/bin/perl
# Script to localize newlines
use 5.005;
use strict;
use Getopt::Long;
use File::Spec;
use File::Find::Rule;
use File::LocalizeNewlines;
use vars qw{$VERSION};
BEGIN {
$VERSION = '1.12';
}
# Create the filter
my $filter = File::Find::Rule->file->not_binary->writable;
# Handle options
my $QUIET = '';
my $SKIPSVN = '';
GetOptions( quiet => \$QUIET, svn => \$SKIPSVN );
# Check the target
my $target = @ARGV ? $ARGV[0] : File::Spec->curdir;
unless ( -e $target ) {
bail("Cannot localize '$target', does not exist");
}
# Create the localizer
if ( $SKIPSVN ) {
$filter = File::Find::Rule->or(
File::Find::Rule->name('.svn')->directory->discard->prune,
$filter,
);
}
my $localizer = File::LocalizeNewlines->new(
filter => $filter,
$QUIET ? () : ( verbose => 1 ),
) or bail("Failed to create localizer");
# Run the localization
$localizer->localize( $target );
exit(0);
#####################################################################
# Support Functions
sub bail ($) {
print "$_[0]\n";
exit(255);
}
|