]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add $PYTHONSTARTUP feature.
authorGuido van Rossum <guido@python.org>
Thu, 3 Sep 1992 20:26:57 +0000 (20:26 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 3 Sep 1992 20:26:57 +0000 (20:26 +0000)
Python/pythonmain.c

index 4344cde452079646d62e12d6c6f9a7e65c479213..1c6469231d01e5fa85a3df547af5f7dfef902b75 100644 (file)
@@ -105,6 +105,16 @@ main(argc, argv)
                sts = run_command(command) != 0;
        }
        else {
+               if (filename == NULL && isatty((int)fileno(fp))) {
+                       char *startup = getenv("PYTHONSTARTUP");
+                       if (startup != NULL && startup[0] != '\0') {
+                               FILE *fp = fopen(startup, "r");
+                               if (fp != NULL) {
+                                       (void) run_script(fp, startup);
+                                       err_clear();
+                               }
+                       }
+               }
                sts = run(fp, filename == NULL ? "<stdin>" : filename) != 0;
        }