Skip to content

Commit 05a9bcb

Browse files
author
guido
committed
Fix a bug in this code that made it do the wrong thing when an option
was a single '-'. Thanks to Andrew Kuchling. git-svn-id: http://svn.python.org/projects/python/trunk@8841 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 8410c18 commit 05a9bcb

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Python/getopt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ char optstring[];
6262
opt_ptr = &argv[optind++][1];
6363
}
6464

65-
if ((ptr = strchr(optstring, option = *opt_ptr++)) == NULL) {
65+
if ( (option = *opt_ptr++) == '\0')
66+
return -1;
67+
68+
if ((ptr = strchr(optstring, option)) == NULL) {
6669
if (opterr)
6770
fprintf(stderr, "Unknown option: -%c\n", option);
6871

0 commit comments

Comments
 (0)