- Remove shebangs from:
- ini files
- unit tests
- module_utils
- plugins
- module_docs_fragments
- non-executable Makefiles
- Change non-modules from '/usr/bin/python' to '/usr/bin/env python'.
- Change '/bin/env' to '/usr/bin/env'.
Also removed main functions from unit tests (since they no longer
have a shebang) and fixed a python 3 compatibility issue with
update_bundled.py so it does not need to specify a python 2 shebang.
A script was added to check for unexpected shebangs in files.
This script is run during CI on Shippable.
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-#!/usr/bin/python2 -tt |
|
1 |
+#!/usr/bin/env python |
|
2 | 2 |
|
3 | 3 |
import glob |
4 | 4 |
import json |
... | ... |
@@ -25,7 +25,7 @@ for filename in glob.glob(os.path.join(basedir, '../lib/ansible/compat/*/__init_ |
25 | 25 |
continue |
26 | 26 |
metadata = json.loads(data) |
27 | 27 |
pypi_fh = open_url('https://pypi.python.org/pypi/{0}/json'.format(metadata['pypi_name'])) |
28 |
- pypi_data = json.loads(pypi_fh.read()) |
|
28 |
+ pypi_data = json.loads(pypi_fh.read().decode('utf-8')) |
|
29 | 29 |
if LooseVersion(metadata['version']) < LooseVersion(pypi_data['info']['version']): |
30 | 30 |
print('UPDATE: {0} from {1} to {2} {3}'.format( |
31 | 31 |
metadata['pypi_name'], |
5 | 4 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,17 @@ |
0 |
+#!/bin/sh |
|
1 |
+ |
|
2 |
+grep '^#!' -RIn . 2>/dev/null | grep ':1:' | sed 's/:1:/:/' | grep -v -E \ |
|
3 |
+ -e '^\./lib/ansible/modules/' \ |
|
4 |
+ -e '^\./test/integration/targets/[^/]*/library/[^/]*:#!powershell$' \ |
|
5 |
+ -e ':#!/bin/sh$' \ |
|
6 |
+ -e ':#!/bin/bash( -[eux]|$)' \ |
|
7 |
+ -e ':#!/usr/bin/make -f$' \ |
|
8 |
+ -e ':#!/usr/bin/env python$' \ |
|
9 |
+ -e ':#!/usr/bin/env bash$' \ |
|
10 |
+ -e ':#!/usr/bin/env fish$' |
|
11 |
+ |
|
12 |
+if [ $? -ne 1 ]; then |
|
13 |
+ echo "One or more file(s) listed above have an unexpected shebang." |
|
14 |
+ echo "See $0 for the list of acceptable values." |
|
15 |
+ exit 1 |
|
16 |
+fi |
... | ... |
@@ -1,5 +1,3 @@ |
1 |
-#!/usr/bin/python |
|
2 |
- |
|
3 | 1 |
from nose.plugins.skip import SkipTest |
4 | 2 |
|
5 | 3 |
try: |
... | ... |
@@ -489,9 +487,3 @@ class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase): |
489 | 489 |
) |
490 | 490 |
self.assertFalse(success) |
491 | 491 |
self.assertFalse(changed) |
492 |
- |
|
493 |
-def main(): |
|
494 |
- unittest.main() |
|
495 |
- |
|
496 |
-if __name__ == '__main__': |
|
497 |
- main() |
... | ... |
@@ -1,5 +1,3 @@ |
1 |
-#!/usr/bin/python |
|
2 |
- |
|
3 | 1 |
from nose.plugins.skip import SkipTest |
4 | 2 |
|
5 | 3 |
try: |
... | ... |
@@ -287,10 +285,3 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): |
287 | 287 |
self.assertTrue(changed) |
288 | 288 |
self.assertEqual(results, should_return) |
289 | 289 |
self.assertEqual(err_msg, 'Kinesis Stream test updated successfully.') |
290 |
- |
|
291 |
- |
|
292 |
-def main(): |
|
293 |
- unittest.main() |
|
294 |
- |
|
295 |
-if __name__ == '__main__': |
|
296 |
- main() |
... | ... |
@@ -20,6 +20,7 @@ test/sanity/code-smell/replace-urlopen.sh . |
20 | 20 |
test/sanity/code-smell/use-compat-six.sh lib |
21 | 21 |
test/sanity/code-smell/boilerplate.sh |
22 | 22 |
test/sanity/code-smell/required-and-default-attributes.sh |
23 |
+test/sanity/code-smell/shebang.sh |
|
23 | 24 |
|
24 | 25 |
shellcheck \ |
25 | 26 |
test/integration/targets/*/*.sh \ |