Escape & on Windows in shell using ^& in run_subprocess

This commit is contained in:
Roy Nieterau 2025-02-04 15:07:05 +01:00
parent f6c80f9ae3
commit 516dd2d7ce

View file

@ -122,6 +122,16 @@ def run_subprocess(*args, **kwargs):
)
args = (new_arg, )
# Escape & on Windows in shell using ^&
if (
kwargs.get("shell") is True
and len(args) == 1
and isinstance(args[0], str)
and platform.system().lower() == "windows"
):
new_arg = args[0].replace("&", "^&")
args = (new_arg, )
# Get environents from kwarg or use current process environments if were
# not passed.
env = kwargs.get("env") or os.environ