comparison Python/pythonmain.c @ 1318:92e6a8cf14be legacy-trunk

* pythonmain.c: -k option, usage message, more environment flags. (the latter also in frozenmain.c) * ceval.c: global 'killprint' flag raises exception when printing an expression statement's value (useful for finding stray output) * timemodule.c: add asctime() and ctime(). Change julian date to 1-based origin (as intended and documented). * Removed unused DO_TIMES stuff from timemodule.c. Added 'epoch' and 'day0' globals (year where time.time() == 0 and day of the week the epoch started).
author Guido van Rossum <guido@python.org>
date Thu, 24 Jun 1993 11:10:19 +0000
parents 14369a5e6167
children c914b10bf2ed
comparison
equal deleted inserted replaced
1317:ec312b647fcb 1318:92e6a8cf14be
24 24
25 /* Python interpreter main program */ 25 /* Python interpreter main program */
26 26
27 #include "allobjects.h" 27 #include "allobjects.h"
28 28
29 extern int debugging; /* Needed by parser.c */ 29 extern int debugging; /* Defined in parser.c */
30 extern int verbose; /* Needed by import.c */ 30 extern int verbose; /* Defined in import.c */
31 extern int killprint; /* Defined in ceval.c */
31 32
32 /* Interface to getopt(): */ 33 /* Interface to getopt(): */
33 extern int optind; 34 extern int optind;
34 extern char *optarg; 35 extern char *optarg;
35 extern int getopt PROTO((int, char **, char *)); 36 extern int getopt PROTO((int, char **, char *));
50 51
51 if ((p = getenv("PYTHONDEBUG")) && *p != '\0') 52 if ((p = getenv("PYTHONDEBUG")) && *p != '\0')
52 debugging = 1; 53 debugging = 1;
53 if ((p = getenv("PYTHONVERBOSE")) && *p != '\0') 54 if ((p = getenv("PYTHONVERBOSE")) && *p != '\0')
54 verbose = 1; 55 verbose = 1;
56 if ((p = getenv("PYTHONINSPECT")) && *p != '\0')
57 inspect = 1;
58 if ((p = getenv("PYTHONKILLPRINT")) && *p != '\0')
59 killprint = 1;
55 60
56 initargs(&argc, &argv); /* Defined in config*.c */ 61 initargs(&argc, &argv);
57 62
58 while ((c = getopt(argc, argv, "c:div")) != EOF) { 63 while ((c = getopt(argc, argv, "c:dikv")) != EOF) {
59 if (c == 'c') { 64 if (c == 'c') {
60 /* -c is the last option; following arguments 65 /* -c is the last option; following arguments
61 that look like options are left for the 66 that look like options are left for the
62 the command to interpret. */ 67 the command to interpret. */
63 command = malloc(strlen(optarg) + 2); 68 command = malloc(strlen(optarg) + 2);
75 80
76 case 'i': 81 case 'i':
77 inspect++; 82 inspect++;
78 break; 83 break;
79 84
85 case 'k':
86 killprint++;
87 break;
88
80 case 'v': 89 case 'v':
81 verbose++; 90 verbose++;
82 break; 91 break;
83 92
84 /* This space reserved for other options */ 93 /* This space reserved for other options */
85 94
86 default: 95 default:
87 fprintf(stderr, 96 fprintf(stderr,
88 "usage: %s [-c cmd | file | -] [arg] ...\n", 97 "usage: %s [-d] [-i] [-k] [-v] [-c cmd | file | -] [arg] ...\n",
89 argv[0]); 98 argv[0]);
99 fprintf(stderr, "\
100 \n\
101 Options and arguments (and corresponding environment variables):\n\
102 -d : debug output from parser (also PYTHONDEBUG=x)\n\
103 -i : inspect interactively after running script (also PYTHONINSPECT=x)\n\
104 -k : kill printing expression statement (also PYTHONKILLPRINT=x)\n\
105 -v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\
106 -c cmd : program passed in as string (terminates option list)\n\
107 file : program read from script file\n\
108 - : program read from stdin (default; interactive mode if a tty)\n\
109 arg ...: arguments passed to program in sys.argv[1:]\n\
110 \n\
111 Other environment variables:\n\
112 PYTHONSTARTUP: file executed on interactive startup (no default)\n\
113 PYTHONPATH : colon-separated list of directories prefixed to the\n\
114 default module search path. The result is sys.path.\n\
115 ");
90 exit(2); 116 exit(2);
91 /*NOTREACHED*/ 117 /*NOTREACHED*/
92 118
93 } 119 }
94 } 120 }