Commit 691ce88b authored by Chris Lamb's avatar Chris Lamb 💬

When formatting command lines for display (eg. as sources of data) ensure...

When formatting command lines for display (eg. as sources of data) ensure newlines and other metacharacters appear escaped as "\n", etc.
parent b8236d4a
......@@ -67,12 +67,15 @@ class Command(metaclass=abc.ABCMeta):
raise NotImplementedError()
def shell_cmdline(self):
return ' '.join(
map(
lambda x: '{}' if x == self.path else shlex.quote(x),
self.cmdline(),
)
)
def fn(x):
if x == self.path:
return '{}'
x = repr(x)
if ' ' not in x:
x = x[1:-1]
return x
return ' '.join(fn(x) for x in self.cmdline())
def env(self):
return None # inherit parent environment by default
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment