Bug 12521 – std.getopt does not conform to documentation
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-04T16:05:36Z
Last change time
2020-07-13T20:46:25Z
Keywords
pull
Assigned to
No Owner
Creator
Jason Spashett
Comments
Comment #0 by jason — 2014-04-04T16:05:36Z
Either the documentation is incorrect or the implementation is.
The documentation says:
"If the option has a parameter, that must be "stuck" to the option without any intervening space or "=": "
and
"Forms such as -t 5 and -timeout=5 will be not accepted. "
Does not appear to be true. The form -t 5 is accepted.
Example:
import std.stdio;
import std.getopt;
void main(string[] args)
{
uint age;
std.getopt.getopt(args, "a", &age);
writeln("age = ", age);
writeln("args = ", args);
}
C:\temp>dmd getopt.d && getopt -a 5000
age = 5000
args = ["getopt"]
Windows XP 32 bit. v2.065
The implementation seems to work correctly as I regard it, unless there is a reason why it should be disallowed I think short options need not have thier parameter immediatly follow the option, and so the documentation should be adjusted.
Comment #1 by dlang-bot — 2020-07-13T19:15:07Z
@quickfur created dlang/phobos pull request #7555 "Fix bug 12521: update docs to match current getopt behaviour." fixing this issue:
- Fix bug 12521: update docs to match current getopt behaviour.
https://github.com/dlang/phobos/pull/7555
Comment #2 by dlang-bot — 2020-07-13T20:46:25Z
dlang/phobos pull request #7555 "Fix bug 12521: update docs to match current getopt behaviour." was merged into master:
- 8812bb54497ecde6d5e2535991508d7152157f49 by H. S. Teoh:
Fix bug 12521: update docs to match current getopt behaviour.
https://github.com/dlang/phobos/pull/7555