From 2aadf5256b3eafeb86efa8626247972dd33baa13 Mon Sep 17 00:00:00 2001 From: Kira Bruneau Date: Mon, 26 Apr 2021 10:54:03 -0400 Subject: [PATCH] Fix printing wine version with custom WINELOADER - Don't call bp::search_path when using WINELOADER. It will return an empty string for an absolute path. - To match the behaviour of the exe wrapper scripts, only print the wine version from WINELOADER if the path is executable. --- src/plugin/utils.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugin/utils.cpp b/src/plugin/utils.cpp index 7f65f393..7735f1c3 100644 --- a/src/plugin/utils.cpp +++ b/src/plugin/utils.cpp @@ -16,6 +16,7 @@ #include "utils.h" +#include #include #include #include @@ -343,16 +344,17 @@ std::vector get_augmented_search_path() { std::string get_wine_version() { // The '*.exe' scripts generated by winegcc allow you to override the binary // used to run Wine, so will will respect this as well - std::string wine_command = "wine"; - + std::string wine_path; bp::environment env = boost::this_process::environment(); - if (!env["WINELOADER"].empty()) { - wine_command = env["WINELOADER"].to_string(); + const std::string wineloader_path = env["WINELOADER"].to_string(); + if (access(wineloader_path.c_str(), X_OK) == 0) { + wine_path = wineloader_path; + } else { + wine_path = bp::search_path("wine"); } bp::ipstream output; try { - const fs::path wine_path = bp::search_path(wine_command); bp::system(wine_path, "--version", bp::std_out = output); } catch (const std::system_error&) { return "";