diff --git a/open_terminal/utils/runner.py b/open_terminal/utils/runner.py index 2e63868..137d541 100644 --- a/open_terminal/utils/runner.py +++ b/open_terminal/utils/runner.py @@ -61,7 +61,10 @@ def __init__(self, command: str, cwd: str | None, env: dict | None, run_as_user: if run_as_user: # Build the inner command: optionally cd first, then run the command. inner = f"cd {shlex.quote(cwd)} && {command}" if cwd else command - command = f"sudo -u {shlex.quote(run_as_user)} -- bash -c {shlex.quote(inner)}" + # ``sudo`` resets the environment by default. ``-E`` preserves + # it so that caller-supplied env vars (e.g. ``GH_TOKEN``) actually + # reach the child process. + command = f"sudo -E -u {shlex.quote(run_as_user)} -- bash -c {shlex.quote(inner)}" cwd = None # Popen runs as parent user — can't chdir into chmod 700 dirs master_fd, slave_fd = pty.openpty() try: