Opened 5 years ago

Last modified 5 years ago

#13085 new Bugs

Bad command line escaping for Windows shell

Reported by: Salamandar <felix@…> Owned by:
Milestone: To Be Determined Component: process
Version: Boost 1.64.0 Severity: Problem
Keywords: Cc:

Description

I'm trying to launch a command with the windows shell:

call "%VS140COMNTOOLS%\vsvars32.bat"

so the source is: (i have to escape the double-quotes and antislash)

std::string getCommandLine() {
  return "call \"%VS140COMNTOOLS%\\vsvars32.bat\""
}
bp::child child(getCommandLine(), bp::shell);

The problem is that Boost is double-escaping the double-quotes, and the windows shell does not understand that:

Error: '\"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\\vsvars32.bat\"' is not recognized as an internal or external command, operable program or batch file.

The problem resides here :
boost/process/detail/windows/basic_cmd.hpp :35 :48 :72

I just had to comment these lines to fix the command line and spawn the shell with the correct args.

Change History (1)

comment:1 by Salamandar <felix@…>, 5 years ago

EDIT:

  • I *need* the double-quotes because the string contains spaces.
  • sorry for the bad formatting, but I can't edit the issue now.
  • the lines contents are :
    • boost::replace_all(st, "\"", "\\\"");
    • boost::replace_all(arg, "\"", "\\\"");
    • boost::replace_all(arg, L"\"", L"\\\"");
Note: See TracTickets for help on using tickets.