From 2721a9f6a8a50abb8e80d1023151b16389a64201 Mon Sep 17 00:00:00 2001 From: Patrick Storz Date: Wed, 16 Oct 2019 20:24:23 +0200 Subject: Extensions: only check existence for interpreted scripts. This is for backwards-compatibility with older .inx files that used to redundantly request a dependency on their own interpreted script and did so with type="executable". However, in practice script files often *don't* have the x-bit set, which fortunately did not cause problems in the past, though, as the check for the x-bit was broken, see 3da7f71e45eb986aef67771b5af3c1e308971cff --- src/extension/dependency.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/extension') diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp index 69cb3199d..a9115cb86 100644 --- a/src/extension/dependency.cpp +++ b/src/extension/dependency.cpp @@ -147,6 +147,23 @@ bool Dependency::check () case TYPE_FILE: { Glib::FileTest filetest = Glib::FILE_TEST_EXISTS; + std::string location(_string); + + // get potential file extension for later usage + std::string extension; + size_t index = location.find_last_of("."); + if (index != std::string::npos) { + extension = location.substr(index); + } + + // check interpreted scripts as "file" for backwards-compatibility, even if "executable" was requested + static const std::vector interpreted = {".py", ".pl", ".rb"}; + if (!extension.empty() && + std::find(interpreted.begin(), interpreted.end(), extension) != interpreted.end()) + { + _type = TYPE_FILE; + } + #ifndef _WIN32 // There's no executable bit on Windows, so this is unreliable // glib would search for "executable types" instead, which are only {".exe", ".cmd", ".bat", ".com"}, @@ -156,7 +173,6 @@ bool Dependency::check () } #endif - std::string location(_string); switch (_location) { case LOCATION_EXTENSIONS: { std::string temploc = @@ -236,13 +252,6 @@ bool Dependency::check () // so that we don't accidentally override (or conflict with) some g_spawn_* magic. if (_type == TYPE_EXECUTABLE) { static const std::vector extensions = {".exe", ".cmd", ".bat", ".com"}; - - std::string extension; - size_t index = final_name.find_last_of("."); - if (index != std::string::npos) { - extension = final_name.substr(index); - } - if (extension.empty() || std::find(extensions.begin(), extensions.end(), extension) == extensions.end()) { -- cgit v1.2.3