Fix return value of run_external_command (#5657)

This commit is contained in:
Jesse Hills 2023-11-02 17:06:09 +13:00 committed by GitHub
parent f70d651a39
commit 4edf3efdf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -222,7 +222,7 @@ def run_external_command(
try: try:
sys.argv = list(cmd) sys.argv = list(cmd)
sys.exit = mock_exit sys.exit = mock_exit
return func() or 0 retval = func() or 0
except KeyboardInterrupt: # pylint: disable=try-except-raise except KeyboardInterrupt: # pylint: disable=try-except-raise
raise raise
except SystemExit as err: except SystemExit as err:
@ -239,9 +239,10 @@ def run_external_command(
sys.stderr = orig_stderr sys.stderr = orig_stderr
if capture_stdout: if capture_stdout:
# pylint: disable=lost-exception
return cap_stdout.getvalue() return cap_stdout.getvalue()
return retval
def run_external_process(*cmd, **kwargs): def run_external_process(*cmd, **kwargs):
full_cmd = " ".join(shlex_quote(x) for x in cmd) full_cmd = " ".join(shlex_quote(x) for x in cmd)