From b6426516b827840747162d9aed340fa09dcb6148 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sat, 3 Aug 2024 11:52:43 +1000 Subject: [PATCH] AP_HAL_SITL: work around bug in dash dash doesn't search the path for scripts, so allow user to specify path to ArduPilot scripts --- libraries/AP_HAL_SITL/system.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libraries/AP_HAL_SITL/system.cpp b/libraries/AP_HAL_SITL/system.cpp index 81c5b4941b..2bbcbb8e73 100644 --- a/libraries/AP_HAL_SITL/system.cpp +++ b/libraries/AP_HAL_SITL/system.cpp @@ -65,13 +65,24 @@ static void run_command_on_ownpid(const char *commandname) // find dumpstack command: const char *command_filepath = commandname; // if we can't find it trust in PATH struct stat statbuf; + const char *custom_scripts_dir_path = getenv("AP_SCRIPTS_DIR_PATH"); + char *custom_scripts_dir_path_pattern = nullptr; + if (custom_scripts_dir_path != nullptr) { + if (asprintf(&custom_scripts_dir_path_pattern, "%s/%%s", custom_scripts_dir_path) == -1) { + custom_scripts_dir_path_pattern = nullptr; + } + } const char *paths[] { + custom_scripts_dir_path_pattern, "Tools/scripts/%s", "APM/Tools/scripts/%s", // for autotest server "../Tools/scripts/%s", // when run from e.g. ArduCopter subdirectory }; char buffer[60]; for (uint8_t i=0; i