summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2020-03-04 09:35:06 +0000
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-03-05 17:27:07 +0100
commitff12a7954c1993dd1f38d49052e79bb245d75dc4 (patch)
treee82e13efe903b28a33862f2f95c1dbf0c4d451c6
parenteda0cbf07186d16a160bd1d810613586fdbdf587 (diff)
downloadsystemd-ff12a7954c1993dd1f38d49052e79bb245d75dc4.tar.gz
treewide: more portable bash shebangs
As in 2a5fcfae024ffc370bb780572279f45a1da3f946 and in 3e67e5c9928f8b1e1c5a63def88d53ed1fed12eb using /usr/bin/env allows bash to be looked up in PATH rather than being hard-coded. As with the previous changes the same arguments apply - distributions have scripts to rewrite shebangs on installation and they know what locations to rely on. - For tests/compilation we should rather rely on the user to have setup there PATH correctly. In particular this makes testing from git easier on NixOS where do not provide /bin/bash to improve compose-ability.
-rwxr-xr-xconfigure3
-rwxr-xr-xsrc/basic/linux/update.sh2
-rw-r--r--src/kernel-install/00-entry-directory.install2
-rw-r--r--src/kernel-install/50-depmod.install2
-rw-r--r--src/kernel-install/90-loaderentry.install2
-rw-r--r--src/kernel-install/kernel-install2
-rwxr-xr-xtest/TEST-01-BASIC/test.sh2
-rwxr-xr-xtest/TEST-02-CRYPTSETUP/test.sh2
-rwxr-xr-xtest/TEST-03-JOBS/test-jobs.sh3
-rwxr-xr-xtest/TEST-03-JOBS/test.sh2
-rwxr-xr-xtest/TEST-04-JOURNAL/test-journal.sh2
-rwxr-xr-xtest/TEST-04-JOURNAL/test.sh2
-rwxr-xr-xtest/TEST-05-RLIMITS/test-rlimits.sh2
-rwxr-xr-xtest/TEST-05-RLIMITS/test.sh2
-rwxr-xr-xtest/TEST-06-SELINUX/test-selinux-checks.sh2
-rwxr-xr-xtest/TEST-06-SELINUX/test.sh2
-rwxr-xr-xtest/TEST-07-ISSUE-1981/test-segfault.sh2
-rwxr-xr-xtest/TEST-07-ISSUE-1981/test.sh2
-rwxr-xr-xtest/TEST-08-ISSUE-2730/test.sh2
-rwxr-xr-xtest/TEST-09-ISSUE-2691/test.sh2
-rwxr-xr-xtest/TEST-10-ISSUE-2467/test.sh2
-rwxr-xr-xtest/TEST-11-ISSUE-3166/test.sh5
-rwxr-xr-xtest/TEST-12-ISSUE-3171/test.sh4
-rwxr-xr-xtest/TEST-13-NSPAWN-SMOKE/create-busybox-container2
-rwxr-xr-xtest/TEST-13-NSPAWN-SMOKE/test.sh4
-rwxr-xr-xtest/TEST-14-MACHINE-ID/test.sh4
-rwxr-xr-xtest/TEST-15-DROPIN/test.sh2
-rwxr-xr-xtest/TEST-16-EXTEND-TIMEOUT/assess.sh2
-rwxr-xr-xtest/TEST-16-EXTEND-TIMEOUT/extend_timeout_test_service.sh2
-rwxr-xr-xtest/TEST-16-EXTEND-TIMEOUT/test.sh2
-rwxr-xr-xtest/TEST-17-UDEV-WANTS/test.sh2
-rwxr-xr-xtest/TEST-17-UDEV-WANTS/testsuite.sh2
-rwxr-xr-xtest/TEST-18-FAILUREACTION/test.sh2
-rwxr-xr-xtest/TEST-18-FAILUREACTION/testsuite.sh2
-rwxr-xr-xtest/TEST-19-DELEGATE/test.sh2
-rwxr-xr-xtest/TEST-19-DELEGATE/testsuite.sh2
-rwxr-xr-xtest/TEST-20-MAINPIDGAMES/test.sh2
-rwxr-xr-xtest/TEST-20-MAINPIDGAMES/testsuite.sh8
-rwxr-xr-xtest/TEST-21-SYSUSERS/test.sh2
-rwxr-xr-xtest/TEST-22-TMPFILES/run-tmpfiles-tests.sh2
-rwxr-xr-xtest/TEST-22-TMPFILES/test-09.sh2
-rwxr-xr-xtest/TEST-22-TMPFILES/test.sh2
-rwxr-xr-xtest/TEST-23-TYPE-EXEC/test.sh2
-rwxr-xr-xtest/TEST-23-TYPE-EXEC/testsuite.sh2
-rwxr-xr-xtest/TEST-24-UNIT-TESTS/test.sh2
-rwxr-xr-xtest/TEST-24-UNIT-TESTS/testsuite.sh2
-rwxr-xr-xtest/TEST-25-IMPORT/test.sh2
-rwxr-xr-xtest/TEST-25-IMPORT/testsuite.sh2
-rwxr-xr-xtest/TEST-26-SETENV/test.sh2
-rwxr-xr-xtest/TEST-26-SETENV/testsuite.sh2
-rwxr-xr-xtest/TEST-27-STDOUTFILE/test.sh2
-rwxr-xr-xtest/TEST-27-STDOUTFILE/testsuite.sh2
-rwxr-xr-xtest/TEST-28-PERCENTJ-WANTEDBY/test.sh2
-rwxr-xr-xtest/TEST-29-UDEV-ID_RENAMING/test.sh2
-rwxr-xr-xtest/TEST-29-UDEV-ID_RENAMING/testsuite.sh2
-rwxr-xr-xtest/TEST-30-ONCLOCKCHANGE/test.sh2
-rwxr-xr-xtest/TEST-30-ONCLOCKCHANGE/testsuite.sh2
-rwxr-xr-xtest/TEST-31-DEVICE-ENUMERATION/test.sh2
-rwxr-xr-xtest/TEST-31-DEVICE-ENUMERATION/testsuite.sh2
-rwxr-xr-xtest/TEST-32-OOMPOLICY/test.sh2
-rwxr-xr-xtest/TEST-32-OOMPOLICY/testsuite.sh2
-rwxr-xr-xtest/TEST-33-CLEAN-UNIT/test.sh2
-rwxr-xr-xtest/TEST-33-CLEAN-UNIT/testsuite.sh2
-rwxr-xr-xtest/TEST-34-DYNAMICUSERMIGRATE/test.sh2
-rwxr-xr-xtest/TEST-34-DYNAMICUSERMIGRATE/testsuite.sh2
-rwxr-xr-xtest/TEST-35-NETWORK-GENERATOR/test.sh2
-rwxr-xr-xtest/TEST-36-NUMAPOLICY/test.sh2
-rwxr-xr-xtest/TEST-36-NUMAPOLICY/testsuite.sh2
-rwxr-xr-xtest/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh2
-rwxr-xr-xtest/TEST-37-RUNTIMEDIRECTORYPRESERVE/testsuite.sh2
-rwxr-xr-xtest/TEST-39-EXECRELOAD/test.sh2
-rw-r--r--test/TEST-39-EXECRELOAD/testsuite.sh2
-rwxr-xr-xtest/TEST-40-EXEC-COMMAND-EX/test.sh2
-rwxr-xr-xtest/TEST-40-EXEC-COMMAND-EX/testsuite.sh2
-rwxr-xr-xtest/TEST-41-ONESHOT-RESTART/test.sh2
-rwxr-xr-xtest/TEST-41-ONESHOT-RESTART/testsuite.sh2
-rwxr-xr-xtest/TEST-42-EXECSTOPPOST/test.sh2
-rwxr-xr-xtest/TEST-42-EXECSTOPPOST/testsuite.sh8
-rwxr-xr-xtest/TEST-43-PRIVATEUSER-UNPRIV/test.sh2
-rwxr-xr-xtest/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh2
-rwxr-xr-xtest/TEST-44-LOG-NAMESPACE/test.sh2
-rwxr-xr-xtest/TEST-44-LOG-NAMESPACE/testsuite.sh2
-rwxr-xr-xtest/TEST-45-REPART/test.sh2
-rwxr-xr-xtest/TEST-45-REPART/testsuite.sh2
-rwxr-xr-xtest/TEST-46-HOMED/test.sh2
-rwxr-xr-xtest/TEST-46-HOMED/testsuite.sh2
-rwxr-xr-xtest/mocks/fsck2
-rwxr-xr-xtest/run-integration-tests.sh3
-rwxr-xr-xtest/test-efi-create-disk.sh3
-rw-r--r--test/test-functions12
-rwxr-xr-xtools/check-directives.sh2
-rwxr-xr-xtools/coverity.sh2
-rwxr-xr-xtools/meson-vcs-tag.sh2
-rwxr-xr-xtools/oss-fuzz.sh2
94 files changed, 114 insertions, 109 deletions
diff --git a/configure b/configure
index a9db8a1cff..5247074b6d 100755
--- a/configure
+++ b/configure
@@ -1,4 +1,5 @@
-#!/bin/bash -e
+#!/usr/bin/env bash
+set -e
cflags=CFLAGS="$CFLAGS"
cxxflags=CXXFLAGS="$CXXFLAGS"
diff --git a/src/basic/linux/update.sh b/src/basic/linux/update.sh
index b232070193..d272ffd296 100755
--- a/src/basic/linux/update.sh
+++ b/src/basic/linux/update.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -eu
diff --git a/src/kernel-install/00-entry-directory.install b/src/kernel-install/00-entry-directory.install
index 2aa8c58319..21c09fa691 100644
--- a/src/kernel-install/00-entry-directory.install
+++ b/src/kernel-install/00-entry-directory.install
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
diff --git a/src/kernel-install/50-depmod.install b/src/kernel-install/50-depmod.install
index 268b6ce0a5..3850eacef5 100644
--- a/src/kernel-install/50-depmod.install
+++ b/src/kernel-install/50-depmod.install
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install
index 133378da6b..6c0e27ba3a 100644
--- a/src/kernel-install/90-loaderentry.install
+++ b/src/kernel-install/90-loaderentry.install
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install
index e7f2beb570..4812464da9 100644
--- a/src/kernel-install/kernel-install
+++ b/src/kernel-install/kernel-install
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# SPDX-License-Identifier: LGPL-2.1+
diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh
index 007ee7a91f..0eaa8f991a 100755
--- a/test/TEST-01-BASIC/test.sh
+++ b/test/TEST-01-BASIC/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Basic systemd setup"
RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes}
diff --git a/test/TEST-02-CRYPTSETUP/test.sh b/test/TEST-02-CRYPTSETUP/test.sh
index a7563f4462..a859b345d0 100755
--- a/test/TEST-02-CRYPTSETUP/test.sh
+++ b/test/TEST-02-CRYPTSETUP/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="cryptsetup systemd setup"
TEST_NO_NSPAWN=1
diff --git a/test/TEST-03-JOBS/test-jobs.sh b/test/TEST-03-JOBS/test-jobs.sh
index fca6cccb4f..85efeeb741 100755
--- a/test/TEST-03-JOBS/test-jobs.sh
+++ b/test/TEST-03-JOBS/test-jobs.sh
@@ -1,4 +1,5 @@
-#!/bin/bash -ex
+#!/usr/bin/env bash
+set -ex
# Test merging of a --job-mode=ignore-dependencies job into a previously
# installed job.
diff --git a/test/TEST-03-JOBS/test.sh b/test/TEST-03-JOBS/test.sh
index 50b7bce3ed..5299464b81 100755
--- a/test/TEST-03-JOBS/test.sh
+++ b/test/TEST-03-JOBS/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Job-related tests"
TEST_NO_QEMU=1
diff --git a/test/TEST-04-JOURNAL/test-journal.sh b/test/TEST-04-JOURNAL/test-journal.sh
index de27eb0064..1431dad862 100755
--- a/test/TEST-04-JOURNAL/test-journal.sh
+++ b/test/TEST-04-JOURNAL/test-journal.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -x
set -e
set -o pipefail
diff --git a/test/TEST-04-JOURNAL/test.sh b/test/TEST-04-JOURNAL/test.sh
index a18d21533e..af96dfd719 100755
--- a/test/TEST-04-JOURNAL/test.sh
+++ b/test/TEST-04-JOURNAL/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Journal-related tests"
diff --git a/test/TEST-05-RLIMITS/test-rlimits.sh b/test/TEST-05-RLIMITS/test-rlimits.sh
index b4d79c9655..86b57601fe 100755
--- a/test/TEST-05-RLIMITS/test-rlimits.sh
+++ b/test/TEST-05-RLIMITS/test-rlimits.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -x
set -e
set -o pipefail
diff --git a/test/TEST-05-RLIMITS/test.sh b/test/TEST-05-RLIMITS/test.sh
index 87fb89e781..bda37ef212 100755
--- a/test/TEST-05-RLIMITS/test.sh
+++ b/test/TEST-05-RLIMITS/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Resource limits-related tests"
diff --git a/test/TEST-06-SELINUX/test-selinux-checks.sh b/test/TEST-06-SELINUX/test-selinux-checks.sh
index dae48cd4b2..9e722e362e 100755
--- a/test/TEST-06-SELINUX/test-selinux-checks.sh
+++ b/test/TEST-06-SELINUX/test-selinux-checks.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -x
set -e
set -o pipefail
diff --git a/test/TEST-06-SELINUX/test.sh b/test/TEST-06-SELINUX/test.sh
index 646dfe024a..46dc1cd805 100755
--- a/test/TEST-06-SELINUX/test.sh
+++ b/test/TEST-06-SELINUX/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="SELinux tests"
TEST_NO_NSPAWN=1
diff --git a/test/TEST-07-ISSUE-1981/test-segfault.sh b/test/TEST-07-ISSUE-1981/test-segfault.sh
index 82339c23cd..fbb2d1d30a 100755
--- a/test/TEST-07-ISSUE-1981/test-segfault.sh
+++ b/test/TEST-07-ISSUE-1981/test-segfault.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -x
set -e
diff --git a/test/TEST-07-ISSUE-1981/test.sh b/test/TEST-07-ISSUE-1981/test.sh
index e72c11fd1b..7927294a8a 100755
--- a/test/TEST-07-ISSUE-1981/test.sh
+++ b/test/TEST-07-ISSUE-1981/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981"
TEST_NO_QEMU=1
diff --git a/test/TEST-08-ISSUE-2730/test.sh b/test/TEST-08-ISSUE-2730/test.sh
index dd87913143..2fedef7b58 100755
--- a/test/TEST-08-ISSUE-2730/test.sh
+++ b/test/TEST-08-ISSUE-2730/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730"
TEST_NO_NSPAWN=1
diff --git a/test/TEST-09-ISSUE-2691/test.sh b/test/TEST-09-ISSUE-2691/test.sh
index 955538c850..efe75d140b 100755
--- a/test/TEST-09-ISSUE-2691/test.sh
+++ b/test/TEST-09-ISSUE-2691/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691"
TEST_NO_NSPAWN=1
diff --git a/test/TEST-10-ISSUE-2467/test.sh b/test/TEST-10-ISSUE-2467/test.sh
index 7bb2569630..1761ad1e43 100755
--- a/test/TEST-10-ISSUE-2467/test.sh
+++ b/test/TEST-10-ISSUE-2467/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467"
diff --git a/test/TEST-11-ISSUE-3166/test.sh b/test/TEST-11-ISSUE-3166/test.sh
index 81c12a2783..e444414a90 100755
--- a/test/TEST-11-ISSUE-3166/test.sh
+++ b/test/TEST-11-ISSUE-3166/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166"
TEST_NO_NSPAWN=1
@@ -41,7 +41,8 @@ EOF
cat >$initdir/test-fail-on-restart.sh <<'EOF'
-#!/bin/bash -x
+#!/usr/bin/env bash
+set -x
systemctl start fail-on-restart.service
active_state=$(systemctl show --property ActiveState fail-on-restart.service)
diff --git a/test/TEST-12-ISSUE-3171/test.sh b/test/TEST-12-ISSUE-3171/test.sh
index d9a0e1a3dd..e30c36ed86 100755
--- a/test/TEST-12-ISSUE-3171/test.sh
+++ b/test/TEST-12-ISSUE-3171/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171"
TEST_NO_QEMU=1
@@ -29,7 +29,7 @@ Type=oneshot
EOF
cat >$initdir/test-socket-group.sh <<'EOF'
-#!/bin/bash
+#!/usr/bin/env bash
set -x
set -e
set -o pipefail
diff --git a/test/TEST-13-NSPAWN-SMOKE/create-busybox-container b/test/TEST-13-NSPAWN-SMOKE/create-busybox-container
index 868dfd852a..08fb5d4aa6 100755
--- a/test/TEST-13-NSPAWN-SMOKE/create-busybox-container
+++ b/test/TEST-13-NSPAWN-SMOKE/create-busybox-container
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -u
diff --git a/test/TEST-13-NSPAWN-SMOKE/test.sh b/test/TEST-13-NSPAWN-SMOKE/test.sh
index de504df632..974b239d80 100755
--- a/test/TEST-13-NSPAWN-SMOKE/test.sh
+++ b/test/TEST-13-NSPAWN-SMOKE/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="systemd-nspawn smoke test"
TEST_NO_NSPAWN=1
@@ -33,7 +33,7 @@ Type=oneshot
EOF
cat >$initdir/test-nspawn.sh <<'EOF'
-#!/bin/bash
+#!/usr/bin/env bash
set -x
set -e
set -u
diff --git a/test/TEST-14-MACHINE-ID/test.sh b/test/TEST-14-MACHINE-ID/test.sh
index 72d7eacbf6..74cabf86aa 100755
--- a/test/TEST-14-MACHINE-ID/test.sh
+++ b/test/TEST-14-MACHINE-ID/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="/etc/machine-id testing"
TEST_NO_NSPAWN=1
@@ -29,7 +29,7 @@ Type=oneshot
EOF
cat >$initdir/test-machine-id-setup.sh <<'EOF'
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -x
diff --git a/test/TEST-15-DROPIN/test.sh b/test/TEST-15-DROPIN/test.sh
index a1d0c618d9..63bbd35051 100755
--- a/test/TEST-15-DROPIN/test.sh
+++ b/test/TEST-15-DROPIN/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Dropin tests"
TEST_NO_QEMU=1
diff --git a/test/TEST-16-EXTEND-TIMEOUT/assess.sh b/test/TEST-16-EXTEND-TIMEOUT/assess.sh
index e7f643f9ad..6f98810b30 100755
--- a/test/TEST-16-EXTEND-TIMEOUT/assess.sh
+++ b/test/TEST-16-EXTEND-TIMEOUT/assess.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -v -x
rm -f /test.log
diff --git a/test/TEST-16-EXTEND-TIMEOUT/extend_timeout_test_service.sh b/test/TEST-16-EXTEND-TIMEOUT/extend_timeout_test_service.sh
index 1fd2768fd2..40bf046dcd 100755
--- a/test/TEST-16-EXTEND-TIMEOUT/extend_timeout_test_service.sh
+++ b/test/TEST-16-EXTEND-TIMEOUT/extend_timeout_test_service.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -x
set -e
set -o pipefail
diff --git a/test/TEST-16-EXTEND-TIMEOUT/test.sh b/test/TEST-16-EXTEND-TIMEOUT/test.sh
index c5f8af6ec6..43d9f1278b 100755
--- a/test/TEST-16-EXTEND-TIMEOUT/test.sh
+++ b/test/TEST-16-EXTEND-TIMEOUT/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="EXTEND_TIMEOUT_USEC=usec start/runtime/stop tests"
SKIP_INITRD=yes
diff --git a/test/TEST-17-UDEV-WANTS/test.sh b/test/TEST-17-UDEV-WANTS/test.sh
index 1cdbbd2d8a..e196003e80 100755
--- a/test/TEST-17-UDEV-WANTS/test.sh
+++ b/test/TEST-17-UDEV-WANTS/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="UDEV SYSTEMD_WANTS property"
TEST_NO_NSPAWN=1
diff --git a/test/TEST-17-UDEV-WANTS/testsuite.sh b/test/TEST-17-UDEV-WANTS/testsuite.sh
index ceac3697b5..989c190ce3 100755
--- a/test/TEST-17-UDEV-WANTS/testsuite.sh
+++ b/test/TEST-17-UDEV-WANTS/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-18-FAILUREACTION/test.sh b/test/TEST-18-FAILUREACTION/test.sh
index e9f6ee7afe..b6231e6f5a 100755
--- a/test/TEST-18-FAILUREACTION/test.sh
+++ b/test/TEST-18-FAILUREACTION/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="FailureAction= operation"
diff --git a/test/TEST-18-FAILUREACTION/testsuite.sh b/test/TEST-18-FAILUREACTION/testsuite.sh
index 6ab2638d8c..e471cda51b 100755
--- a/test/TEST-18-FAILUREACTION/testsuite.sh
+++ b/test/TEST-18-FAILUREACTION/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-19-DELEGATE/test.sh b/test/TEST-19-DELEGATE/test.sh
index 706f0e9fbb..2fbfef3062 100755
--- a/test/TEST-19-DELEGATE/test.sh
+++ b/test/TEST-19-DELEGATE/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test cgroup delegation in the unified hierarchy"
TEST_NO_NSPAWN=1
diff --git a/test/TEST-19-DELEGATE/testsuite.sh b/test/TEST-19-DELEGATE/testsuite.sh
index a2cb2b875f..57831c267f 100755
--- a/test/TEST-19-DELEGATE/testsuite.sh
+++ b/test/TEST-19-DELEGATE/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-20-MAINPIDGAMES/test.sh b/test/TEST-20-MAINPIDGAMES/test.sh
index 05fa847a65..4cf1b79f9a 100755
--- a/test/TEST-20-MAINPIDGAMES/test.sh
+++ b/test/TEST-20-MAINPIDGAMES/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test changing main PID"
diff --git a/test/TEST-20-MAINPIDGAMES/testsuite.sh b/test/TEST-20-MAINPIDGAMES/testsuite.sh
index 904ac0e3b8..f894026070 100755
--- a/test/TEST-20-MAINPIDGAMES/testsuite.sh
+++ b/test/TEST-20-MAINPIDGAMES/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
@@ -55,7 +55,7 @@ systemd-notify --uid=1000 MAINPID=$$
test `systemctl show -p MainPID --value testsuite.service` -eq $$
cat >/tmp/mainpid.sh <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
set -eux
set -o pipefail
@@ -79,7 +79,7 @@ systemd-run --unit=mainpidsh.service -p StandardOutput=tty -p StandardError=tty
test `systemctl show -p MainPID --value mainpidsh.service` -eq `cat /run/mainpidsh/pid`
cat >/tmp/mainpid2.sh <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
set -eux
set -o pipefail
@@ -104,7 +104,7 @@ systemd-run --unit=mainpidsh2.service -p StandardOutput=tty -p StandardError=tty
test `systemctl show -p MainPID --value mainpidsh2.service` -eq `cat /run/mainpidsh2/pid`
cat >/dev/shm/mainpid3.sh <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
set -eux
set -o pipefail
diff --git a/test/TEST-21-SYSUSERS/test.sh b/test/TEST-21-SYSUSERS/test.sh
index aed921e39e..c4b221af8a 100755
--- a/test/TEST-21-SYSUSERS/test.sh
+++ b/test/TEST-21-SYSUSERS/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Sysuser-related tests"
diff --git a/test/TEST-22-TMPFILES/run-tmpfiles-tests.sh b/test/TEST-22-TMPFILES/run-tmpfiles-tests.sh
index 3ad652f4ed..a0158f0421 100755
--- a/test/TEST-22-TMPFILES/run-tmpfiles-tests.sh
+++ b/test/TEST-22-TMPFILES/run-tmpfiles-tests.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -x
set -e
diff --git a/test/TEST-22-TMPFILES/test-09.sh b/test/TEST-22-TMPFILES/test-09.sh
index b69abda644..c558dfd4db 100755
--- a/test/TEST-22-TMPFILES/test-09.sh
+++ b/test/TEST-22-TMPFILES/test-09.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -x
diff --git a/test/TEST-22-TMPFILES/test.sh b/test/TEST-22-TMPFILES/test.sh
index 32c3abdeab..aa6efcfb48 100755
--- a/test/TEST-22-TMPFILES/test.sh
+++ b/test/TEST-22-TMPFILES/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Tmpfiles related tests"
TEST_NO_QEMU=1
diff --git a/test/TEST-23-TYPE-EXEC/test.sh b/test/TEST-23-TYPE-EXEC/test.sh
index 127d39319a..ebc9fe4c85 100755
--- a/test/TEST-23-TYPE-EXEC/test.sh
+++ b/test/TEST-23-TYPE-EXEC/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test Type=exec"
diff --git a/test/TEST-23-TYPE-EXEC/testsuite.sh b/test/TEST-23-TYPE-EXEC/testsuite.sh
index 50d6754b96..5e2966f848 100755
--- a/test/TEST-23-TYPE-EXEC/testsuite.sh
+++ b/test/TEST-23-TYPE-EXEC/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-24-UNIT-TESTS/test.sh b/test/TEST-24-UNIT-TESTS/test.sh
index 3c993e67f7..c9198fb6c7 100755
--- a/test/TEST-24-UNIT-TESTS/test.sh
+++ b/test/TEST-24-UNIT-TESTS/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Run unit tests under containers"
RUN_IN_UNPRIVILEGED_CONTAINER=yes
diff --git a/test/TEST-24-UNIT-TESTS/testsuite.sh b/test/TEST-24-UNIT-TESTS/testsuite.sh
index e33d04d043..cc78adbbe9 100755
--- a/test/TEST-24-UNIT-TESTS/testsuite.sh
+++ b/test/TEST-24-UNIT-TESTS/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
#set -ex
#set -o pipefail
diff --git a/test/TEST-25-IMPORT/test.sh b/test/TEST-25-IMPORT/test.sh
index c0f51f3b89..14265cdfc5 100755
--- a/test/TEST-25-IMPORT/test.sh
+++ b/test/TEST-25-IMPORT/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test importd"
diff --git a/test/TEST-25-IMPORT/testsuite.sh b/test/TEST-25-IMPORT/testsuite.sh
index d4efd71e06..6dcb780508 100755
--- a/test/TEST-25-IMPORT/testsuite.sh
+++ b/test/TEST-25-IMPORT/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-26-SETENV/test.sh b/test/TEST-26-SETENV/test.sh
index 065a8e461c..ee0f562277 100755
--- a/test/TEST-26-SETENV/test.sh
+++ b/test/TEST-26-SETENV/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test setenv"
diff --git a/test/TEST-26-SETENV/testsuite.sh b/test/TEST-26-SETENV/testsuite.sh
index 0abbf95326..89c0937c8d 100755
--- a/test/TEST-26-SETENV/testsuite.sh
+++ b/test/TEST-26-SETENV/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-27-STDOUTFILE/test.sh b/test/TEST-27-STDOUTFILE/test.sh
index c8338736bb..66c98e5675 100755
--- a/test/TEST-27-STDOUTFILE/test.sh
+++ b/test/TEST-27-STDOUTFILE/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test StandardOutput=file:"
diff --git a/test/TEST-27-STDOUTFILE/testsuite.sh b/test/TEST-27-STDOUTFILE/testsuite.sh
index 2c813da720..c522f75dbc 100755
--- a/test/TEST-27-STDOUTFILE/testsuite.sh
+++ b/test/TEST-27-STDOUTFILE/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-28-PERCENTJ-WANTEDBY/test.sh b/test/TEST-28-PERCENTJ-WANTEDBY/test.sh
index 3427ba7a91..934e1bc70c 100755
--- a/test/TEST-28-PERCENTJ-WANTEDBY/test.sh
+++ b/test/TEST-28-PERCENTJ-WANTEDBY/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Ensure %j Wants directives work"
RUN_IN_UNPRIVILEGED_CONTAINER=yes
diff --git a/test/TEST-29-UDEV-ID_RENAMING/test.sh b/test/TEST-29-UDEV-ID_RENAMING/test.sh
index 7d173c8422..fb570b0347 100755
--- a/test/TEST-29-UDEV-ID_RENAMING/test.sh
+++ b/test/TEST-29-UDEV-ID_RENAMING/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="UDEV ID_RENAMING property"
TEST_NO_NSPAWN=1
diff --git a/test/TEST-29-UDEV-ID_RENAMING/testsuite.sh b/test/TEST-29-UDEV-ID_RENAMING/testsuite.sh
index eb9b2ffb89..5abdb53eb3 100755
--- a/test/TEST-29-UDEV-ID_RENAMING/testsuite.sh
+++ b/test/TEST-29-UDEV-ID_RENAMING/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-30-ONCLOCKCHANGE/test.sh b/test/TEST-30-ONCLOCKCHANGE/test.sh
index 8976e95308..9e2c11238c 100755
--- a/test/TEST-30-ONCLOCKCHANGE/test.sh
+++ b/test/TEST-30-ONCLOCKCHANGE/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test OnClockChange= + OnTimezoneChange="
TEST_NO_NSPAWN=1
diff --git a/test/TEST-30-ONCLOCKCHANGE/testsuite.sh b/test/TEST-30-ONCLOCKCHANGE/testsuite.sh
index 7b24922e62..a507ffcd7b 100755
--- a/test/TEST-30-ONCLOCKCHANGE/testsuite.sh
+++ b/test/TEST-30-ONCLOCKCHANGE/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-31-DEVICE-ENUMERATION/test.sh b/test/TEST-31-DEVICE-ENUMERATION/test.sh
index e88e0c367a..7bc9298dc1 100755
--- a/test/TEST-31-DEVICE-ENUMERATION/test.sh
+++ b/test/TEST-31-DEVICE-ENUMERATION/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="plugged -> dead -> plugged issue #11997"
TEST_NO_NSPAWN=1
diff --git a/test/TEST-31-DEVICE-ENUMERATION/testsuite.sh b/test/TEST-31-DEVICE-ENUMERATION/testsuite.sh
index 047c1be06f..fcff82d804 100755
--- a/test/TEST-31-DEVICE-ENUMERATION/testsuite.sh
+++ b/test/TEST-31-DEVICE-ENUMERATION/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -o pipefail
diff --git a/test/TEST-32-OOMPOLICY/test.sh b/test/TEST-32-OOMPOLICY/test.sh
index 1726b21fc3..36aad419ea 100755
--- a/test/TEST-32-OOMPOLICY/test.sh
+++ b/test/TEST-32-OOMPOLICY/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test OOM killer logic"
TEST_NO_NSPAWN=1
diff --git a/test/TEST-32-OOMPOLICY/testsuite.sh b/test/TEST-32-OOMPOLICY/testsuite.sh
index 8aab487c6e..aafafc1183 100755
--- a/test/TEST-32-OOMPOLICY/testsuite.sh
+++ b/test/TEST-32-OOMPOLICY/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-33-CLEAN-UNIT/test.sh b/test/TEST-33-CLEAN-UNIT/test.sh
index b3316bdc26..310cf7b145 100755
--- a/test/TEST-33-CLEAN-UNIT/test.sh
+++ b/test/TEST-33-CLEAN-UNIT/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
diff --git a/test/TEST-33-CLEAN-UNIT/testsuite.sh b/test/TEST-33-CLEAN-UNIT/testsuite.sh
index 0272a2305b..0a6ee57b99 100755
--- a/test/TEST-33-CLEAN-UNIT/testsuite.sh
+++ b/test/TEST-33-CLEAN-UNIT/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -ex
diff --git a/test/TEST-34-DYNAMICUSERMIGRATE/test.sh b/test/TEST-34-DYNAMICUSERMIGRATE/test.sh
index c7c1b29d86..ad299df420 100755
--- a/test/TEST-34-DYNAMICUSERMIGRATE/test.sh
+++ b/test/TEST-34-DYNAMICUSERMIGRATE/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test migrating state directory from DynamicUser=1 to DynamicUser=0 and back"
diff --git a/test/TEST-34-DYNAMICUSERMIGRATE/testsuite.sh b/test/TEST-34-DYNAMICUSERMIGRATE/testsuite.sh
index 8f5316e3e5..6d9488688a 100755
--- a/test/TEST-34-DYNAMICUSERMIGRATE/testsuite.sh
+++ b/test/TEST-34-DYNAMICUSERMIGRATE/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-35-NETWORK-GENERATOR/test.sh b/test/TEST-35-NETWORK-GENERATOR/test.sh
index 4ee5da533f..7853281850 100755
--- a/test/TEST-35-NETWORK-GENERATOR/test.sh
+++ b/test/TEST-35-NETWORK-GENERATOR/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="network-generator tests"
diff --git a/test/TEST-36-NUMAPOLICY/test.sh b/test/TEST-36-NUMAPOLICY/test.sh
index e4c0e45ebe..29addc958b 100755
--- a/test/TEST-36-NUMAPOLICY/test.sh
+++ b/test/TEST-36-NUMAPOLICY/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test MUMAPolicy= and NUMAMask= options"
diff --git a/test/TEST-36-NUMAPOLICY/testsuite.sh b/test/TEST-36-NUMAPOLICY/testsuite.sh
index a5ac788178..4a2bede431 100755
--- a/test/TEST-36-NUMAPOLICY/testsuite.sh
+++ b/test/TEST-36-NUMAPOLICY/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh b/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh
index ffe0ee9499..2c5ad430b5 100755
--- a/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh
+++ b/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
diff --git a/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/testsuite.sh b/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/testsuite.sh
index 4e63a07326..32a9dd8694 100755
--- a/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/testsuite.sh
+++ b/test/TEST-37-RUNTIMEDIRECTORYPRESERVE/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -ex
diff --git a/test/TEST-39-EXECRELOAD/test.sh b/test/TEST-39-EXECRELOAD/test.sh
index d2b1663aa3..ac1d0c9cf6 100755
--- a/test/TEST-39-EXECRELOAD/test.sh
+++ b/test/TEST-39-EXECRELOAD/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Test ExecReload= (PR #13098)"
diff --git a/test/TEST-39-EXECRELOAD/testsuite.sh b/test/TEST-39-EXECRELOAD/testsuite.sh
index a51f6fd5cc..eb7363fa6a 100644
--- a/test/TEST-39-EXECRELOAD/testsuite.sh
+++ b/test/TEST-39-EXECRELOAD/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-40-EXEC-COMMAND-EX/test.sh b/test/TEST-40-EXEC-COMMAND-EX/test.sh
index 01d725eb5e..a7933b0070 100755
--- a/test/TEST-40-EXEC-COMMAND-EX/test.sh
+++ b/test/TEST-40-EXEC-COMMAND-EX/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test ExecXYZEx= service unit dbus hookups"
diff --git a/test/TEST-40-EXEC-COMMAND-EX/testsuite.sh b/test/TEST-40-EXEC-COMMAND-EX/testsuite.sh
index e0580ae75a..957d22031a 100755
--- a/test/TEST-40-EXEC-COMMAND-EX/testsuite.sh
+++ b/test/TEST-40-EXEC-COMMAND-EX/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-41-ONESHOT-RESTART/test.sh b/test/TEST-41-ONESHOT-RESTART/test.sh
index 96c21da642..54292c0ca2 100755
--- a/test/TEST-41-ONESHOT-RESTART/test.sh
+++ b/test/TEST-41-ONESHOT-RESTART/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Test oneshot unit restart on failure"
. $TEST_BASE_DIR/test-functions
diff --git a/test/TEST-41-ONESHOT-RESTART/testsuite.sh b/test/TEST-41-ONESHOT-RESTART/testsuite.sh
index 4465614ff3..905f32e994 100755
--- a/test/TEST-41-ONESHOT-RESTART/testsuite.sh
+++ b/test/TEST-41-ONESHOT-RESTART/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-42-EXECSTOPPOST/test.sh b/test/TEST-42-EXECSTOPPOST/test.sh
index 865989d001..0c393597c7 100755
--- a/test/TEST-42-EXECSTOPPOST/test.sh
+++ b/test/TEST-42-EXECSTOPPOST/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test that ExecStopPost= is always run"
diff --git a/test/TEST-42-EXECSTOPPOST/testsuite.sh b/test/TEST-42-EXECSTOPPOST/testsuite.sh
index a027890047..154398dd66 100755
--- a/test/TEST-42-EXECSTOPPOST/testsuite.sh
+++ b/test/TEST-42-EXECSTOPPOST/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
systemd-analyze log-level debug
@@ -16,7 +16,7 @@ test -f /run/exec1
test -f /run/exec2
cat > /tmp/forking1.sh <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
set -eux
@@ -32,7 +32,7 @@ systemd-run --unit=forking1.service --wait -p StandardOutput=tty -p StandardErro
test -f /run/forking1
cat > /tmp/forking2.sh <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
set -eux
@@ -62,7 +62,7 @@ test -f /run/dbus1
test -f /run/dbus2
cat > /tmp/notify1.sh <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
set -eux
diff --git a/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh b/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh
index fe20114756..3b40bf7d8b 100755
--- a/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh
+++ b/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="Test PrivateUsers=yes on user manager"
. $TEST_BASE_DIR/test-functions
diff --git a/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh b/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh
index fa5da2ec7d..ff94ad4d81 100755
--- a/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh
+++ b/test/TEST-43-PRIVATEUSER-UNPRIV/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/TEST-44-LOG-NAMESPACE/test.sh b/test/TEST-44-LOG-NAMESPACE/test.sh
index 4dfb4418db..c2070f2b61 100755
--- a/test/TEST-44-LOG-NAMESPACE/test.sh
+++ b/test/TEST-44-LOG-NAMESPACE/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test log namespaces"
diff --git a/test/TEST-44-LOG-NAMESPACE/testsuite.sh b/test/TEST-44-LOG-NAMESPACE/testsuite.sh
index 9be07652b9..97541634d0 100755
--- a/test/TEST-44-LOG-NAMESPACE/testsuite.sh
+++ b/test/TEST-44-LOG-NAMESPACE/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
systemd-analyze log-level debug
diff --git a/test/TEST-45-REPART/test.sh b/test/TEST-45-REPART/test.sh
index f1f4660027..e7015d57e0 100755
--- a/test/TEST-45-REPART/test.sh
+++ b/test/TEST-45-REPART/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test systemd-repart"
diff --git a/test/TEST-45-REPART/testsuite.sh b/test/TEST-45-REPART/testsuite.sh
index efea390b07..804faefe78 100755
--- a/test/TEST-45-REPART/testsuite.sh
+++ b/test/TEST-45-REPART/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
# Check if repart is installed, and if it isn't bail out early instead of failing
diff --git a/test/TEST-46-HOMED/test.sh b/test/TEST-46-HOMED/test.sh
index 092136c3e7..99fd5b85b8 100755
--- a/test/TEST-46-HOMED/test.sh
+++ b/test/TEST-46-HOMED/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="testing homed"
TEST_NO_QEMU=1
diff --git a/test/TEST-46-HOMED/testsuite.sh b/test/TEST-46-HOMED/testsuite.sh
index 9c52312ab5..9ef9f30f1e 100755
--- a/test/TEST-46-HOMED/testsuite.sh
+++ b/test/TEST-46-HOMED/testsuite.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -ex
set -o pipefail
diff --git a/test/mocks/fsck b/test/mocks/fsck
index 77b50d7234..241583bb4e 100755
--- a/test/mocks/fsck
+++ b/test/mocks/fsck
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
fd=0
OPTIND=1
diff --git a/test/run-integration-tests.sh b/test/run-integration-tests.sh
index 74fd64d24a..c0a8448a88 100755
--- a/test/run-integration-tests.sh
+++ b/test/run-integration-tests.sh
@@ -1,4 +1,5 @@
-#!/bin/bash -e
+#!/usr/bin/env bash
+set -e
BUILD_DIR="$($(dirname "$0")/../tools/find-build-dir.sh)"
if [ $# -gt 0 ]; then
diff --git a/test/test-efi-create-disk.sh b/test/test-efi-create-disk.sh
index 592b20afcf..783b787450 100755
--- a/test/test-efi-create-disk.sh
+++ b/test/test-efi-create-disk.sh
@@ -1,4 +1,5 @@
-#!/bin/bash -e
+#!/usr/bin/env bash
+set -e
out="$1"
systemd_efi="$2"
diff --git a/test/test-functions b/test/test-functions
index e4ec4f025f..66cd60b559 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
@@ -39,7 +39,7 @@ PATH_TO_INIT=$ROOTLIBDIR/systemd
[ "$SYSTEMD_NSPAWN" ] || SYSTEMD_NSPAWN=$(which -a $BUILD_DIR/systemd-nspawn systemd-nspawn 2>/dev/null | grep '^/' -m1)
[ "$JOURNALCTL" ] || JOURNALCTL=$(which -a $BUILD_DIR/journalctl journalctl 2>/dev/null | grep '^/' -m1)
-BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo head tail cat mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs"
+BASICTOOLS="test env sh bash setsid loadkeys setfont login sulogin gzip sleep echo head tail cat mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs"
DEBUGTOOLS="df free ls stty ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find vi mv"
STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))"
@@ -376,7 +376,7 @@ create_valgrind_wrapper() {
local _valgrind_wrapper=$initdir/$ROOTLIBDIR/systemd-under-valgrind
ddebug "Create $_valgrind_wrapper"
cat >$_valgrind_wrapper <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
mount -t proc proc /proc
exec valgrind --leak-check=full --log-file=/valgrind.out $ROOTLIBDIR/systemd "\$@"
@@ -405,7 +405,7 @@ create_asan_wrapper() {
esac
cat >$_asan_wrapper <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
set -x
@@ -488,7 +488,7 @@ create_strace_wrapper() {
local _strace_wrapper=$initdir/$ROOTLIBDIR/systemd-under-strace
ddebug "Create $_strace_wrapper"
cat >$_strace_wrapper <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
exec strace -D -o /strace.out $ROOTLIBDIR/systemd "\$@"
EOF
@@ -675,7 +675,7 @@ strip_binaries() {
create_rc_local() {
mkdir -p $initdir/etc/rc.d
cat >$initdir/etc/rc.d/rc.local <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
exit 0
EOF
chmod 0755 $initdir/etc/rc.d/rc.local
diff --git a/tools/check-directives.sh b/tools/check-directives.sh
index a90fb604ae..1a0bb0995b 100755
--- a/tools/check-directives.sh
+++ b/tools/check-directives.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
which perl &>/dev/null || exit 77
diff --git a/tools/coverity.sh b/tools/coverity.sh
index 8edce065ca..5d3b7e2918 100755
--- a/tools/coverity.sh
+++ b/tools/coverity.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# The official unmodified version of the script can be found at
# https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh
diff --git a/tools/meson-vcs-tag.sh b/tools/meson-vcs-tag.sh
index 5dc95fa8c1..1c3814d483 100755
--- a/tools/meson-vcs-tag.sh
+++ b/tools/meson-vcs-tag.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -eu
set -o pipefail
diff --git a/tools/oss-fuzz.sh b/tools/oss-fuzz.sh
index 5e48a7e0c6..79846f8787 100755
--- a/tools/oss-fuzz.sh
+++ b/tools/oss-fuzz.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1+
set -ex