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

getopt with config.stopOnFirstNonOption fails to recognize option #10362

Open
dlangBugzillaToGithub opened this issue Dec 11, 2018 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

timosesu reported this on 2018-12-11T16:30:09Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=19478

Description

std.getopt seems to fail when reversing the order of the options passed as args when config.stopOnFirstNonOption is enabled.

    string dir1;
    string dir2;
    
    string[] args = ["./app",  "--dir1", "dir1","--dir2", "dir2"];
    auto result = getopt(args,
            config.stopOnFirstNonOption,
            "dir1", "first dir", &dir1,
            "dir2", "second dir", &dir2);

	assert(dir1 == "dir1" && dir2 == "dir2");
    
    args = ["./app",  "--dir2", "dir2","--dir1", "dir1"];
    // No problem without 'config.stopOnFirstNonOption'
    result = getopt(args,
            "dir1", "first dir", &dir1,
            "dir2", "second dir", &dir2);
  
    assert(dir1 == "dir1" && dir2 == "dir2");
    
    args = ["./app",  "--dir2", "dir2","--dir1", "dir1"];
    // Throws: "Unrecognized option --dir1"
    result = getopt(args,
            config.stopOnFirstNonOption,
            "dir1", "first dir", &dir1,
            "dir2", "second dir", &dir2);
@thewilsonator thewilsonator removed P3 Arch:x86 Issues specific to x86 OS:Mac OS Issues Specific to Mac OS labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants