Skip to content

Commit

Permalink
ci: Optimize shebang of bash scripts to enhance compatibility (#33431)
Browse files Browse the repository at this point in the history
Replace `#!/bin/bash` with `#!/usr/bin/env bash` in bash scripts to ensure they execute with the bash specified by the local environment(#33426)

Signed-off-by: xocodergit <[email protected]>
  • Loading branch information
ZarrianShi authored Apr 10, 2024
1 parent 64c8b2b commit 808a436
Show file tree
Hide file tree
Showing 81 changed files with 103 additions and 81 deletions.
4 changes: 3 additions & 1 deletion bazel/coverage/fuzz_coverage_wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -e
#!/usr/bin/env bash

set -e

TEST_BINARY=$1
shift
Expand Down
2 changes: 1 addition & 1 deletion bazel/external/boringssl_fips.genrule_cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion bazel/gen_sh_test_runner.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Used in a genrule to wrap sh_test script for execution in
# //test/coverage:coverage_tests single binary.
Expand Down
2 changes: 1 addition & 1 deletion bazel/get_workspace_status
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# This file was imported from https://github.com/bazelbuild/bazel at d6fec93.

Expand Down
4 changes: 3 additions & 1 deletion bazel/setup_clang.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -e
#!/usr/bin/env bash

set -e

BAZELRC_FILE="${BAZELRC_FILE:-./clang.bazelrc}"

Expand Down
2 changes: 1 addition & 1 deletion bazel/setup_local_tsan.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

BAZELRC_FILE="${BAZELRC_FILE:-$(bazel info workspace)/local_tsan.bazelrc}"

Expand Down
2 changes: 1 addition & 1 deletion bazel/sh_test_wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Dummy shell implementation for nooping tests.
# TODO(lizan): remove when we have a solution for
Expand Down
2 changes: 1 addition & 1 deletion bazel/test/verify_tap_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

Expand Down
2 changes: 1 addition & 1 deletion bazel/test_for_benchmark_wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Set the benchmark time to 0 to just verify that the benchmark runs to
# completion. We're interacting with two different flag parsers, so the order
Expand Down
3 changes: 2 additions & 1 deletion bazel/version_update_post.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash -e
#!/usr/bin/env bash

set -e
set -o pipefail


Expand Down
4 changes: 3 additions & 1 deletion bazel/volatile_env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -e
#!/usr/bin/env bash

set -e

if [[ ! -f bazel-out/volatile-status.txt ]]; then
# shellcheck disable=SC2016
Expand Down
2 changes: 1 addition & 1 deletion ci/build_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Configure environment variables for Bazel build and test.

Expand Down
2 changes: 1 addition & 1 deletion ci/check_and_fix_format.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Run a CI build/test target, e.g. docs, asan.

Expand Down
2 changes: 1 addition & 1 deletion ci/docker_ci.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Do not ever set -x here, it is a security hazard as it will place the credentials below in the
# CI logs.
Expand Down
2 changes: 1 addition & 1 deletion ci/docker_rebuild_google-vrp.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Script to rebuild Dockerfile-envoy-google-vrp locally (i.e. not in CI) for development purposes.
# This makes use of the latest envoy:dev base image on Docker Hub as the base and takes an
Expand Down
2 changes: 1 addition & 1 deletion ci/envoy_build_sha.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash


ENVOY_BUILD_CONTAINER="$(grep envoyproxy/envoy-build-ubuntu "$(dirname "$0")"/../.bazelrc | sed -e 's#.*envoyproxy/envoy-build-ubuntu:\(.*\)#\1#' | uniq)"
Expand Down
2 changes: 1 addition & 1 deletion ci/filter_example_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Configure environment for Envoy Filter Example build and test.

Expand Down
4 changes: 3 additions & 1 deletion ci/format_pre.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -E
#!/usr/bin/env bash

set -E

# Pre-checks for validation and linting
#
Expand Down
2 changes: 1 addition & 1 deletion ci/mac_ci_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Installs the dependencies required for a macOS build via homebrew.
# Tools are not upgraded to new versions.
Expand Down
2 changes: 1 addition & 1 deletion ci/mac_ci_steps.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
4 changes: 3 additions & 1 deletion ci/reopen_branch.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -e
#!/usr/bin/env bash

set -e

ENVOY_GIT_USERNAME="${ENVOY_GIT_USERNAME:-envoy-bot}"
ENVOY_GIT_EMAIL="${ENVOY_GIT_EMAIL:-envoy-bot@users.noreply.github.com}"
Expand Down
2 changes: 1 addition & 1 deletion ci/run_clang_tidy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -eo pipefail

Expand Down
2 changes: 1 addition & 1 deletion ci/run_envoy_docker.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion ci/test_docker_ci.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Run this with `./ci/test_docker_ci.sh`.
#
Expand Down
2 changes: 1 addition & 1 deletion ci/upload_gcs_artifact.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e -o pipefail

Expand Down
4 changes: 3 additions & 1 deletion ci/verify_examples.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -E
#!/usr/bin/env bash

set -E

TESTFILTER="${1:-*}"
TESTEXCLUDES="${2}"
Expand Down
2 changes: 1 addition & 1 deletion configs/configgen.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion configs/google-vrp/launch_envoy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

cd /etc/envoy || exit
envoy "$@"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
4 changes: 3 additions & 1 deletion distribution/distrotest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -E
#!/usr/bin/env bash

set -E

FAILED=()
TESTNAME=
Expand Down
2 changes: 1 addition & 1 deletion mobile/bazelw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

Expand Down
2 changes: 1 addition & 1 deletion mobile/ci/linux_ci_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion mobile/ci/mac_ci_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion mobile/ci/start_android_emulator.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion mobile/ci/start_ios_simulator.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

Expand Down
3 changes: 2 additions & 1 deletion mobile/ci/test_size_regression.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash -e
#!/usr/bin/env bash

set -e
set -o pipefail

# Checks the absolute size and the relative size increase of a file.
Expand Down
2 changes: 1 addition & 1 deletion mobile/docs/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
4 changes: 3 additions & 1 deletion mobile/docs/publish.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash -e
#!/usr/bin/env bash

set -e

# This is run on every commit that GitHub Actions picks up. It assumes that docs have already been
# built via docs/build.sh. The commit behavior differs depending on the nature of the commit:
Expand Down
2 changes: 1 addition & 1 deletion mobile/remote
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

Expand Down
2 changes: 1 addition & 1 deletion mobile/third_party/rbe_configs/cc/cc_wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2015 The Bazel Authors. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion mobile/tools/ktfmt.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

Expand Down
2 changes: 1 addition & 1 deletion source/common/version/generate_version_linkstamp.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# This script generates a header file that is used by version_lib whenever linkstamp is not allowed.
# linkstamp is used to link in version_linkstamp.cc into the version_lib.
Expand Down
2 changes: 1 addition & 1 deletion test/common/runtime/filesystem_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion test/common/tls/ocsp/test_data/certs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Create test certificates and OCSP responses for them for unittests.

Expand Down
2 changes: 1 addition & 1 deletion test/common/tls/test_data/certs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion test/config/integration/certs/certs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion test/config_test/example_configs_test_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion test/exe/build_id_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e -o pipefail

Expand Down
2 changes: 1 addition & 1 deletion test/exe/envoy_static_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

ENVOY_BIN=${TEST_SRCDIR}/envoy/source/exe/envoy-static

Expand Down
2 changes: 1 addition & 1 deletion test/exe/pie_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion test/exe/version_out_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e -o pipefail

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Generates the thrift bindings for example.thrift. Requires that
# apache-thrift's thrift generator is installed and on the path.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Generates request and response fixtures for integration tests.

Expand Down
2 changes: 1 addition & 1 deletion test/fuzz/fuzz_runner_launcher.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Launcher for the fuzz runner engine.
# See https://github.com/bazelbuild/rules_fuzzing for more info.
Expand Down
2 changes: 1 addition & 1 deletion test/integration/admin_html/test_server_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

tmp="${TEST_TMPDIR}/test/integration/admin_html/tempfiles"
export ENVOY_BIN="${TEST_SRCDIR}/envoy/test/integration/admin_html/test_server"
Expand Down
2 changes: 1 addition & 1 deletion test/integration/admin_html/web_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# This test is semi-automatic. It builds envoy-static with
# ENVOY_ADMIN_BROWSER_TEST set, then runs the binary in a mode where
Expand Down
2 changes: 1 addition & 1 deletion test/integration/hotrestart_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# In order to get core dumps that can be debugged, uncomment the following line and then run
# the test using --spawn_strategy=local. (There may be a better way of doing this but this worked
Expand Down
2 changes: 1 addition & 1 deletion test/integration/run_envoy_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

export ENVOY_BIN="${TEST_SRCDIR}/envoy/test/integration/hotrestart_small_main"

Expand Down
2 changes: 1 addition & 1 deletion test/integration/sds_dynamic_key_rotation_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_utility.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Helper script for bash integration tests, intended to be source'd from the
# _test.sh.
Expand Down
2 changes: 1 addition & 1 deletion test/per_file_coverage.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# directory:coverage_percent
# for existing directories with low coverage.
Expand Down
Loading

0 comments on commit 808a436

Please sign in to comment.