Bug 9583 – std.getopt.getopt does not consume options terminator "--" from args list, as docs claim

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-24T10:43:00Z
Last change time
2013-03-02T12:32:47Z
Keywords
pull
Assigned to
nobody
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2013-02-24T10:43:56Z
Code: import std.getopt; import std.stdio; void main(string[] args) { int opt; writeln(args); getopt(args, "opt", &opt); writeln(args); } Results: $ ./test --opt=123 -- --a --b --c ["./test", "--opt=123", "--", "--a", "--b", "--c"] ["./test", "--", "--a", "--b", "--c"] $ Contrary to what the docs claim, the options terminator "--" is not consumed by getopt.
Comment #1 by hsteoh — 2013-02-24T12:16:42Z
Comment #2 by andrej.mitrovich — 2013-02-24T13:35:00Z
Comment #3 by andrej.mitrovich — 2013-02-24T13:35:25Z
(In reply to comment #2) > H. S. Teoh's pull: https://github.com/D-Programming-Language/phobos/pull/1159 Woops I didn't see you already pasted the link. The 'pull' keyword was missing though.
Comment #4 by github-bugzilla — 2013-02-26T06:54:59Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/20cda1eae065d2c1d259596028bfd38747bdd8b8 getopt should consume options terminator "--". As stated by the docs. (Cf. issue 9583) https://github.com/D-Programming-Language/phobos/commit/d6af6284383f84ff88b5420f9f66115315e4d20a Merge pull request #1159 from quickfur/getopt_optend Fix issue 9583
Comment #5 by dlang-bugzilla — 2013-03-01T21:20:26Z
The fix introduced a regression in rdmd (issue 9622). It might have been better to change the documentation instead.
Comment #6 by hsteoh — 2013-03-02T12:30:11Z
I don't understand, isn't that a bug with rdmd, not with this fix? Besides, one of my programs depends on this fix, because sometimes it needs getopt to not processing subsequent arguments that may begin with '-'.
Comment #7 by dlang-bugzilla — 2013-03-02T12:32:47Z
Yeah, you're right. The old behavior made no sense.