@ -6,10 +6,9 @@ import sys
def main ( ) :
def main ( ) :
allowed = set ( [
standard_shebangs = set ( [
b ' #!/bin/bash -eu ' ,
b ' #!/bin/bash -eu ' ,
b ' #!/bin/bash -eux ' ,
b ' #!/bin/bash -eux ' ,
b ' #!/bin/bash ' ,
b ' #!/bin/sh ' ,
b ' #!/bin/sh ' ,
b ' #!/usr/bin/env bash ' ,
b ' #!/usr/bin/env bash ' ,
b ' #!/usr/bin/env fish ' ,
b ' #!/usr/bin/env fish ' ,
@ -18,6 +17,12 @@ def main():
b ' #!/usr/bin/make -f ' ,
b ' #!/usr/bin/make -f ' ,
] )
] )
integration_shebangs = set ( [
b ' #!/bin/sh ' ,
b ' #!/usr/bin/env bash ' ,
b ' #!/usr/bin/env python ' ,
] )
module_shebangs = {
module_shebangs = {
' ' : b ' #!/usr/bin/python ' ,
' ' : b ' #!/usr/bin/python ' ,
' .py ' : b ' #!/usr/bin/python ' ,
' .py ' : b ' #!/usr/bin/python ' ,
@ -61,6 +66,7 @@ def main():
continue
continue
is_module = False
is_module = False
is_integration = False
if path . startswith ( ' lib/ansible/modules/ ' ) :
if path . startswith ( ' lib/ansible/modules/ ' ) :
is_module = True
is_module = True
@ -73,6 +79,8 @@ def main():
continue
continue
elif path . startswith ( ' test/integration/targets/ ' ) :
elif path . startswith ( ' test/integration/targets/ ' ) :
is_integration = True
dirname = os . path . dirname ( path )
dirname = os . path . dirname ( path )
if dirname . endswith ( ' /library ' ) or dirname in (
if dirname . endswith ( ' /library ' ) or dirname in (
@ -98,6 +106,11 @@ def main():
else :
else :
print ( ' %s : %d : %d : expected module extension %s but found: %s ' % ( path , 0 , 0 , expected_ext , ext ) )
print ( ' %s : %d : %d : expected module extension %s but found: %s ' % ( path , 0 , 0 , expected_ext , ext ) )
else :
else :
if is_integration :
allowed = integration_shebangs
else :
allowed = standard_shebangs
if shebang not in allowed :
if shebang not in allowed :
print ( ' %s : %d : %d : unexpected non-module shebang: %s ' % ( path , 1 , 1 , shebang ) )
print ( ' %s : %d : %d : unexpected non-module shebang: %s ' % ( path , 1 , 1 , shebang ) )