FEXBash: Clean up and fix FEXInterpreter lookup

Previously, the first attempt to look up a FEXInterpreter would always
fail due to a missing path separator.

Additionally, fallback lookup now uses /proc/self/exe to find a path relative
to the FEXBash executable. The previous use of FindContainerPrefix does not
seem to be required anymore in current Steam versions.
This commit is contained in:
Tony Wasserka committed 2025-06-17 11:40:32 +02:00
1 parent 9d2f557666
commit 9ad4e3a6a0
2 files changed
+13 -8

No files matched your search

+1 -5
View File
@@ -1,9 +1,5 @@
add_executable(FEXBash FEXBash.cpp)
target_include_directories(FEXBash
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/Source/
${CMAKE_BINARY_DIR}/generated
)
target_include_directories(FEXBash PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Source/)
target_link_libraries(FEXBash
PRIVATE
+12 -3
View File
@@ -6,7 +6,6 @@ desc: Launches bash under FEX and passes arguments via -c to it
$end_info$
*/
#include "ConfigDefines.h"
#include "Common/ArgumentLoader.h"
#include <FEXCore/Config/Config.h>
@@ -25,11 +24,21 @@ int main(int argc, char** argv, char** const envp) {
// Use /bin/sh for -c commands and /bin/bash for interactive mode
const char* BashPath = Args.empty() ? "/bin/bash" : "/bin/sh";
std::string FEXInterpreterPath = std::filesystem::path(argv[0]).parent_path().string() + "FEXInterpreter";
std::string FEXInterpreterPath = std::filesystem::path(argv[0]).parent_path().string() + "/FEXInterpreter";
// Check if a local FEXInterpreter to FEXBash exists
// If it does then it takes priority over the installed one
if (!std::filesystem::exists(FEXInterpreterPath)) {
FEXInterpreterPath = FEXCore::Config::FindContainerPrefix() + FEXINTERPRETER_PATH;
char FEXBashPath[PATH_MAX];
auto Result = readlink("/proc/self/exe", FEXBashPath, PATH_MAX);
if (Result != -1) {
FEXInterpreterPath = std::filesystem::path(&FEXBashPath[0], &FEXBashPath[Result]).parent_path().string() + "/FEXInterpreter";
}
if (!std::filesystem::exists(FEXInterpreterPath)) {
fmt::print(stderr, "Could not locate FEXInterpreter executable\n");
std::abort();
}
}
const char* FEXArgs[] = {
FEXInterpreterPath.c_str(),