From aff1640691bc04b564705f7ebad8fd9bb34134e5 Mon Sep 17 00:00:00 2001 From: "U-olece-PC\\olece" Date: Mon, 7 Dec 2015 18:11:56 +0100 Subject: [PATCH] Fixed use of backslash in process commands. --- src/process_win.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/process_win.cpp b/src/process_win.cpp index 25a15bb..703a607 100644 --- a/src/process_win.cpp +++ b/src/process_win.cpp @@ -98,10 +98,6 @@ Process::id_type Process::open(const std::string &command, const std::string &pa #ifdef MSYS_PROCESS_USE_SH size_t pos=0; std::string sh_command=command; - while((pos=sh_command.find('\\', pos))!=std::string::npos) { - sh_command.replace(pos, 1, "\\\\\\"); - pos+=3; - } while((pos=sh_command.find('\"', pos))!=std::string::npos) { if(pos>0 && sh_command[pos-1]!='\\') { sh_command.replace(pos, 1, "\\\""); @@ -109,6 +105,14 @@ Process::id_type Process::open(const std::string &command, const std::string &pa } pos++; } + pos=0; + while((pos=sh_command.find('\\', pos))!=std::string::npos) { + if((pos+1)==sh_command.size() || sh_command[pos+1]!='\"') { + sh_command.replace(pos, 1, "\\\\\\"); + pos++; + } + pos+=2; + } sh_command.insert(0, "sh -c \""); sh_command+="\""; command_cstr=new char[sh_command.size()+1];