mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 09:13:37 +02:00
jw.pkg.lib.util.run_cmd(): Honour env in PTY mode
The evironment passed to run_cmd() via env is currently not honoured with mode:interactive. Fix that. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
838b745581
commit
f8dc8ee6d1
1 changed files with 9 additions and 0 deletions
|
|
@ -104,6 +104,15 @@ async def run_cmd(
|
|||
)
|
||||
|
||||
def _spawn():
|
||||
# Apply env in PTY mode by temporarily updating os.environ around spawn.
|
||||
if env:
|
||||
old_env = os.environ.copy()
|
||||
try:
|
||||
os.environ.update(env)
|
||||
return pty.spawn(args, master_read=reader)
|
||||
finally:
|
||||
os.environ.clear()
|
||||
os.environ.update(old_env)
|
||||
return pty.spawn(args, master_read=reader)
|
||||
|
||||
__check_exit_code(await asyncio.to_thread(_spawn))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue