#!/usr/bin/perl -w
use strict;

# Wrapper around weblint to give it proper exit codes!

my $fnd = 0;
foreach $_ (split /:/,$ENV{PATH}) {
   if( -x "$_/weblint" ) { $fnd = 1; last; }
}
if( !$fnd ) { print "lint: skipping, no weblint available\n"; exit 0; }

my $err = 0;
for my $file (@ARGV) {
   print "lint: $file\n";
   open( FOO, "weblint \Q$file\E|" );
   my $output = join '', <FOO>;
   close FOO;
   if( $output ne "" ) {
      $err = 1;
      print STDERR $output;
   }
}

exit $err;

