aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lechner2020-01-15 12:05:06 -0600
committerDamien George2020-02-04 17:52:58 +1100
commit122baa678733636336689feeb4e2c8b4807649db (patch)
treea82231eef276d4c3e6d250c65561bbcd6b9f419e
parentbc3ce86a5ab5bf697e2d7a88940020953cafdb82 (diff)
unix/main: Add support for MICROPYINSPECT environment variable.
This adds support for a MICROPYINSPECT environment variable that works exactly like PYTHONINSPECT; per CPython docs: If this is set to a non-empty string it is equivalent to specifying the -i option. This variable can also be modified by Python code using os.environ to force inspect mode on program termination.
-rw-r--r--ports/unix/main.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ports/unix/main.c b/ports/unix/main.c
index e12915454..deda8eb70 100644
--- a/ports/unix/main.c
+++ b/ports/unix/main.c
@@ -647,6 +647,10 @@ MP_NOINLINE int main_(int argc, char **argv) {
}
}
+ const char *inspect_env = getenv("MICROPYINSPECT");
+ if (inspect_env && inspect_env[0] != '\0') {
+ inspect = true;
+ }
if (ret == NOTHING_EXECUTED || inspect) {
if (isatty(0)) {
prompt_read_history();