author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Fri, 12 Apr 2019 02:21:09 +0200 | |
changeset 4520 | 36632d514af2 |
parent 3376 | aad37ffd7d58 |
permissions | -rw-r--r-- |
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))