docs/tutorial/testlib/arguments_printer.py
changeset 3376 aad37ffd7d58
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/tutorial/testlib/arguments_printer.py	Mon Jan 08 11:46:53 2018 +0100
@@ -0,0 +1,22 @@
+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))