Skip to content

Commit

Permalink
Stop option processing immediately after "-c command",
Browse files Browse the repository at this point in the history
leaving additional options for the command to handle.
  • Loading branch information
gvanrossum committed Jan 2, 1992
1 parent bdfcfcc commit 46b1638
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions Python/pythonmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,28 @@ 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",
argv[0]);
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;

}
}

Expand Down

0 comments on commit 46b1638

Please sign in to comment.