Skip to content

Commit

Permalink
treewide: use /usr/bin/env bash instead of /bin/bash
Browse files Browse the repository at this point in the history
This commit switch most usage of "/bin/bash" to "/usr/bin/env bash".
This allows to conform to the PATH env variable when invoking bash which
is especially important on distros/installs in which bash is *NOT*
installed in /bin/bash (for instance in some more "exotic" distros like NixOS
or even if bash is installed in /usr/local/bin/ for whatever reasons).

The goal here is not to be perfectly exhaustive but to address most
low hanging fruits whenever this happens and most importantly should
ease the Cilium contributions for people which don't have bash
installed in /bin/bash.

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>
  • Loading branch information
MrFreezeex authored and joestringer committed May 18, 2023
1 parent b2de07a commit 2c367de
Show file tree
Hide file tree
Showing 89 changed files with 91 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/gcp-vm-startup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

apt-get update
apt-get install -y --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion .travis/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -o errexit

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

CLANG_VERSION=10.0.0

Expand Down
2 changes: 1 addition & 1 deletion Makefile.defs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright Authors of Cilium
# SPDX-License-Identifier: Apache-2.0

SHELL := /bin/bash
SHELL := /usr/bin/env bash
.SHELLFLAGS := -eu -o pipefail -c

# define a function replacing spaces with commas in a list
Expand Down
2 changes: 1 addition & 1 deletion contrib/ansible/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

ansible-playbook -u vagrant --skip-tags=common:delete site.yml
ansible-playbook -u vagrant --tags=common:delete site.yml
2 changes: 1 addition & 1 deletion contrib/backporting/check-stable
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2016 The Kubernetes Authors All rights reserved.
# Copyright Authors of Cilium
Expand Down
2 changes: 1 addition & 1 deletion contrib/backporting/cherry-pick
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

source $(dirname $(readlink -ne $BASH_SOURCE))/common.sh
Expand Down
2 changes: 1 addition & 1 deletion contrib/backporting/common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/backporting/start-backport
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/backporting/submit-backport
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

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

set -o errexit
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion contrib/gofat/gofat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/usr/bin/env bash
eval `go build -work -a 2>&1`
find $WORK -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed s@_pkg_.a@importcfg@g | xargs -I{} echo {} | awk '{print $1; system("bash -c '\''grep importmap "$2" | head -1'\''")}'
2 changes: 1 addition & 1 deletion contrib/k8s/k8s-cilium-exec.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/k8s/k8s-extract-clustermesh-nodeport-secret.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/k8s/k8s-get-cilium-pod.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/k8s/k8s-heap-dump.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/k8s/k8s-import-clustermesh-secrets.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/k8s/k8s-unmanaged.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/policy-watcher/cilium-policy-watcher
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 contrib/policy-watcher/post-merge
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"

Expand Down
2 changes: 1 addition & 1 deletion contrib/release/bump-docker-stable.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/release/bump-readme.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/release/lib/common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion contrib/release/lib/gitlib.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion contrib/release/post-release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/release/prep-changelog.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/release/pull-docker-manifests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/release/start-release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/release/submit-release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/release/tag-release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/add_vagrant_box.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 contrib/scripts/bugtool-multinode-gather.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Usage
# ./bugtool-multinode-gather.sh <OUTPUT_DIR> <NAMESPACE> <LABEL> <OUTPUT_ARCHIVE>
Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/check-assert-deep-equals.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# check-assert-deep-equals.sh checks whether DeepEquals checker from
# pkg/checker is used every time instead of the checker from gopkg.in/check.v1.
Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/check-logging-subsys-field.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# check-logging-subsys-field.sh checks whether all logging entry instancs
# created from DefaultLogger contain the LogSubsys field. This is required for
Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/check-preflight-clusterrole.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

cd install/kubernetes/cilium/templates
echo "Checking for differences between preflight and agent clusterrole"
Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/check-viper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/custom-vet-check.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

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

# Ensure sort order doesn't depend on locale
export LANG=en_US.UTF-8
Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/go-mod-update-cloud-providers.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# This script updates all vendored cloud provider SDK Go modules to their latest
# version.
Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/jenkins-failures.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

DIR=$(dirname $(readlink -ne $BASH_SOURCE))

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

# Here are a set of functions designed to be sourced into your shell.
# They implement commands which build, push, and install the Cilium agent and
Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/lock-check.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/print-chart-version.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# shellcheck disable=SC2001

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/push_manifest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

IMAGE_NAME=${1:-}
Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/quarantine.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion contrib/scripts/rand-check.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/shell/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion contrib/shell/util.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
# Copyright Authors of Cilium
#
Expand Down
2 changes: 1 addition & 1 deletion contrib/testing/integrations.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright Authors of Cilium
# SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion contrib/vagrant/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
2 changes: 1 addition & 1 deletion examples/kubernetes-cassandra/cass-populate-tables.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
#!/usr/bin/env bash

CASS_SERVER_POD=$(kubectl get pods -l app=cass-server -o jsonpath='{.items[0].metadata.name}')

Expand Down
2 changes: 1 addition & 1 deletion examples/kubernetes-kafka/kafka-sw-gen-traffic.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
#!/usr/bin/env bash


HQ_POD=$(kubectl get pods -l app=empire-hq -o jsonpath='{.items[0].metadata.name}')
Expand Down
2 changes: 1 addition & 1 deletion examples/kubernetes-memcached/memcd-env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
#!/usr/bin/env bash
#define ENV variables for memcached demo
MEMCD_SERVER_POD=$(kubectl get pods -l app=memcd-server -o jsonpath='{.items[0].metadata.name}')
AWING_POD=$(kubectl get pods -l app=a-wing -o jsonpath='{.items[0].metadata.name}')
Expand Down
2 changes: 1 addition & 1 deletion test/archive_test_results.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

cd ${WORKSPACE}/test

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

set -x

Expand Down
2 changes: 1 addition & 1 deletion test/bigtcp/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion test/bpf/probes-test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Cilium

Expand Down
2 changes: 1 addition & 1 deletion test/eks/release-cluster.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/eks/select-cluster.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/envoy/envoy-smoke-test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "${dir}/helpers.bash"
Expand Down
4 changes: 3 additions & 1 deletion test/fuzzing/oss-fuzz-build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#/bin/bash -eu
#!/usr/bin/env bash

set -eu

# The oss-fuzz-build.sh is meant to only be run inside the OSS-Fuzz build environment.
# In that environment, the fuzzers are built with go build which does not include _test.go files
Expand Down
2 changes: 1 addition & 1 deletion test/get-vagrant-kubeconfig.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/gke/create-cluster.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

if [ "$#" != 1 ]; then
>&2 printf "Illegal number of parameters\n"
Expand Down
2 changes: 1 addition & 1 deletion test/gke/release-cluster.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

Expand Down
2 changes: 1 addition & 1 deletion test/k8s/manifests/frr.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
- "/bin/sh"
- "-c"
- |
#!/bin/bash
#!/usr/bin/env bash

set -o errexit
set -o pipefail
Expand Down
Loading

0 comments on commit 2c367de

Please sign in to comment.