Browse code

Clean up shebangs for various files.

- 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.

Matt Clay authored on 2016/11/03 06:47:42
Showing 24 changed files
... ...
@@ -1,4 +1,3 @@
1
-#!/usr/bin/make
2 1
 # WARN: gmake syntax
3 2
 ########################################################
4 3
 # Makefile for Ansible
... ...
@@ -1,4 +1,3 @@
1
-#!/usr/bin/python
2 1
 # Copyright 2016 Doalitic.
3 2
 #
4 3
 # This file is part of Ansible
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/python
1
+#!/usr/bin/env python
2 2
 # vim: set fileencoding=utf-8 :
3 3
 #
4 4
 # Copyright (C) 2016 Guido Günther <agx@sigxcpu.org>
... ...
@@ -1,4 +1,3 @@
1
-#!/usr/bin/python
2 1
 # Copyright 2013 Google Inc.
3 2
 #
4 3
 # This file is part of Ansible
... ...
@@ -1,4 +1,4 @@
1
-#!/bin/env python
1
+#!/usr/bin/env python
2 2
 
3 3
 '''
4 4
 nsot
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/python
1
+#!/usr/bin/env python
2 2
 
3 3
 import json
4 4
 import requests
... ...
@@ -1,4 +1,4 @@
1
-#!/bin/env python
1
+#!/usr/bin/env python
2 2
 
3 3
 """
4 4
 Spacewalk external inventory script
... ...
@@ -1,4 +1,3 @@
1
-#!/usr/bin/make
2 1
 SITELIB = $(shell python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")
3 2
 FORMATTER=../hacking/module_formatter.py
4 3
 DUMPER=../hacking/dump_playbook_attributes.py
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/python
1
+#!/usr/bin/env python
2 2
 from collections import namedtuple
3 3
 from ansible.parsing.dataloader import DataLoader
4 4
 from ansible.vars import VariableManager
... ...
@@ -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'],
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/python
1
+#!/usr/bin/env python
2 2
 # long version of this one liner: python -c 'import yaml,sys;yaml.safe_load(sys.stdin)' < yamltest.txt
3 3
 import yaml
4 4
 import sys
... ...
@@ -1,4 +1,3 @@
1
-#!/usr/bin/python
2 1
 # -*- coding: utf-8 -*-
3 2
 
4 3
 # This code is part of Ansible, but is an independent component.
... ...
@@ -1,4 +1,3 @@
1
-#!/usr/bin/python
2 1
 # -*- coding: utf-8 -*-
3 2
 
4 3
 # (c) 2016, Hiroaki Nakamura <hnakamur@gmail.com>
... ...
@@ -1,4 +1,3 @@
1
-#!/usr/bin/python
2 1
 # -*- coding: utf-8 -*-
3 2
 #
4 3
 # Copyright (c) 2016 Red Hat, Inc.
... ...
@@ -1,4 +1,3 @@
1
-#!/usr/bin/python
2 1
 # -*- coding: utf-8 -*-
3 2
 
4 3
 # (c) 2012-2013, Timothy Appnel <tim@appnel.com>
... ...
@@ -1,5 +1,3 @@
1
-#!/usr/bin/python
2
-#
3 1
 # Copyright (c) 2016 Matt Davis, <mdavis@ansible.com>
4 2
 #                    Chris Houseknecht, <house@redhat.com>
5 3
 #
... ...
@@ -1,5 +1,3 @@
1
-#!/usr/bin/python
2
-#
3 1
 # Copyright (c) 2016 Matt Davis, <mdavis@ansible.com>
4 2
 #                    Chris Houseknecht, <house@redhat.com>
5 3
 #
... ...
@@ -1,4 +1,3 @@
1
-#!/usr/bin/python
2 1
 # -*- coding: utf-8 -*-
3 2
 #
4 3
 # Copyright (c) 2016 Red Hat, Inc.
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()
... ...
@@ -1,4 +1,3 @@
1
-#!/usr/bin/python
2 1
 # -*- coding: utf-8 -*-
3 2
 # (c) 2016, James Cammarata <jimi@sngx.net>
4 3
 #
... ...
@@ -1,4 +1,3 @@
1
-#!/usr/bin/env python
2 1
 # -*- coding: utf-8 -*-
3 2
 # (c) 2015, Florian Apolloner <florian@apolloner.eu>
4 3
 #
... ...
@@ -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 \