From 9837ce0bf445cb4e0889d6d11b1179e86ea3d5ca Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 23 Jan 2023 10:35:50 -0500 Subject: [PATCH] Pass absolute path to exe in argv[0] (#31) --- main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index a7a4e27..b0c0ef8 100644 --- a/main.cpp +++ b/main.cpp @@ -177,8 +177,13 @@ int main(int argc, char **argv) { // Build a command line std::string cmdLine; for (int i = 1; i < argc; i++) { - if (i != 1) cmdLine += ' '; - std::string arg = argv[i]; + std::string arg; + if (i == 1) { + arg = files::pathToWindows(std::filesystem::absolute(argv[1])); + } else { + cmdLine += ' '; + arg = argv[i]; + } bool needQuotes = arg.find_first_of("\\\" \t\n") != std::string::npos; if (needQuotes) cmdLine += '"';