Check file given as first argument

Check the file whose name has been specified on the command line for
errors, instead of `stdin'. Git passes the file name of the file
containing the commit message instead of passing the commit message to
`stdin'.

This was supposed to be committed in the first commit. but somehow it
got lost.
This commit is contained in:
Tom Willemse 2014-03-05 00:26:26 +01:00
parent a4279c3b6b
commit 06abe8cbc7

View file

@ -12,7 +12,9 @@ sub err {
$status = 1;
}
while (<>) {
open(my $commitfile, "<", $ARGV[0]) or die "Couldn't open $ARGV[0]";
while (<$commitfile>) {
next if /^#/; # Discard comments
next if $lineno == 0 && /^$/; # Discard leading empty lines
$lineno++; # Start at 1, so increment first
@ -27,4 +29,5 @@ while (<>) {
err "Longer than 80 characters" if /^.{73,}/;
}
close $commitfile;
exit $status;