Suppress subshell errors for CMD and Powershell

This commit is contained in:
Tzu-ping Chung
2018-03-14 02:14:10 +08:00
parent 2e9d2658e6
commit edf6da4807
+10 -1
View File
@@ -153,7 +153,16 @@ def fork_shell(env, shellcmd, cwd):
if 'VIRTUAL_ENV' in os.environ:
err("Be aware that this environment will be nested on top "
"of '%s'" % Path(os.environ['VIRTUAL_ENV']).name)
inve(env, *shellcmd, cwd=cwd)
try:
inve(env, *shellcmd, cwd=cwd)
except CalledProcessError:
# These shells report errors when the last command executed in the
# subshell in an error. This causes the subprocess to fail, which is
# not what we want. Stay silent for them, there's nothing we can do.
shell_name, _ = os.path.splitext(os.path.basename(shellcmd[0]))
suppress_error = shell_name.tolower() in ['cmd', 'powershell', 'pwsh']
if not suppress_error:
raise
def fork_bash(env, cwd):