Have read_shell_environment() not fail when no shell is present

This commit is contained in:
Kovid Goyal
2019-12-27 12:25:01 +05:30
parent 7bed66a458
commit ee7a5eef99

View File

@@ -207,7 +207,11 @@ def read_shell_environment(opts=None):
shell = resolved_shell(opts)
master, slave = openpty()
remove_blocking(master)
p = subprocess.Popen(shell + ['-l', '-c', 'env'], stdout=slave, stdin=slave, stderr=slave, start_new_session=True, close_fds=True)
try:
p = subprocess.Popen(shell + ['-l', '-c', 'env'], stdout=slave, stdin=slave, stderr=slave, start_new_session=True, close_fds=True)
except FileNotFoundError:
log_error('Could not find shell to read environment')
return ans
with os.fdopen(master, 'rb') as stdout, os.fdopen(slave, 'wb'):
raw = b''
from subprocess import TimeoutExpired