From e37dcd4c76e3ab61c585b116c34d32382c592b9f Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Tue, 7 Apr 2015 15:00:25 +0000 Subject: [PATCH] Remove check for bash usage Arbitrarily restricting ourselves from using bash because developers on platforms like netbsd don't want to install bash from ports doesn't make sense. Any non-trivial shell script is likely to use features like arrays or string manipulation that are poorly supported (if at all) by sh, and the continued bumping of the number of expected bash scripts is an indication that the check is not serving its purpose anyway. Along with removing the check, all shebang references to /bin/bash have been replaced with /usr/bin/env bash in an attempt to be more compatible across different hosts. Change-Id: Ief72dc380cc88af38959c330897e2c127e33c332 Closes-Bug: #1440824 --- .../agent/xenapi/contrib/build-rpm.sh | 2 +- neutron/tests/contrib/gate_hook.sh | 2 +- neutron/tests/contrib/post_test_hook.sh | 2 +- run_tests.sh | 2 +- tools/abandon_old_reviews.sh | 2 +- tools/check_unit_test_structure.sh | 2 +- tools/clean.sh | 2 +- tools/configure_for_func_testing.sh | 2 +- tools/copy_api_tests_from_tempest.sh | 2 +- tools/deploy_rootwrap.sh | 2 +- tools/misc-sanity-checks.sh | 17 ----------------- tools/with_venv.sh | 2 +- tox.ini | 4 +++- 13 files changed, 14 insertions(+), 29 deletions(-) diff --git a/neutron/plugins/openvswitch/agent/xenapi/contrib/build-rpm.sh b/neutron/plugins/openvswitch/agent/xenapi/contrib/build-rpm.sh index 81b5f3b316b..750bdde2b0a 100755 --- a/neutron/plugins/openvswitch/agent/xenapi/contrib/build-rpm.sh +++ b/neutron/plugins/openvswitch/agent/xenapi/contrib/build-rpm.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eux diff --git a/neutron/tests/contrib/gate_hook.sh b/neutron/tests/contrib/gate_hook.sh index 0f93918a4be..4c777f5251e 100644 --- a/neutron/tests/contrib/gate_hook.sh +++ b/neutron/tests/contrib/gate_hook.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -ex diff --git a/neutron/tests/contrib/post_test_hook.sh b/neutron/tests/contrib/post_test_hook.sh index fc11f6d2bdf..2c8360a47a7 100644 --- a/neutron/tests/contrib/post_test_hook.sh +++ b/neutron/tests/contrib/post_test_hook.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -xe diff --git a/run_tests.sh b/run_tests.sh index 6fe001f5381..a32476c5543 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eu diff --git a/tools/abandon_old_reviews.sh b/tools/abandon_old_reviews.sh index a91e1d1c064..2cb08a7d2df 100755 --- a/tools/abandon_old_reviews.sh +++ b/tools/abandon_old_reviews.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tools/check_unit_test_structure.sh b/tools/check_unit_test_structure.sh index 1e8a2362f75..0aaa0c3ab36 100755 --- a/tools/check_unit_test_structure.sh +++ b/tools/check_unit_test_structure.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script identifies the unit test modules that do not correspond # directly with a module in the code tree. See TESTING.rst for the diff --git a/tools/clean.sh b/tools/clean.sh index 27bc219f9ca..b79f0352692 100755 --- a/tools/clean.sh +++ b/tools/clean.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash rm -rf ./*.deb ./*.tar.gz ./*.dsc ./*.changes rm -rf */*.deb rm -rf ./plugins/**/build/ ./plugins/**/dist diff --git a/tools/configure_for_func_testing.sh b/tools/configure_for_func_testing.sh index 736cb020793..e04b07f6dd4 100755 --- a/tools/configure_for_func_testing.sh +++ b/tools/configure_for_func_testing.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tools/copy_api_tests_from_tempest.sh b/tools/copy_api_tests_from_tempest.sh index 6a3b9f2091b..7084451d334 100755 --- a/tools/copy_api_tests_from_tempest.sh +++ b/tools/copy_api_tests_from_tempest.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script is intended to allow repeatable migration of the neutron # api tests from tempest. The intention is to allow development to diff --git a/tools/deploy_rootwrap.sh b/tools/deploy_rootwrap.sh index dbe8ef705e4..0009a42e2b9 100755 --- a/tools/deploy_rootwrap.sh +++ b/tools/deploy_rootwrap.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tools/misc-sanity-checks.sh b/tools/misc-sanity-checks.sh index 0b18f86e222..874b3243682 100644 --- a/tools/misc-sanity-checks.sh +++ b/tools/misc-sanity-checks.sh @@ -23,22 +23,6 @@ trap "rm -rf $TMPDIR" EXIT FAILURES=$TMPDIR/failures -check_opinionated_shell () { - # The purpose of this function is to avoid casual introduction of more - # bash dependency. Please consider alternatives before committing code - # which uses bash specific features. - - # Check that shell scripts are not bash opinionated (ignore comments though) - # If you cannot avoid the use of bash, please change the EXPECTED var below. - OBSERVED=$(grep -E '^([[:space:]]*[^#[:space:]]|#!).*bash' \ - tox.ini tools/* | wc -l) - EXPECTED=8 - if [ ${EXPECTED} -ne ${OBSERVED} ]; then - echo "Bash usage has been detected!" >>$FAILURES - fi -} - - check_no_symlinks_allowed () { # Symlinks break the package build process, so ensure that they # do not slip in, except hidden symlinks. @@ -74,7 +58,6 @@ check_identical_policy_files () { } # Add your checks here... -check_opinionated_shell check_no_symlinks_allowed check_pot_files_errors check_identical_policy_files diff --git a/tools/with_venv.sh b/tools/with_venv.sh index dea5c5fc2be..5fb07ea8ccb 100755 --- a/tools/with_venv.sh +++ b/tools/with_venv.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2011 OpenStack Foundation. # All Rights Reserved. # diff --git a/tox.ini b/tox.ini index c3bb17f0e4e..32cecacf8f1 100644 --- a/tox.ini +++ b/tox.ini @@ -82,7 +82,9 @@ commands= flake8 sh ./tools/coding-checks.sh --pylint '{posargs}' neutron-db-manage check_migration -whitelist_externals = sh +whitelist_externals = + sh + bash [testenv:cover] commands =