From 8d7d7f04cdc5d68ded788443914d54828ee66dbd Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Sun, 30 Jun 2024 12:20:05 -0500 Subject: [PATCH] AP_Scripting: ignore hidden Lua files On macOS, sometimes ._script.lua is created to store metadata when the user copies script.lua over to their SD card. Previously, the scripting engine would barf since the file is not Lua. Now, these files are ignored. Also avoids a case where a hidden and valid script might be loaded without the user's knowledge. --- libraries/AP_Scripting/lua_scripts.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Scripting/lua_scripts.cpp b/libraries/AP_Scripting/lua_scripts.cpp index f0bd863014265..d0fe11a993ad3 100644 --- a/libraries/AP_Scripting/lua_scripts.cpp +++ b/libraries/AP_Scripting/lua_scripts.cpp @@ -268,8 +268,8 @@ void lua_scripts::load_all_scripts_in_dir(lua_State *L, const char *dirname) { continue; } - if (strncmp(&de->d_name[length-4], ".lua", 4)) { - // doesn't end in .lua + if ((de->d_name[0] == '.') || strncmp(&de->d_name[length-4], ".lua", 4)) { + // starts with . (hidden file) or doesn't end in .lua continue; }