Skip to content

Commit 65a561d

Browse files
committed
minimal support for subprocess execution on windows
1 parent 38c5b39 commit 65a561d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

graalpython/lib-python/3/subprocess.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,23 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
17051705
else:
17061706
args = list(args)
17071707

1708+
# Truffle change
1709+
if sys.platform == 'win32':
1710+
if executable is None and len(args) == 1:
1711+
import shlex
1712+
executable = next(shlex.shlex(list2cmdline(args)))
1713+
if executable.startswith('"') and executable.endswith('"'):
1714+
executable = executable[1:-1]
1715+
if (len(args) == 1 and executable != args[0]) or shell:
1716+
shell = False
1717+
comspec = os.environ.get("COMSPEC", "cmd.exe")
1718+
executable = comspec
1719+
if len(args) == 1:
1720+
args = [comspec, "/u", "/c", *args]
1721+
else:
1722+
args = [comspec, "/u", "/c", list2cmdline(args)]
1723+
# End Truffle change
1724+
17081725
if shell:
17091726
# On Android the default shell is at '/system/bin/sh'.
17101727
unix_shell = ('/system/bin/sh' if

0 commit comments

Comments
 (0)