id summary reporter owner description type status milestone component version severity resolution keywords cc 850 program_options strips off escaped quotes in some situations apoxy Vladimir Prus "{{{ boost::program_options strips off escaped quotes from command line strings like -a ""\""quoted value\"""". A command line string like -a ""\""quoted value\"" unquoted_value"" does not have its escaped quotes striped out. I am using program_options in Windows to parse the command line of my application. One of the requirements is that I be able to pass in the command line of a different application such as the following: myapp -c ""\""c:\App versions\App v1\App.exe\"" -a \""A Value\"" -b Another_Value"" In this case, program_options will correctly parse out the value of the parameter c to be: ""c:\App versions\App v1\App.exe"" -a ""A Value"" -b Another_Value However, if I pass in the following: myapp -c ""\""c:\App versions\App v1\App.exe\"""" program_options parses c as: c:\App versions\App v1\App.exe Note that the escaped quotes were stripped off instead of preserved like you would expect. This is a problem because my application immediately turns around and calls ::CreateProcess using the value of the c parameter. ::CreateProcess' documented behavior is that it executes the first match it can find of c:\App.exe, c:\App versions\App.exe, and c:\App versions\App v1\App.exe. The only way you can stop this behavior is by enclosing the file path in quotes. The code I'm using to get the options is pasted below. Please email me with any questions. Thanks! -------------------- pair CCmdLineParser::GetParam(const string& sParamName) { Run(); // Make sure we're parsed if (!Impl_.bOptionsDescribed && !Impl_.bPositionalOptionsDescribed) return GetUnregisteredParam_(sParamName); return Impl_.RegisteredOptions.count(sParamName) ? make_pair(Impl_.RegisteredOptions[sParamName].as(), true) : make_pair("""", false); } void CCmdLineParser::Run(void) { if (Impl_.bInitialized) return; Impl_.bInitialized = true; // Create parser command_line_parser Parser(split_winmain(AfxGetApp()->m_lpCmdLine)); bool bUnregistered = !Impl_.bOptionsDescribed && !Impl_.bPositionalOptionsDescribed; // Setup parser Parser.options(Impl_.OptionsDesc); // Always required (even if empty) because command_line_parser::run() asserts it if (Impl_.bPositionalOptionsDescribed) Parser.positional(Impl_.PositionalOptionsDesc); if (bUnregistered) Parser.allow_unregistered(); // Parse parsed_options ParsedOptions = Parser.run(); // Retrieve // We can't call store on something with unregistered options. It throws an exception even if you specifically // call allow_unregistered(). This is a known bug. It is fixed in the boost CVS tree, but not released yet. // What all of this basically means if that we can't mix registered and unregistered options (yet). if (bUnregistered) Impl_.UnregisteredOptions = collect_unrecognized(ParsedOptions.options, include_positional); else { store(ParsedOptions, Impl_.RegisteredOptions); // notify() is required for automatic value storage and default values notify(Impl_.RegisteredOptions); } } }}}" Bugs reopened Boost 1.42.0 program_options None Problem s.ochsenknecht@…