docs/tutorial/testlib/arguments_printer.py
author Joerg Sonnenberger <joerg@bec.de>
Tue, 05 May 2020 20:25:33 +0200
changeset 5335 3847dedd12d7
parent 3376 aad37ffd7d58
permissions -rw-r--r--
changelog: adjust The changes only apply to newly created sqlite database. There are code pathes that drop existing ones, but that's a more complicated condition.

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