def _strip_shell(cmd):
    """Strip a (potentially multi-line) command.

    For example

    $ foo \
    >     --bar baz \
    >     --quux 10

    would becomes `foo --bar baz --quux 10`.
    """
    parts = []
    for line in cmd.strip().split("\n"):
        without_console = line.lstrip("$> ").rstrip("\\ ")
        parts.append(without_console)
    return " ".join(parts)