import pipes


def run_cmd(call, cmd, *, echo=True, **kwargs):
    """Run a command and echo it first"""
    if echo:
        print("$> " + " ".join(map(pipes.quote, cmd)))
    return call(cmd, **kwargs)