Commit 691ce88b authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

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
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -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