Skip to content

Commit

Permalink
Merge pull request #1234 from Sonicadvance1/FEXBash_init
Browse files Browse the repository at this point in the history
FEXBash: Allow creating a bash instance easily
  • Loading branch information
Sonicadvance1 authored Aug 29, 2021
2 parents 1c3be54 + f72ecac commit 9140ba2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Source/Tests/FEXBash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,17 @@ int main(int argc, char **argv, char **const envp) {

auto Args = FEX::ArgLoader::Get();

if (Args.empty()) {
// Early exit if we weren't passed an argument
return 0;
}

// Ensure RootFS is setup before config options try to pull CONFIG_ROOTFS
if (!FEX::RootFS::Setup(envp)) {
LogMan::Msg::E("RootFS failure");
fprintf(stderr, "RootFS configuration failed.");
return -1;
}

FEX_CONFIG_OPT(RootFSPath, ROOTFS);
std::vector<const char*> Argv;
std::string BinShPath = RootFSPath() + "/bin/sh";
std::string BinBashPath = RootFSPath() + "/bin/bash";

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
Expand All @@ -54,10 +51,13 @@ int main(int argc, char **argv, char **const envp) {
}
const char *FEXArgs[] = {
FEXInterpreterPath.c_str(),
BinShPath.c_str(),
Args.empty() ? BinBashPath.c_str() : BinShPath.c_str(),
"-c",
};
constexpr size_t FEXArgsCount = std::size(FEXArgs);

// Remove -c argument if arguments are empty
// Lets us start an emulated bash instance
const size_t FEXArgsCount = std::size(FEXArgs) - (Args.empty() ? 1 : 0);

Argv.resize(Args.size() + FEXArgsCount + 1);

Expand Down

0 comments on commit 9140ba2

Please sign in to comment.