This commit is contained in:
Paul Gauthier 2024-08-31 15:50:50 -07:00
parent 0c5cd64b83
commit 22318a3160

View file

@ -18,7 +18,7 @@ def run_cmd(command, verbose=False):
def run_cmd_subprocess(command, verbose=False):
if verbose:
print("run_cmd_subprocess:", command)
print("Using run_cmd_subprocess:", command)
try:
process = subprocess.Popen(
command,
@ -52,7 +52,7 @@ def run_cmd_pexpect(command, verbose=False):
:return: A tuple containing (exit_status, output)
"""
if verbose:
print("run_cmd_pexpect:", command)
print("Using run_cmd_pexpect:", command)
output = BytesIO()
@ -64,17 +64,17 @@ def run_cmd_pexpect(command, verbose=False):
# Use the SHELL environment variable, falling back to /bin/sh if not set
shell = os.environ.get("SHELL", "/bin/sh")
if verbose:
print("shell:", shell)
print("With shell:", shell)
if os.path.exists(shell):
# Use the shell from SHELL environment variable
if verbose:
print("pexpect.spawn with shell:", shell)
print("Running pexpect.spawn with shell:", shell)
child = pexpect.spawn(shell, args=["-c", command], encoding="utf-8")
else:
# Fall back to spawning the command directly
if verbose:
print("pexpect.spawn without shell")
print("Running pexpect.spawn without shell.")
child = pexpect.spawn(command, encoding="utf-8")
# Transfer control to the user, capturing output