cxxopts
cxxopts copied to clipboard
Comma Delimiter Breaking Quoted Strings
Parsing an argument into a vector
Expected Result:
Providing the argument --strings "string_one","string,two" would be parsed as a vector with two strings: "string_one" and "string,two".
Actual Result:
Providing the argument --strings "string_one","string,two" is parsed as a vector with three strings: "string_one", "string", and "two".
It would be great if the delimiter was disabled when parsing an argument in quotes, or possibly the delimiter could be escaped with: \,.
I am pretty sure that the quotes are interpreted directly by the shell and the two cases are indistinguishable by the framework.
Escaping , is a good idea though.
If you were to construct argv/argc directly (or do the proper amount of escaping in the shell), you can have the following: argv[1] = "--strings" argv[2] = ""string_one","string,two""
It would be nice to be able to have "string,two" be interpreted as one value. Or at least be able to do something like: argv[2] = ""string_one","string,two"" and have the escaped comma not be interpreted as a delimiter.
Would you be open to a patch to allow for escaping?