author | Anton Shestakov <av6@dwimlabs.net> |
Wed, 24 Apr 2019 15:57:49 +0200 | |
changeset 4575 | 903e8b983fac |
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))