From fdcde7be8f6bde7b44b0a3c87be1d87a1dfe7de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergiusz=20Baza=C5=84ski?= Date: Wed, 2 May 2012 16:25:58 +0000 Subject: [PATCH] Use shlex for console parsing. --- mainframe/console.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mainframe/console.py b/mainframe/console.py index 88516d6..e642f4e 100644 --- a/mainframe/console.py +++ b/mainframe/console.py @@ -1,5 +1,6 @@ import logic import sys +import shlex actions = { "initialize": (logic.initialize, [], True), @@ -19,7 +20,7 @@ def start(): sys.stdout.write("> ") sys.stdout.flush() line = raw_input().strip() - command = line.split()[0] + command = shlex.split(line)[0] if command == "quit": break @@ -42,7 +43,7 @@ def start(): print "[e] Make up your mind." continue - given_arguments = line.split()[1:] + given_arguments = shlex.split(line)[1:] if len(given_arguments) != len(arguments): print "[e] Syntax: %s %s" % (command, " ".join([argument[0] for argument in arguments])) continue