Author wangchun
Recipients wangchun
Date 2008-12-11.06:54:15
SpamBayes Score 0.00182177
Marked as misclassified No
Message-id <>
Consider the following program

import sys, getopt
print(getopt.getopt(sys.argv[1:], '', ['help']))

The program accept "--help" without a value:

python --help

But if someone invoke the program like:

python --help=

Python should raise an error.

"--help=" is not considered as no_argument in libc's getopt implementation (tested on Mac OS X 

#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
Date User Action Args
2008-12-11 06:54:18wangchunsetrecipients: + wangchun
2008-12-11 06:54:18wangchunsetmessageid: <>
2008-12-11 06:54:17wangchunlinkissue4629 messages
2008-12-11 06:54:15wangchuncreate