docs/tutorial/testlib/arguments_printer.py
author Rodrigo Damazio Bovendorp <rdamazio@google.com>
Fri, 27 Dec 2019 20:38:10 -0800
changeset 5251 353e546ab324
parent 3376 aad37ffd7d58
permissions -rw-r--r--
obslog: add flags to control the output of precursors and successors With just this change, precursors are only shown in structured output.

import sys

formatted_args = []

UNSAFE_CHARACTERS = [" ", "!", "\"", "#", "$", "&", "'", "(", ")", "*", ",", ";", "<", ">", "?", "[", "\\", "]", "^", "`", "{", "|", "}", ":", "~", "/"]


def find_unsafe(arg):
    for unsafe in UNSAFE_CHARACTERS:
        if unsafe in arg:
            return True

    return False


for arg in sys.argv[1:]:
    if find_unsafe(arg):
        formatted_args.append('"%s"' % arg)
    else:
        formatted_args.append(arg)

print("$ " + " ".join(formatted_args))