Skip to content

Commit 2adac0a

Browse files
committed
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.
1 parent 8037cb1 commit 2adac0a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Python/getopt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ int getopt( int argc, char *const *argv, const char *optstring )
5555

5656
if (*opt_ptr == '\0') {
5757

58-
if (optind >= argc || argv[optind][0] != '-')
58+
if (optind >= argc || argv[optind][0] != '-' ||
59+
argv[optind][1] == '\0' /* lone dash */ )
5960
return -1;
6061

6162
else if (strcmp(argv[optind], "--") == 0) {

0 commit comments

Comments
 (0)