From 02c11afbc6c4c434c0cba475cdc19250008b9d13 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Mon, 11 May 2026 19:44:47 +0200 Subject: [PATCH] FEXBash: Don't imply "-c" to behave more closely like bash Implicitly adding "-c" breaks argument passing for scripts. For example, the command "FEXBash ./steam.sh -silent" will process steam.sh but the script wouldn't see the "-silent" argument previously. --- Source/Tools/FEXBash/FEXBash.cpp | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/Source/Tools/FEXBash/FEXBash.cpp b/Source/Tools/FEXBash/FEXBash.cpp index 903ad12b0..bff42c775 100644 --- a/Source/Tools/FEXBash/FEXBash.cpp +++ b/Source/Tools/FEXBash/FEXBash.cpp @@ -2,7 +2,7 @@ /* $info$ tags: Bin|FEXBash -desc: Launches bash under FEX and passes arguments via -c to it +desc: Wrapper for invoking x86 bash from the rootfs using FEX $end_info$ */ @@ -18,7 +18,6 @@ int main(int argc, char** argv, char** const envp) { const int ArgCount = argc - 1; const bool EmptyArgs = ArgCount == 0; - std::vector Argv; // FEX will handle finding bash in the rootfs // Use /bin/sh for -c commands and /bin/bash for interactive mode const char* BashPath = EmptyArgs ? "/bin/bash" : "/bin/sh"; @@ -39,32 +38,17 @@ int main(int argc, char** argv, char** const envp) { std::abort(); } } - const char* FEXArgs[] = { - FEXPath.c_str(), - BashPath, - "-c", - }; - // Remove -c argument if arguments are empty - // Lets us start an emulated bash instance - const size_t FEXArgsCount = std::size(FEXArgs) - (EmptyArgs ? 1 : 0); - - Argv.resize(ArgCount + FEXArgsCount); - - // Pass in the FEX arguments - for (size_t i = 0; i < FEXArgsCount; ++i) { - Argv[i] = FEXArgs[i]; - } - - // Bring in passed in arguments - for (size_t i = 0; i < ArgCount; ++i) { - Argv[i + FEXArgsCount] = argv[i + 1]; + std::vector Argv; + Argv.emplace_back(FEXPath.c_str()); + Argv.emplace_back(BashPath); + for (int i = 1; i < argc; ++i) { + Argv.emplace_back(argv[i]); } // Set --norc when no arguments are passed so PS1 doesn't get overwritten - const char* NoRC = "--norc"; if (EmptyArgs) { - Argv.emplace_back(NoRC); + Argv.emplace_back("--norc"); } Argv.emplace_back(nullptr);