D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12521 - std.getopt does not conform to documentation
Summary: std.getopt does not conform to documentation
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2014-04-04 16:05 UTC by Jason Spashett
Modified: 2020-07-13 20:46 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jason Spashett 2014-04-04 16:05:36 UTC
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 Dlang Bot 2020-07-13 19:15:07 UTC
@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 Dlang Bot 2020-07-13 20:46:25 UTC
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