Tim Peters discovered a bug in the Python-supplied getopt():

it doesn't recognize a lone dash as a non-flag argument.
Now it does.
This commit is contained in:
Guido van Rossum 1999-09-13 13:45:32 +00:00
parent 8037cb11f5
commit 2adac0a637
1 changed files with 2 additions and 1 deletions

View File

@ -55,7 +55,8 @@ int getopt( int argc, char *const *argv, const char *optstring )
if (*opt_ptr == '\0') { if (*opt_ptr == '\0') {
if (optind >= argc || argv[optind][0] != '-') if (optind >= argc || argv[optind][0] != '-' ||
argv[optind][1] == '\0' /* lone dash */ )
return -1; return -1;
else if (strcmp(argv[optind], "--") == 0) { else if (strcmp(argv[optind], "--") == 0) {