From 0d18be5049cc29a4237cdbda5b6a1d7e4e5fb9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Wed, 1 Apr 2026 23:25:28 +0300 Subject: [PATCH] fix(scripts): replace hardcoded /bin/bash shebangs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several helper scripts assumes bash is available at /bin/bash. That breaks on systems such as NixOS, where bash is resolved from PATH instead of a fixed /bin location and causes failures like `bad interpreter` during `make format`, e.g., on my host machine: ```sh $ make format /PX4-Autopilot/Tools/astyle/check_code_style.sh: /PX4-Autopilot/Tools/astyle/fix_code_style.sh: /bin/bash: bad interpreter: No such file or directory ``` This change switches these entrypoints to `#!/usr/bin/env bash` so they locate bash properly. No functional changes intended. Signed-off-by: Onur Özkan --- Tools/HIL/test_airframes.sh | 2 +- Tools/astyle/fix_code_style.sh | 2 +- Tools/auterion/remote_update_fmu.sh | 2 +- Tools/ci/build_all_runner.sh | 2 +- Tools/ci/check_msg_versioning.sh | 2 +- Tools/ci/package_build_artifacts.sh | 2 +- Tools/ci/run_fuzz_tests.sh | 2 +- Tools/copy_to_ros_ws.sh | 2 +- Tools/docker_run.sh | 2 +- Tools/run-shellcheck.sh | 2 +- Tools/setup/docker-entrypoint.sh | 2 +- Tools/simulation/gazebo-classic/setup_gazebo.bash | 2 +- Tools/simulation/gazebo-classic/sitl_multiple_run.sh | 2 +- Tools/simulation/sitl_multiple_run.sh | 2 +- boards/modalai/fc-v2/scripts/run_docker.sh | 2 +- boards/modalai/voxl2/debian/postinst | 2 +- boards/modalai/voxl2/debian/prerm | 2 +- boards/modalai/voxl2/scripts/build-apps.sh | 2 +- boards/modalai/voxl2/scripts/build-pkg.sh | 2 +- boards/modalai/voxl2/scripts/build-slpi.sh | 2 +- boards/modalai/voxl2/scripts/clean.sh | 2 +- boards/modalai/voxl2/scripts/install-voxl-bins.sh | 2 +- boards/modalai/voxl2/scripts/install-voxl.sh | 2 +- boards/modalai/voxl2/scripts/patch-gazebo.sh | 2 +- boards/modalai/voxl2/scripts/run-docker.sh | 2 +- boards/modalai/voxl2/scripts/voxl-configure-px4 | 2 +- boards/modalai/voxl2/target/voxl-px4 | 2 +- boards/modalai/voxl2/target/voxl-px4-hitl | 2 +- docs/en/hardware/board_packaging.md | 4 ++-- test/rostest_px4_run.sh | 2 +- 30 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Tools/HIL/test_airframes.sh b/Tools/HIL/test_airframes.sh index 24d20f07ec..3b26d47ed0 100755 --- a/Tools/HIL/test_airframes.sh +++ b/Tools/HIL/test_airframes.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/usr/bin/env bash # exit when any command fails set -e diff --git a/Tools/astyle/fix_code_style.sh b/Tools/astyle/fix_code_style.sh index 73a7a39278..af3a968e38 100755 --- a/Tools/astyle/fix_code_style.sh +++ b/Tools/astyle/fix_code_style.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash if [[ $# -eq 0 ]] ; then exit 0 diff --git a/Tools/auterion/remote_update_fmu.sh b/Tools/auterion/remote_update_fmu.sh index d3777aebaf..ba181bc49e 100755 --- a/Tools/auterion/remote_update_fmu.sh +++ b/Tools/auterion/remote_update_fmu.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Flash PX4 to a device running AuterionOS in the local network if [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ $# -lt 2 ]; then echo "Usage: $0 -f [-c ] -d [-u ] [-p ] [--revert]" diff --git a/Tools/ci/build_all_runner.sh b/Tools/ci/build_all_runner.sh index bfb77e2623..2d81de2c6a 100755 --- a/Tools/ci/build_all_runner.sh +++ b/Tools/ci/build_all_runner.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script is meant to be used by the build_all.yml workflow in a github runner # Please only modify if you know what you are doing set -e diff --git a/Tools/ci/check_msg_versioning.sh b/Tools/ci/check_msg_versioning.sh index 508a344ee6..da769dbeb3 100755 --- a/Tools/ci/check_msg_versioning.sh +++ b/Tools/ci/check_msg_versioning.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/usr/bin/env bash # Copy a git diff between two commits if msg versioning is added DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) diff --git a/Tools/ci/package_build_artifacts.sh b/Tools/ci/package_build_artifacts.sh index d371e25eba..f24a3f6a6c 100755 --- a/Tools/ci/package_build_artifacts.sh +++ b/Tools/ci/package_build_artifacts.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash mkdir artifacts cp **/**/*.px4 artifacts/ 2>/dev/null || true diff --git a/Tools/ci/run_fuzz_tests.sh b/Tools/ci/run_fuzz_tests.sh index 4aa4a9d3b6..3007dc744e 100755 --- a/Tools/ci/run_fuzz_tests.sh +++ b/Tools/ci/run_fuzz_tests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script runs the fuzz tests from a given binary for a certain amount of time set -e diff --git a/Tools/copy_to_ros_ws.sh b/Tools/copy_to_ros_ws.sh index 48fcaa0d1f..b27fb07e34 100755 --- a/Tools/copy_to_ros_ws.sh +++ b/Tools/copy_to_ros_ws.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/usr/bin/env bash # Copy msgs and the message translation node into a ROS workspace directory DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) diff --git a/Tools/docker_run.sh b/Tools/docker_run.sh index 773c8992eb..fda1ee65e0 100755 --- a/Tools/docker_run.sh +++ b/Tools/docker_run.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/usr/bin/env bash if [ -z ${PX4_DOCKER_REPO+x} ]; then PX4_DOCKER_REPO="px4io/px4-dev:v1.17.0-beta1" diff --git a/Tools/run-shellcheck.sh b/Tools/run-shellcheck.sh index 5c745bad7a..bdd78f28d0 100755 --- a/Tools/run-shellcheck.sh +++ b/Tools/run-shellcheck.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Script to run ShellCheck (a static analysis tool for shell scripts) over a # script directory diff --git a/Tools/setup/docker-entrypoint.sh b/Tools/setup/docker-entrypoint.sh index 69101c5833..5ffe214569 100755 --- a/Tools/setup/docker-entrypoint.sh +++ b/Tools/setup/docker-entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash GREEN='\033[0;32m' NO_COLOR='\033[0m' # No Color diff --git a/Tools/simulation/gazebo-classic/setup_gazebo.bash b/Tools/simulation/gazebo-classic/setup_gazebo.bash index 7829c929c6..2be4e42fbf 100755 --- a/Tools/simulation/gazebo-classic/setup_gazebo.bash +++ b/Tools/simulation/gazebo-classic/setup_gazebo.bash @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Setup environment to make PX4 visible to Gazebo. # diff --git a/Tools/simulation/gazebo-classic/sitl_multiple_run.sh b/Tools/simulation/gazebo-classic/sitl_multiple_run.sh index 114003163a..3f3ff6f5d8 100755 --- a/Tools/simulation/gazebo-classic/sitl_multiple_run.sh +++ b/Tools/simulation/gazebo-classic/sitl_multiple_run.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # run multiple instances of the 'px4' binary, with the gazebo SITL simulation # It assumes px4 is already built, with 'make px4_sitl_default sitl_gazebo-classic' diff --git a/Tools/simulation/sitl_multiple_run.sh b/Tools/simulation/sitl_multiple_run.sh index a5c1c98d29..39554a622d 100755 --- a/Tools/simulation/sitl_multiple_run.sh +++ b/Tools/simulation/sitl_multiple_run.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Run multiple instances of the 'px4' binary, without starting an external simulator. # It assumes px4 is already built with the specified build target. # diff --git a/boards/modalai/fc-v2/scripts/run_docker.sh b/boards/modalai/fc-v2/scripts/run_docker.sh index 4e42146ca6..96a8890f11 100755 --- a/boards/modalai/fc-v2/scripts/run_docker.sh +++ b/boards/modalai/fc-v2/scripts/run_docker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Run this from the px4 project top level directory docker run -it --rm --privileged -v `pwd`:/usr/local/workspace px4io/px4-dev-nuttx-focal:2022-08-12 diff --git a/boards/modalai/voxl2/debian/postinst b/boards/modalai/voxl2/debian/postinst index cb50d967f5..dbe4798612 100755 --- a/boards/modalai/voxl2/debian/postinst +++ b/boards/modalai/voxl2/debian/postinst @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e # Create px4-* symlinks from px4-alias.sh diff --git a/boards/modalai/voxl2/debian/prerm b/boards/modalai/voxl2/debian/prerm index 71bab592af..fdfc7c89a9 100755 --- a/boards/modalai/voxl2/debian/prerm +++ b/boards/modalai/voxl2/debian/prerm @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e # Stop voxl-px4 service if running diff --git a/boards/modalai/voxl2/scripts/build-apps.sh b/boards/modalai/voxl2/scripts/build-apps.sh index a3570748c2..aecb11d1df 100755 --- a/boards/modalai/voxl2/scripts/build-apps.sh +++ b/boards/modalai/voxl2/scripts/build-apps.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash echo "*** Starting unified VOXL2 build (apps + SLPI) ***" diff --git a/boards/modalai/voxl2/scripts/build-pkg.sh b/boards/modalai/voxl2/scripts/build-pkg.sh index 2abe4ccc81..589618cb87 100755 --- a/boards/modalai/voxl2/scripts/build-pkg.sh +++ b/boards/modalai/voxl2/scripts/build-pkg.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash echo "*** Starting unified VOXL2 build (apps + SLPI) ***" diff --git a/boards/modalai/voxl2/scripts/build-slpi.sh b/boards/modalai/voxl2/scripts/build-slpi.sh index fa639191be..f9a3be7d21 100755 --- a/boards/modalai/voxl2/scripts/build-slpi.sh +++ b/boards/modalai/voxl2/scripts/build-slpi.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash echo "*** Starting qurt slpi build ***" diff --git a/boards/modalai/voxl2/scripts/clean.sh b/boards/modalai/voxl2/scripts/clean.sh index 80832b0b70..8a4a9dff66 100755 --- a/boards/modalai/voxl2/scripts/clean.sh +++ b/boards/modalai/voxl2/scripts/clean.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Clean out the build artifacts # source /home/build-env.sh diff --git a/boards/modalai/voxl2/scripts/install-voxl-bins.sh b/boards/modalai/voxl2/scripts/install-voxl-bins.sh index 417cf59cf5..1d917255f9 100755 --- a/boards/modalai/voxl2/scripts/install-voxl-bins.sh +++ b/boards/modalai/voxl2/scripts/install-voxl-bins.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Push slpi image to voxl2 adb push build/modalai_voxl2_slpi/platforms/qurt/libpx4.so /usr/lib/rfsa/adsp diff --git a/boards/modalai/voxl2/scripts/install-voxl.sh b/boards/modalai/voxl2/scripts/install-voxl.sh index 86c5890c7c..fc08e44213 100755 --- a/boards/modalai/voxl2/scripts/install-voxl.sh +++ b/boards/modalai/voxl2/scripts/install-voxl.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Push slpi image to voxl2 adb push build/modalai_voxl2_slpi/platforms/qurt/libpx4.so /usr/lib/rfsa/adsp diff --git a/boards/modalai/voxl2/scripts/patch-gazebo.sh b/boards/modalai/voxl2/scripts/patch-gazebo.sh index bb31b99b12..7505c0ae4f 100755 --- a/boards/modalai/voxl2/scripts/patch-gazebo.sh +++ b/boards/modalai/voxl2/scripts/patch-gazebo.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash cd Tools/simulation/gazebo-classic/sitl_gazebo-classic/src patch < ../../../../../boards/modalai/voxl2/gazebo-docker/patch/mavlink_interface.patch diff --git a/boards/modalai/voxl2/scripts/run-docker.sh b/boards/modalai/voxl2/scripts/run-docker.sh index 4df40769de..e1ca48b19a 100755 --- a/boards/modalai/voxl2/scripts/run-docker.sh +++ b/boards/modalai/voxl2/scripts/run-docker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Run this from the px4 project top level directory docker run -it --rm -v `pwd`:/usr/local/workspace rb5-flight-px4-build-docker diff --git a/boards/modalai/voxl2/scripts/voxl-configure-px4 b/boards/modalai/voxl2/scripts/voxl-configure-px4 index 5ef2d42b40..8632f646d9 100755 --- a/boards/modalai/voxl2/scripts/voxl-configure-px4 +++ b/boards/modalai/voxl2/scripts/voxl-configure-px4 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ################################################################################ # Copyright 2023 ModalAI Inc. # diff --git a/boards/modalai/voxl2/target/voxl-px4 b/boards/modalai/voxl2/target/voxl-px4 index 2d7e3d9129..951d7cb198 100755 --- a/boards/modalai/voxl2/target/voxl-px4 +++ b/boards/modalai/voxl2/target/voxl-px4 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash CONFIG_FILE="/etc/modalai/voxl-px4.conf" diff --git a/boards/modalai/voxl2/target/voxl-px4-hitl b/boards/modalai/voxl2/target/voxl-px4-hitl index c0da8adb74..9e84134366 100755 --- a/boards/modalai/voxl2/target/voxl-px4-hitl +++ b/boards/modalai/voxl2/target/voxl-px4-hitl @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Make sure that the SLPI DSP test signature is there otherwise px4 cannot run # on the DSP diff --git a/docs/en/hardware/board_packaging.md b/docs/en/hardware/board_packaging.md index 5c578e45b8..25454702af 100644 --- a/docs/en/hardware/board_packaging.md +++ b/docs/en/hardware/board_packaging.md @@ -159,7 +159,7 @@ Runs after the package is installed. Common tasks: - Board-specific setup (e.g., DSP signature generation) ```bash -#!/bin/bash +#!/usr/bin/env bash set -e # Create px4-* symlinks @@ -185,7 +185,7 @@ fi Runs before the package is removed: ```bash -#!/bin/bash +#!/usr/bin/env bash set -e # Stop the service diff --git a/test/rostest_px4_run.sh b/test/rostest_px4_run.sh index f3964d82a1..e66e833e61 100755 --- a/test/rostest_px4_run.sh +++ b/test/rostest_px4_run.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/usr/bin/env bash DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) PX4_SRC_DIR=${DIR}/..