Skip to content

Commit

Permalink
Pass absolute path to exe in argv[0] (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
encounter authored Jan 23, 2023
1 parent 67f99ba commit 9837ce0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 += '"';
Expand Down

0 comments on commit 9837ce0

Please sign in to comment.