|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import stat
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -24,7 +25,6 @@ def main():
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
skip = set([
|
|
|
|
|
'hacking/cherrypick.py',
|
|
|
|
|
'test/integration/targets/win_module_utils/library/legacy_only_new_way_win_line_ending.ps1',
|
|
|
|
|
'test/integration/targets/win_module_utils/library/legacy_only_old_way_win_line_ending.ps1',
|
|
|
|
|
])
|
|
|
|
@ -35,17 +35,27 @@ def main():
|
|
|
|
|
|
|
|
|
|
with open(path, 'rb') as path_fd:
|
|
|
|
|
shebang = path_fd.readline().strip()
|
|
|
|
|
mode = os.stat(path).st_mode
|
|
|
|
|
executable = (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) & mode
|
|
|
|
|
|
|
|
|
|
if not shebang:
|
|
|
|
|
continue
|
|
|
|
|
if not shebang or not shebang.startswith(b'#!'):
|
|
|
|
|
if executable:
|
|
|
|
|
print('%s:%d:%d: file without shebang should not be executable' % (path, 0, 0))
|
|
|
|
|
|
|
|
|
|
if not shebang.startswith(b'#!'):
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
is_module = False
|
|
|
|
|
|
|
|
|
|
if path.startswith('lib/ansible/modules/'):
|
|
|
|
|
is_module = True
|
|
|
|
|
elif path.startswith('lib/') or path.startswith('test/runner/lib/'):
|
|
|
|
|
if executable:
|
|
|
|
|
print('%s:%d:%d: should not be executable' % (path, 0, 0))
|
|
|
|
|
|
|
|
|
|
if shebang:
|
|
|
|
|
print('%s:%d:%d: should not have a shebang' % (path, 0, 0))
|
|
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
elif path.startswith('test/integration/targets/'):
|
|
|
|
|
dirname = os.path.dirname(path)
|
|
|
|
|
|
|
|
|
@ -57,6 +67,9 @@ def main():
|
|
|
|
|
is_module = True
|
|
|
|
|
|
|
|
|
|
if is_module:
|
|
|
|
|
if executable:
|
|
|
|
|
print('%s:%d:%d: module should not be executable' % (path, 0, 0))
|
|
|
|
|
|
|
|
|
|
ext = os.path.splitext(path)[1]
|
|
|
|
|
expected_shebang = module_shebangs.get(ext)
|
|
|
|
|
expected_ext = ' or '.join(['"%s"' % k for k in module_shebangs])
|
|
|
|
|