diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-02-10 12:39:15 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2011-02-10 12:39:15 +0100 |
commit | 3dbb6590d3fab0ffb8ec7e66f0ecbe2701ce8d75 (patch) | |
tree | 516710779a129372e4dcf49eedf915948a5fb3db /src/common.py | |
parent | 538c843ec704fea18107f875aad0e14eebd1875e (diff) | |
download | poezio-3dbb6590d3fab0ffb8ec7e66f0ecbe2701ce8d75.tar.gz poezio-3dbb6590d3fab0ffb8ec7e66f0ecbe2701ce8d75.tar.bz2 poezio-3dbb6590d3fab0ffb8ec7e66f0ecbe2701ce8d75.tar.xz poezio-3dbb6590d3fab0ffb8ec7e66f0ecbe2701ce8d75.zip |
Make the shell split do a normal split if the syntax is wrong
Diffstat (limited to 'src/common.py')
-rw-r--r-- | src/common.py | 13 |
1 files changed, 13 insertions, 0 deletions
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() |