Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comma Delimiter Breaking Quoted Strings #380

Open
DauntlessStudio opened this issue Nov 21, 2022 · 2 comments
Open

Comma Delimiter Breaking Quoted Strings #380

DauntlessStudio opened this issue Nov 21, 2022 · 2 comments

Comments

@DauntlessStudio
Copy link

Parsing an argument into a vector using the CXXOPTS_VECTOR_DELIMITER interacts unexpectedly with arguments in quotes.

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: \,.

@PKua007
Copy link

PKua007 commented Jan 23, 2023

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.

@akropp
Copy link

akropp commented Oct 6, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants