From 285af1cbb553d086a9566fa614dacc0705e57693 Mon Sep 17 00:00:00 2001 From: Aleksander Gondek Date: Fri, 29 Jan 2021 22:34:15 +0100 Subject: [PATCH] Ensure bash shebang lines are portable (#53) This commit ensures all instances of bash shebang line are utilizing portable '/usr/bin/env bash', allowing for greater portability of the rules_gitops --- create_kind_cluster.sh | 2 +- e2e_test.sh | 2 +- examples/e2e-test.sh | 2 +- examples/helloworld/k8s_deploy_test.sh | 2 +- skylib/cmd.sh.tpl | 2 +- skylib/k8s.bzl | 2 +- skylib/k8s_cmd.sh.tpl | 2 +- skylib/k8s_gitops.sh.tpl | 2 +- skylib/k8s_test_namespace.sh.tpl | 2 +- skylib/kustomize/kustomize.bzl | 2 +- skylib/kustomize/run-all.sh.tpl | 2 +- skylib/kustomize/set_namespace.sh | 4 +++- skylib/kustomize/tests/set_namespace_test.sh | 2 +- skylib/tests/fork_join_test.sh | 2 +- 14 files changed, 16 insertions(+), 14 deletions(-) diff --git a/create_kind_cluster.sh b/create_kind_cluster.sh index a15382bc..5acdc161 100755 --- a/create_kind_cluster.sh +++ b/create_kind_cluster.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2020 Adobe. All rights reserved. # This file is licensed to you under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. You may obtain a copy diff --git a/e2e_test.sh b/e2e_test.sh index 5e8b4d44..76b36550 100755 --- a/e2e_test.sh +++ b/e2e_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2020 Adobe. All rights reserved. # This file is licensed to you under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. You may obtain a copy diff --git a/examples/e2e-test.sh b/examples/e2e-test.sh index 6157c92b..f196c58e 100755 --- a/examples/e2e-test.sh +++ b/examples/e2e-test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2020 Adobe. All rights reserved. # This file is licensed to you under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. You may obtain a copy diff --git a/examples/helloworld/k8s_deploy_test.sh b/examples/helloworld/k8s_deploy_test.sh index 18ba1f6a..c30c3101 100755 --- a/examples/helloworld/k8s_deploy_test.sh +++ b/examples/helloworld/k8s_deploy_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Debug # set -x diff --git a/skylib/cmd.sh.tpl b/skylib/cmd.sh.tpl index cf7bd524..b4436494 100644 --- a/skylib/cmd.sh.tpl +++ b/skylib/cmd.sh.tpl @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2020 Adobe. All rights reserved. # This file is licensed to you under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. You may obtain a copy diff --git a/skylib/k8s.bzl b/skylib/k8s.bzl index 52ea705b..0083cce5 100644 --- a/skylib/k8s.bzl +++ b/skylib/k8s.bzl @@ -29,7 +29,7 @@ def _python_runfiles(ctx, f): return "PYTHON_RUNFILES=${RUNFILES} %s" % _runfiles(ctx, f) def _show_impl(ctx): - script_content = "#!/bin/bash\nset -e\n" + script_content = "#!/usr/bin/env bash\nset -e\n" kustomize_outputs = [] script_template = "{template_engine} --template={infile} --variable=NAMESPACE={namespace} --stamp_info_file={info_file}\n" diff --git a/skylib/k8s_cmd.sh.tpl b/skylib/k8s_cmd.sh.tpl index 83492a97..f1df2830 100644 --- a/skylib/k8s_cmd.sh.tpl +++ b/skylib/k8s_cmd.sh.tpl @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2020 Adobe. All rights reserved. # This file is licensed to you under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. You may obtain a copy diff --git a/skylib/k8s_gitops.sh.tpl b/skylib/k8s_gitops.sh.tpl index 0de6b732..45215802 100644 --- a/skylib/k8s_gitops.sh.tpl +++ b/skylib/k8s_gitops.sh.tpl @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2020 Adobe. All rights reserved. # This file is licensed to you under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. You may obtain a copy diff --git a/skylib/k8s_test_namespace.sh.tpl b/skylib/k8s_test_namespace.sh.tpl index 9e98a1c1..ab7cffee 100644 --- a/skylib/k8s_test_namespace.sh.tpl +++ b/skylib/k8s_test_namespace.sh.tpl @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2020 Adobe. All rights reserved. # This file is licensed to you under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. You may obtain a copy diff --git a/skylib/kustomize/kustomize.bzl b/skylib/kustomize/kustomize.bzl index 51029847..08145e77 100644 --- a/skylib/kustomize/kustomize.bzl +++ b/skylib/kustomize/kustomize.bzl @@ -88,7 +88,7 @@ def _is_ignored_src(src): return basename.startswith(".") _script_template = """\ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail {kustomize} build --load_restrictor none --reorder legacy {kustomize_dir} {template_part} {resolver_part} >{out} """ diff --git a/skylib/kustomize/run-all.sh.tpl b/skylib/kustomize/run-all.sh.tpl index 36bf318e..abc5a0a4 100644 --- a/skylib/kustomize/run-all.sh.tpl +++ b/skylib/kustomize/run-all.sh.tpl @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2017 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/skylib/kustomize/set_namespace.sh b/skylib/kustomize/set_namespace.sh index 38f49322..203159be 100755 --- a/skylib/kustomize/set_namespace.sh +++ b/skylib/kustomize/set_namespace.sh @@ -1,4 +1,4 @@ -#!/bin/bash +x +#!/usr/bin/env bash # Copyright 2020 Adobe. All rights reserved. # This file is licensed to you under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. You may obtain a copy @@ -9,6 +9,8 @@ # OF ANY KIND, either express or implied. See the License for the specific language # governing permissions and limitations under the License. +set +x + if [ "$1" == "" ]; then echo usage: echo $0 'namespace out.yaml' diff --git a/skylib/kustomize/tests/set_namespace_test.sh b/skylib/kustomize/tests/set_namespace_test.sh index 6ccc1921..abd1514c 100755 --- a/skylib/kustomize/tests/set_namespace_test.sh +++ b/skylib/kustomize/tests/set_namespace_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail function test_namespace_replaced { diff --git a/skylib/tests/fork_join_test.sh b/skylib/tests/fork_join_test.sh index 223bc276..b01e9f23 100755 --- a/skylib/tests/fork_join_test.sh +++ b/skylib/tests/fork_join_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail function test_dedupe {