#!/usr/bin/env python
# mikey

# Check that scripts have a hashbang #! on the first line

# Imports
import sys, re

for file in sys.argv[1:]:
    # for command line options after 0
    with open(file, "r") as fp:
        # op as read only as fp object
        first_line = fp.readline().strip()
        # read the first line of the file and strip whitespace
        if not re.match(r'#!?/', first_line):
            # if the first line doesnt match this regex for #! then
            print("\033[1;41mERR!\033[0;0m, '%s' does not look like a valid hashbang" % first_line)
            # print an error
        else:
            print "\033[1;42mValid\033[0;0m, '%s' looks good" % first_line
            # Well done :)
