From 217777f60e491fd957bbedf451924f5c7c6f1186 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 12 Nov 2021 02:44:46 +0100 Subject: [PATCH] Remove sh -euc from output --- shlax/subprocess.py | 13 ++++++++----- tests/test_proc.py | 8 ++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/shlax/subprocess.py b/shlax/subprocess.py index 7267a38..f51fbd4 100644 --- a/shlax/subprocess.py +++ b/shlax/subprocess.py @@ -52,9 +52,6 @@ class Subprocess: write=None, flush=None, ): - if len(args) == 1 and ' ' in args[0]: - args = ['sh', '-euc', args[0]] - self.args = args self.quiet = quiet if quiet is not None else False self.prefix = prefix @@ -79,7 +76,7 @@ class Subprocess: self.output( self.colors.bgray.encode() + b'+ ' - + shlex.join([ + + ' '.join([ arg.replace('\n', '\\n') for arg in self.args ]).encode() @@ -93,13 +90,19 @@ class Subprocess: self.exit_future = asyncio.Future(loop=loop) + if len(self.args) == 1 and ' ' in self.args[0]: + args = ['sh', '-euc', self.args[0]] + else: + args = self.args + # Create the subprocess controlled by DateProtocol; # redirect the standard output into a pipe. self.transport, self.protocol = await loop.subprocess_exec( lambda: SubprocessProtocol(self), - *self.args, + *args, stdin=None, ) + self.started = True async def wait(self, *args, **kwargs): diff --git a/tests/test_proc.py b/tests/test_proc.py index 568bf21..0042d97 100644 --- a/tests/test_proc.py +++ b/tests/test_proc.py @@ -74,7 +74,7 @@ async def test_prefix(): + Proc.colors.reset.encode() + b'| ' + Proc.colors.bgray.encode() - + b'+ sh -euc \'echo hi\'' + + b'+ echo hi' + Proc.colors.reset.encode() + b'\n' ), @@ -92,7 +92,7 @@ async def test_prefix(): + Proc.colors.reset.encode() + b'| ' + Proc.colors.bgray.encode() - + b'+ sh -euc \'echo hi\'' + + b'+ echo hi' + Proc.colors.reset.encode() + b'\n' ), @@ -112,7 +112,7 @@ async def test_prefix(): + Proc.colors.reset.encode() + b'| ' + Proc.colors.bgray.encode() - + b'+ sh -euc \'echo hi\'' + + b'+ echo hi' + Proc.colors.reset.encode() + b'\n' ), @@ -143,7 +143,7 @@ async def test_prefix_multiline(): + Proc.colors.reset.encode() + b'| ' + Proc.colors.bgray.encode() - + b'+ sh -euc \'echo -e "a\\nb"\'' + + b'+ echo -e "a\\nb"' + Proc.colors.reset.encode() + b'\n' ),