summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-01-02 16:16:18 (GMT)
committerGuido van Rossum <guido@python.org>1992-01-02 16:16:18 (GMT)
commit46b1638044ab8afaa78843a8f5f76213f20ef023 (patch)
tree4cc68df938996a968ef911957b3bfad6f7640b01 /Python
parentbdfcfccbe591e15221f35add01132174c9b4e669 (diff)
downloadcpython-46b1638044ab8afaa78843a8f5f76213f20ef023.zip
cpython-46b1638044ab8afaa78843a8f5f76213f20ef023.tar.gz
cpython-46b1638044ab8afaa78843a8f5f76213f20ef023.tar.bz2
Stop option processing immediately after "-c command",
leaving additional options for the command to handle.
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonmain.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/Python/pythonmain.c b/Python/pythonmain.c
index 0e47c9a..0f8ff02 100644
--- a/Python/pythonmain.c
+++ b/Python/pythonmain.c
@@ -65,8 +65,21 @@ main(argc, argv)
initargs(&argc, &argv); /* Defined in config*.c */
while ((c = getopt(argc, argv, "c:")) != EOF) {
+ if (c == 'c') {
+ /* -c is the last option; following arguments
+ that look like options are left for the
+ the command to interpret. */
+ command = malloc(strlen(optarg) + 2);
+ /* Ignore malloc errors this early... */
+ strcpy(command, optarg);
+ strcat(command, "\n");
+ break;
+ }
+
switch (c) {
+ /* This space reserved for other options */
+
default:
fprintf(stderr,
"usage: %s [-c cmd | file | -] [arg] ...\n",
@@ -74,18 +87,6 @@ main(argc, argv)
exit(2);
/*NOTREACHED*/
- case 'c':
- if (command != NULL) {
- fprintf(stderr, "%s: duplicate -c option\n",
- argv[0]);
- exit(2);
- }
- command = malloc(strlen(optarg) + 2);
- /* Ignore malloc errors this early... */
- strcpy(command, optarg);
- strcat(command, "\n");
- break;
-
}
}