def is_sh(executable):
 try:
  fp = open(executable)
  magic = fp.read(2)
  fp.close()
 except (OSError, IOError):
  return executable
 return (magic == '#!')

def is_sh ( executable ) : try : fp = open ( executable ) magic = fp . read ( 2 ) fp . close ( ) except ( OSError , IOError ) : return executable return ( magic == '#!' )
determine if the specified executable is a .