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

use dd-style fail to get '\' in linux #97

Closed
Twinkle1087 opened this issue Feb 23, 2021 · 3 comments
Closed

use dd-style fail to get '\' in linux #97

Twinkle1087 opened this issue Feb 23, 2021 · 3 comments

Comments

@Twinkle1087
Copy link

I made a samiliar use as the dd-style example.
the code is following, the project name is server:
int main(int argc, char **argv)
{
args::ArgumentParser parser("push the commands");
parser.LongPrefix("");
parser.LongSeparator("=");
args::HelpFlag help(parser, "HELP", "Show this help menu.", { "help" });
args::ValueFlagstd::string logs_dir(parser, "Path", " Logs Directory", { "-log", "-LogPath" });
try
{
parser.ParseCLI(argc, argv);
}
catch (args::Help)
{
std::cout << parser;
return 0;
}
catch (args::ParseError e)
{
std::cerr << e.what() << std::endl;
std::cerr << parser;
return 1;
}
catch (args::ValidationError e)
{
std::cerr << e.what() << std::endl;
std::cerr << parser;
return 1;
}
if (logs_dir)
{
std::cout << "if = " << args::get(logs_dir) << std::endl;
}
}
than I ues the command to started the program in windows(the exe name is server):
./server.exe -log=server_1\logs
the output is:
if = server_1\logs
Then I built a linux program in Ubuntu 20.04 LTS, I started the program :
./server -log=server_1\logs
the output is:
if = server_1logs
The '' has been disappered
So how can I fix this problem?
Thank you!

@Twinkle1087
Copy link
Author

The \ symbol has been disappered as the third sentence from the bottom

@Twinkle1087
Copy link
Author

well, in linux path use /

@Taywee
Copy link
Owner

Taywee commented Mar 1, 2021

That is probably actually your shell eating it, as backslashes are typically used as escape characters. If you surround the argument in single-quotes, the backslash won't get eaten (double quotes may or may not help, depending on your shell). But you're right, Linux paths do use forward slashes.

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

2 participants