Skip to content

Commit f07e2c1

Browse files
committed
Support pipe and redirect for a shell process
1 parent 1ea9072 commit f07e2c1

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

ptrlib/connection/unixproc.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def __init__(self,
5151
self._fd_r: int = -1
5252
self._fd_w: int = -1
5353
self._args: list[str]
54+
self._raw_args: str | list[str] = args
5455
self._pty_slave: int = -1
5556
self._pty_master: int = -1
5657
self._saved_termios: TcAttrT | None = None
@@ -431,9 +432,17 @@ def setup_tty():
431432
if is_raw:
432433
tty.setraw(self._pty_slave, when=termios.TCSANOW)
433434

435+
if self._shell:
436+
if isinstance(self._raw_args, str):
437+
popen_args = self._raw_args
438+
else:
439+
popen_args = " ".join(shlex.quote(arg) for arg in self._raw_args)
440+
else:
441+
popen_args = self._args
442+
434443
# pylint: disable-next=subprocess-popen-preexec-fn
435444
self._proc = subprocess.Popen(
436-
" ".join(shlex.quote(arg) for arg in self._args) if self._shell else self._args,
445+
popen_args,
437446
shell=self._shell,
438447
cwd=self._workdir,
439448
env=self._env,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name='ptrlib',
13-
version='3.0.1',
13+
version='3.0.2',
1414
description='CTF library',
1515
long_description=long_description,
1616
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)