summaryrefslogtreecommitdiff
path: root/Python/getopt.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-09-13 13:45:32 +0000
committerGuido van Rossum <guido@python.org>1999-09-13 13:45:32 +0000
commit2adac0a6377ce9779f2db7ba05f3769e30a7a5a6 (patch)
treed95444473e0ae6f5bd4817393f13bbeb1334eada /Python/getopt.c
parent8037cb11f5d9dc9eee5a64e5aa0b4f06fbabcaad (diff)
downloadcpython-git-2adac0a6377ce9779f2db7ba05f3769e30a7a5a6.tar.gz
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.
Diffstat (limited to 'Python/getopt.c')
-rw-r--r--Python/getopt.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/getopt.c b/Python/getopt.c
index 5175e0a3de..c5a3f62681 100644
--- a/Python/getopt.c
+++ b/Python/getopt.c
@@ -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) {