std.getopt error

Ramon spam at thanks.no
Sun Aug 25 23:58:40 PDT 2013


There seems to be a bug in std.getopt.

D doc says:
"To set timeout to 5, use either of the following: --timeout=5, 
--timeout 5, --t=5, --t 5, or ** -t5 **. Forms such as -t 5 and 
-timeout=5 will be not accepted."

However

bool reverseOrder = false, helpFlag = false;
int colOrder = 1;

getopt(args, std.getopt.config.bundling, "reverse|r", 
&reverseOrder, "column|c", &colOrder,"help|?", &helpFlag);

sets colOrder to -1 rather than to +1 when the commandline has 
"-c1" as arg.

Funnily, when the arg is *illegally* "-c 1", the variable is set 
correctly to +1.

This is not an urgent issue because there is a very simple 
workaround:
colorder = - colorder;

But I thought it should be mentioned anyway and, if not noticed 
it can create troublesome situations.

Being at that, the official rule "-t 5" is not acceptable is 
problematic because that form is pretty commonly used on unix and 
even sometimes used in docs.

- R


More information about the Digitalmars-d mailing list