title: Pre Commit hook git error
body: <p>I am trying to execute a pre commit git hook in python to check if files have line lengths less than 80 chars. However i get a no such file/directory error. i am on fedora and have set the #!usr/bin/python.help would be appreciated</p>
  
  <pre><code>#!/usr/bin/env python
  #-*- mode: python -*-
  
  from subprocess import Popen, PIPE
  import sys
  
  def run(command):
      p = Popen(command.split(), stdout=PIPE, stderr=PIPE)
      p.wait()
      return p.returncode, p.stdout.read().strip().split(), p.stderr.read()
  
  
  def precommit():
    _, files_modified, _= run("git diff-index --name-only HEAD")
    i=1
    for fname in files_modified:
  
      file = open(fname)
      while i==1:
         line = file.readline()
         if not line:
            break
         elif len(line)&gt;80:
            print("Commit failed: Line greater than 80 characters")
            return 1
      return 0
  sys.exit(precommit())
  </code></pre>