Dedent cmd
This commit is contained in:
parent
7e9af1fe35
commit
0408590c4f
@ -1,3 +1,5 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
from .script import Script
|
from .script import Script
|
||||||
|
|
||||||
|
|
||||||
@ -31,10 +33,17 @@ class BuildScript(Script):
|
|||||||
|
|
||||||
def _run(self, cmd, inject=False):
|
def _run(self, cmd, inject=False):
|
||||||
user = self.container.variable('username')
|
user = self.container.variable('username')
|
||||||
_cmd = cmd
|
_cmd = textwrap.dedent(cmd)
|
||||||
if cmd.startswith('sudo '):
|
if cmd.startswith('sudo '):
|
||||||
_cmd = _cmd[5:]
|
_cmd = _cmd[5:]
|
||||||
|
|
||||||
|
heredoc = False
|
||||||
|
for i in ('\n', '>', '<', '|', '&'):
|
||||||
|
if i in _cmd:
|
||||||
|
heredoc = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if heredoc:
|
||||||
_cmd = ' '.join(['bash -eux <<__EOF\n', _cmd.strip(), '\n__EOF'])
|
_cmd = ' '.join(['bash -eux <<__EOF\n', _cmd.strip(), '\n__EOF'])
|
||||||
|
|
||||||
if cmd.startswith('sudo '):
|
if cmd.startswith('sudo '):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user