]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Tim Peters discovered a bug in the Python-supplied getopt():
authorGuido van Rossum <guido@python.org>
Mon, 13 Sep 1999 13:45:32 +0000 (13:45 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 13 Sep 1999 13:45:32 +0000 (13:45 +0000)
it doesn't recognize a lone dash as a non-flag argument.
Now it does.

Python/getopt.c

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