Mercurial > cpython-lru_cache-weakref
comparison Python/pythonmain.c @ 560:0614d887d10a legacy-trunk
Stop option processing immediately after "-c command",
leaving additional options for the command to handle.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 02 Jan 1992 16:16:18 +0000 |
| parents | e198cc98a4fd |
| children | 0868176365d7 |
comparison
equal
deleted
inserted
replaced
| 559:683edb0c4463 | 560:0614d887d10a |
|---|---|
| 63 FILE *fp = stdin; | 63 FILE *fp = stdin; |
| 64 | 64 |
| 65 initargs(&argc, &argv); /* Defined in config*.c */ | 65 initargs(&argc, &argv); /* Defined in config*.c */ |
| 66 | 66 |
| 67 while ((c = getopt(argc, argv, "c:")) != EOF) { | 67 while ((c = getopt(argc, argv, "c:")) != EOF) { |
| 68 if (c == 'c') { | |
| 69 /* -c is the last option; following arguments | |
| 70 that look like options are left for the | |
| 71 the command to interpret. */ | |
| 72 command = malloc(strlen(optarg) + 2); | |
| 73 /* Ignore malloc errors this early... */ | |
| 74 strcpy(command, optarg); | |
| 75 strcat(command, "\n"); | |
| 76 break; | |
| 77 } | |
| 78 | |
| 68 switch (c) { | 79 switch (c) { |
| 80 | |
| 81 /* This space reserved for other options */ | |
| 69 | 82 |
| 70 default: | 83 default: |
| 71 fprintf(stderr, | 84 fprintf(stderr, |
| 72 "usage: %s [-c cmd | file | -] [arg] ...\n", | 85 "usage: %s [-c cmd | file | -] [arg] ...\n", |
| 73 argv[0]); | 86 argv[0]); |
| 74 exit(2); | 87 exit(2); |
| 75 /*NOTREACHED*/ | 88 /*NOTREACHED*/ |
| 76 | |
| 77 case 'c': | |
| 78 if (command != NULL) { | |
| 79 fprintf(stderr, "%s: duplicate -c option\n", | |
| 80 argv[0]); | |
| 81 exit(2); | |
| 82 } | |
| 83 command = malloc(strlen(optarg) + 2); | |
| 84 /* Ignore malloc errors this early... */ | |
| 85 strcpy(command, optarg); | |
| 86 strcat(command, "\n"); | |
| 87 break; | |
| 88 | 89 |
| 89 } | 90 } |
| 90 } | 91 } |
| 91 | 92 |
| 92 if (command == NULL && optind < argc && strcmp(argv[optind], "-") != 0) | 93 if (command == NULL && optind < argc && strcmp(argv[optind], "-") != 0) |
