Home > OS >  Dealing with special characters in CLI11
Dealing with special characters in CLI11

Time:06-10

I have code like the following

flags->add_option("--name", name_, "The name.")->required();

I want to be able to pass strings like "aa$p$aa" to the --name parameter. However, this does not seem to work with CLI11, and the name gets truncated to just "aa". I need to escape the $ characters to properly read the strings. So aa\$p\$aa works fine, and I get the expected string ("aa$p$aa").

Changing the function to add_flag() does not work either.

Is there a way to be able to pass arbitrary strings to a parameter as with either function calls above?

CodePudding user response:

Your operating system takes the command you type in and executes the given program, passing the parameters to it.

The interpolation, and the handling of $ characters in typed-in commands is handled by your operating system as part of executing the typed-in command. Your compiled C program receives the transformed arguments, as parameters. Your C program has no means to control what has happened before it was even executed.

  • Related