Skip to content

Commit

Permalink
Fix yet more escaping issues on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 committed Nov 14, 2011
1 parent a55c6d0 commit 39ab6d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/cpp/core/system/Win32ChildProcess.cpp
Expand Up @@ -85,7 +85,7 @@ void resolveCommand(std::string* pExecutable, std::vector<std::string>* pArgs)
*pExecutable = cmdExePath;

// manipulate args to have cmd.exe invoke the batch file
pArgs->insert(pArgs->begin(), "\"" + cmdPath + "\"");
pArgs->insert(pArgs->begin(), cmdPath);
pArgs->insert(pArgs->begin(), "/C");

}
Expand Down Expand Up @@ -250,7 +250,7 @@ void ChildProcess::init(const std::string& command,
{
exe_ = findOnPath("cmd.exe");
args_.push_back("/C");
args_.push_back(command);
args_.push_back("(" + command + ")");
options_ = options;
}

Expand Down Expand Up @@ -344,7 +344,17 @@ Error ChildProcess::run()
BOOST_FOREACH(std::string& arg, args_)
{
cmdLine.push_back(' ');

// This is kind of gross. Ideally we would be more deterministic
// than this.
bool quot = std::string::npos != arg.find(' ')
&& std::string::npos == arg.find('"');

if (quot)
cmdLine.push_back('"');
std::copy(arg.begin(), arg.end(), std::back_inserter(cmdLine));
if (quot)
cmdLine.push_back('"');
}
cmdLine.push_back('\0');

Expand Down
2 changes: 1 addition & 1 deletion src/cpp/session/modules/SessionGit.cpp
Expand Up @@ -286,7 +286,7 @@ class Git : public boost::noncopyable

#ifdef _WIN32
boost::shared_ptr<ConsoleProcess> ptrCP =
ConsoleProcess::create(program,
ConsoleProcess::create(gitBin(),
args.args(),
options,
caption,
Expand Down

0 comments on commit 39ab6d9

Please sign in to comment.