Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da8cd86

Browse files
committed
Add $PYTHONSTARTUP feature.
1 parent 14b4adb commit da8cd86

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Python/pythonmain.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ main(argc, argv)
105105
sts = run_command(command) != 0;
106106
}
107107
else {
108+
if (filename == NULL && isatty((int)fileno(fp))) {
109+
char *startup = getenv("PYTHONSTARTUP");
110+
if (startup != NULL && startup[0] != '\0') {
111+
FILE *fp = fopen(startup, "r");
112+
if (fp != NULL) {
113+
(void) run_script(fp, startup);
114+
err_clear();
115+
}
116+
}
117+
}
108118
sts = run(fp, filename == NULL ? "<stdin>" : filename) != 0;
109119
}
110120

0 commit comments

Comments
 (0)