]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Stop option processing immediately after "-c command",
authorGuido van Rossum <guido@python.org>
Thu, 2 Jan 1992 16:16:18 +0000 (16:16 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 2 Jan 1992 16:16:18 +0000 (16:16 +0000)
leaving additional options for the command to handle.

Python/pythonmain.c

index 0e47c9a3d60946e113da3e90e72d4db2bf8cdce8..0f8ff02390360a022ea7651b0323f7428a3fbaf7 100644 (file)
@@ -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;
-
                }
        }