diff options
author | Guido van Rossum <guido@python.org> | 1997-12-05 21:56:45 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-12-05 21:56:45 (GMT) |
commit | a075ce1618c30c7d0faf4de6e84920027da40e41 (patch) | |
tree | 571d41a66aa38714b34525f3f6ba154b8243b70c | |
parent | 595d7ba06981edcddaa89c58e67300ef6d92f3c7 (diff) | |
download | cpython-a075ce1618c30c7d0faf4de6e84920027da40e41.zip cpython-a075ce1618c30c7d0faf4de6e84920027da40e41.tar.gz cpython-a075ce1618c30c7d0faf4de6e84920027da40e41.tar.bz2 |
Two changes by Jeff Rush (slightly tweaked):
- New option -x, to skip first line of script
- Use the correct platform-specific delimiter and library location in
the usage message
(Also removed two blank lines and moved one line around so that each
part of the usage message is again under 512 bytes and the whole usage
message still fits in 23 lines.)
-rw-r--r-- | Modules/main.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/Modules/main.c b/Modules/main.c index df79ab5..83fd9dc 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -32,6 +32,7 @@ PERFORMANCE OF THIS SOFTWARE. /* Python interpreter main program */ #include "Python.h" +#include "osdefs.h" #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -41,6 +42,12 @@ PERFORMANCE OF THIS SOFTWARE. #include <fcntl.h> #endif +#if defined(PYOS_OS2) || defined(MS_WINDOWS) +#define PYTHONHOMEHELP "<prefix>\\lib" +#else +#define PYTHONHOMEHELP "<prefix>/python1.5" +#endif + /* Interface to getopt(): */ extern int optind; extern char *optarg; @@ -53,20 +60,21 @@ static int orig_argc; /* Short usage message (with %s for argv0) */ static char *usage_line = -"usage: %s [-d] [-i] [-O] [-S] [-u] [-v] [-X] [-c cmd | file | -] [arg] ...\n"; +"usage: %s [-d] [-i] [-O] [-S] [-u] [-v] [-x] [-X] [-c cmd | file | -] [arg] ...\n"; /* Long usage message, split into parts < 512 bytes */ -static char *usage_top = "\n\ +static char *usage_top = "\ Options and arguments (and corresponding environment variables):\n\ -d : debug output from parser (also PYTHONDEBUG=x)\n\ -i : inspect interactively after running script, (also PYTHONINSPECT=x)\n\ and force prompts, even if stdin does not appear to be a terminal.\n\ -O : optimize generated bytecode (a tad).\n\ -S : don't imply 'import site' on initialization\n\ +-u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)\n\ "; static char *usage_mid = "\ --u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)\n\ -v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\ +-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ -X : disable class based built-in exceptions\n\ -c cmd : program passed in as string (terminates option list)\n\ file : program read from script file\n\ @@ -74,13 +82,12 @@ file : program read from script file\n\ arg ...: arguments passed to program in sys.argv[1:]\n\ "; static char *usage_bot = "\ -\n\ Other environment variables:\n\ PYTHONSTARTUP: file executed on interactive startup (no default)\n\ -PYTHONPATH : colon-separated list of directories prefixed to the\n\ +PYTHONPATH : '%c'-separated list of directories prefixed to the\n\ default module search path. The result is sys.path.\n\ -PYTHONHOME : alternate <prefix> directory (or <prefix>:<exec_prefix>).\n\ - The default module search path uses <prefix>/lib/python1.5.\n\ +PYTHONHOME : alternate <prefix> directory (or <prefix>%c<exec_prefix>).\n\ + The default module search path uses %s.\n\ "; @@ -99,6 +106,7 @@ Py_Main(argc, argv) char *p; int inspect = 0; int unbuffered = 0; + int skipfirstline = 0; int stdin_is_interactive = 0; orig_argc = argc; /* For Py_GetArgcArgv() */ @@ -109,7 +117,7 @@ Py_Main(argc, argv) if ((p = getenv("PYTHONUNBUFFERED")) && *p != '\0') unbuffered = 1; - while ((c = getopt(argc, argv, "c:diOSuvX")) != EOF) { + while ((c = getopt(argc, argv, "c:diOSuvxX")) != EOF) { if (c == 'c') { /* -c is the last option; following arguments that look like options are left for the @@ -150,6 +158,10 @@ Py_Main(argc, argv) Py_VerboseFlag++; break; + case 'x': + skipfirstline = 1; + break; + case 'X': Py_UseClassExceptionsFlag = 0; break; @@ -160,7 +172,8 @@ Py_Main(argc, argv) fprintf(stderr, usage_line, argv[0]); fprintf(stderr, usage_top); fprintf(stderr, usage_mid); - fprintf(stderr, usage_bot); + fprintf(stderr, usage_bot, + DELIM, DELIM, PYTHONHOMEHELP); exit(2); /*NOTREACHED*/ @@ -177,6 +190,10 @@ Py_Main(argc, argv) argv[0], filename); exit(2); } + else if (skipfirstline) { + char line[256]; + fgets(line, sizeof line, fp); + } } } |