Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #1877 (closed defect: fixed)

Opened 10 years ago

Last modified 10 years ago

text.Arguments: argument prefix followed by nothing sets null argument instead of becoming parameter

Reported by: Deewiant Assigned to: kris
Priority: normal Milestone: 1.0
Component: Tango Version: trunk
Keywords: Cc:

Description

import tango.io.Stdout;
import tango.text.Arguments;
void main() {
	auto parser = new Arguments;
	parser.parse(["-", "-x", "-", "-y", "-"]);
	auto args = parser("").assigned;
	foreach (i, arg; args)
		Stdout.formatln("{}: `{}`", i, arg);
	Stdout(parser("").set).newline;
}

I would expect the above code to print:

0: `-`
1: `-`
2: `-`
false

Currently it prints:

true

I.e. the "-" arguments were considered as enabling the null argument instead of becoming parameters of the null argument. I think that's counterintuitive. Many programs that take a filename as an argument use "-" to denote stdin instead; the current behaviour doesn't really support that kind of usage.

Change History

03/11/10 20:48:40 changed by kris

the "" empty argument would appear to be unsupported ... is "" really a legitimate argument instance?

03/11/10 20:55:57 changed by Deewiant

My whole point was that it shouldn't be, but it currently is: the "-" arguments are setting the empty argument instead of becoming parameters.

03/11/10 21:54:47 changed by kris

good; then the question is, should "-" by itself be an error condition? I kinda think it should, though you illustrate a use for it as a parameter

03/12/10 03:44:46 changed by kris

  • status changed from new to closed.
  • resolution set to fixed.

(In [5402]) fixes #1877 :: argument prefix followed by nothing sets null argument instead of becoming parameter

kudos to deewiant