Message77597
Consider the following program tmp.py:
import sys, getopt
print(getopt.getopt(sys.argv[1:], '', ['help']))
The program accept "--help" without a value:
python helloworld.py --help
But if someone invoke the program like:
python helloworld.py --help=
Python should raise an error.
"--help=" is not considered as no_argument in libc's getopt implementation (tested on Mac OS X
Leopard):
#include <getopt.h>
static struct option longopts[] = {
{ "help", no_argument, NULL, "h" },
};
#include <getopt.h>
static struct option longopts[] = {
{ "help", no_argument, NULL, 'h' },
};
int main(int argc, char **argv)
{
while (getopt_long(argc, argv, "h", longopts, NULL) != -1);
return 0;
}
macbook:~/tmp$ gcc -o tmp tmp.c
macbook:~/tmp$ ./tmp --help=
tmp: option `--help' doesn't allow an argument
macbook:~/tmp$ |
|
Date |
User |
Action |
Args |
2008-12-11 06:54:18 | wangchun | set | recipients:
+ wangchun |
2008-12-11 06:54:18 | wangchun | set | messageid: <1228978458.01.0.0804138423997.issue4629@psf.upfronthosting.co.za> |
2008-12-11 06:54:17 | wangchun | link | issue4629 messages |
2008-12-11 06:54:15 | wangchun | create | |
|