digitalmars.D.bugs - [Issue 19478] New: getopt with config.stopOnFirstNonOption fails to
- d-bugmail puremagic.com (37/37) Dec 11 2018 https://issues.dlang.org/show_bug.cgi?id=19478
https://issues.dlang.org/show_bug.cgi?id=19478 Issue ID: 19478 Summary: getopt with config.stopOnFirstNonOption fails to recognize option Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: minor Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: timosesu gmail.com 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); --
Dec 11 2018