#5383: GetOpt parser too strict
-----------------------------+----------------------------------------------
Reporter: mcandre | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: libraries/base | Version: 7.0.4
Resolution: wontfix | Keywords:
Testcase: | Blockedby:
Difficulty: | Os: Unknown/Multiple
Blocking: | Architecture: Unknown/Multiple
Failure: None/Unknown |
-----------------------------+----------------------------------------------
Changes (by igloo):
* status: new => closed
* resolution: => wontfix
* component: libraries/unix => libraries/base
Comment:
This matches the GNU getopt behaviour with optional arguments:
{{{
$ cat z.c
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main (int argc, char **argv) {
int c;
while ((c = getopt (argc, argv, "ab:c::")) != -1) {
switch (c) {
case 'a':
printf("Got a: %p\n", optarg);
break;
case 'b':
printf("Got b: %p\n", optarg);
break;
case 'c':
printf("Got c: %p\n", optarg);
break;
default:
printf("Got something else\n");
}
}
return 0;
}
$ gcc z.c -o z
$ ./z -a 2
Got a: (nil)
$ ./z -b 2
Got b: 0x7fff1fed24a9
$ ./z -c 2
Got c: (nil)
$ ./z -b2
Got b: 0x7fff2e0a24a9
$ ./z -c2
Got c: 0x7fff4016d4a9
}}}
The difference is `ReqArg` vs `OptArg`, not `String` vs `Int` (both are
`String` as far as `GetOpt` is concerned).
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5383#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs