summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-08-16 16:21:54 +0200
committermathieui <mathieui@mathieui.net>2013-08-16 16:21:54 +0200
commit1a92c51ddf6c3a3064d0a3d8cf80eb97a34aad74 (patch)
tree15acaafb1df2817fd5a3a1b84a638261426a050c
parent7820f985682947da3bc2cc427c5193fe9a56acdb (diff)
downloadpoezio-1a92c51ddf6c3a3064d0a3d8cf80eb97a34aad74.tar.gz
poezio-1a92c51ddf6c3a3064d0a3d8cf80eb97a34aad74.tar.bz2
poezio-1a92c51ddf6c3a3064d0a3d8cf80eb97a34aad74.tar.xz
poezio-1a92c51ddf6c3a3064d0a3d8cf80eb97a34aad74.zip
Fix an issue with shlex
(well, sort of fix)
-rw-r--r--src/common.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common.py b/src/common.py
index 88c3d0ea..81f7b61a 100644
--- a/src/common.py
+++ b/src/common.py
@@ -238,12 +238,16 @@ def shell_split(st):
['toto', '']
>>> shell_split('"toto titi" toto ""')
['toto titi', 'toto', '']
+ >>> shell_split('toto "titi')
+ ['toto', 'titi']
"""
sh = shlex.shlex(st)
ret = []
w = sh.get_token()
while w and w[2] is not None:
ret.append(w[2])
+ if w[1] == len(st):
+ return ret
w = sh.get_token()
return ret
@@ -277,6 +281,8 @@ def find_argument_quoted(pos, text):
1
>>> find_argument_quoted(8, '"toto" "titi tata')
1
+ >>> find_argument_quoted(3, '"toto" "titi tata')
+ 0
>>> find_argument_quoted(18, '"toto" "titi tata" ')
2
"""