From dc38b0d315cbf5b220855180afb92a288e8e0d36 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Sat, 15 Feb 2025 20:34:56 +0700 Subject: [PATCH] Preserve current environment when spawning bash This is useful if you want to set some random env vars (like `NIX_PATH`). --- src/tesh/test.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tesh/test.py b/src/tesh/test.py index 525b0ae..967216f 100644 --- a/src/tesh/test.py +++ b/src/tesh/test.py @@ -65,7 +65,12 @@ def test(filename: str, session: ShellSession, verbose: bool, debug: bool) -> No shell = spawn( "bash --norc --noprofile", encoding="utf-8", - env={"PS1": "$ ", "PATH": os.environ["PATH"], "HOME": os.getcwd()}, + env={ + **os.environ, + "PS1": "$ ", + "PATH": os.environ["PATH"], + "HOME": os.getcwd(), + }, # The (height, width) of the TTY commands run in. 24 is the default. # The width needs to be larger than the longest command, as # otherwise the command string gets truncated and the shell.expect