I couldn't resist--here's a more idiomatic perl version:

#!/usr/bin/perl

use strict;
use warnings;

use Cwd 'abs_path';
use File::Basename;

use constant DIR  => dirname( dirname( __FILE__ ) );
use constant DICT => abs_path( DIR.'/doc/aspell.en.pws' );

sub spellcheck {
    my $file = shift;
    print "Spell checking $file\n";
    system('aspell', '-H', '-p', DICT, '-c', $file);
}

if ( ( @ARGV == 0 ) || ( ( @ARGV == 1 ) && ! -f $ARGV[0] ) ) {

    my $treeish = $ARGV[0] || 'master';

    open ( GIT, "git diff --name-only '$treeish'|" )
        or die "Unable to open $treeish: $!";

    chomp ( my @files = <GIT> );

    spellcheck( $_ ) for grep { m{.*/.*\.xml$} } @files;

} else {

    spellcheck( $_ ) for @ARGV;

}

-- 
Alan

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to