docs/tutorial/testlib/arguments_printer.py
author Martin von Zweigbergk <martinvonz@google.com>
Wed, 18 Apr 2018 22:36:54 -0700
changeset 3677 60d396d3da80
parent 3376 aad37ffd7d58
permissions -rw-r--r--
obsexchange: remove unused import of wireprotoserver This seems to be unused since 300d7d019b9.

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))