From 3dbb6590d3fab0ffb8ec7e66f0ecbe2701ce8d75 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 10 Feb 2011 12:39:15 +0100 Subject: Make the shell split do a normal split if the syntax is wrong --- src/common.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/common.py') diff --git a/src/common.py b/src/common.py index 141b67be..f910892d 100644 --- a/src/common.py +++ b/src/common.py @@ -41,6 +41,7 @@ import subprocess import curses import sys import time +import shlex ROOM_STATE_NONE = 11 ROOM_STATE_CURRENT = 10 @@ -192,3 +193,15 @@ def datetime_tuple(timestamp): dst = timedelta(seconds=time.altzone) ret -= dst return ret + +def shell_split(string): + sh = shlex.shlex(string, posix=True) + ret = list() + try: + w = sh.get_token() + while w: + ret.append(w) + w = sh.get_token() + return ret + except ValueError: + return string.split() -- cgit v1.2.3