2 from __future__ import absolute_import
6 from bup import shquote
7 from buptest import no_lingering_errors
11 return [word for offset,word in shquote.quotesplit(line)]
15 with no_lingering_errors():
16 WVPASSEQ(qst(""" this is basic \t\n\r text """),
17 ['this', 'is', 'basic', 'text'])
18 WVPASSEQ(qst(r""" \"x\" "help" 'yelp' """), ['"x"', 'help', 'yelp'])
19 WVPASSEQ(qst(r""" "'\"\"'" '\"\'' """), ["'\"\"'", '\\"\''])
21 WVPASSEQ(shquote.quotesplit(' this is "unfinished'),
22 [(2,'this'), (7,'is'), (10,'unfinished')])
24 WVPASSEQ(shquote.quotesplit('"silly"\'will'),
25 [(0,'silly'), (7,'will')])
27 WVPASSEQ(shquote.unfinished_word('this is a "billy" "goat'),
29 WVPASSEQ(shquote.unfinished_word("'x"),
31 WVPASSEQ(shquote.unfinished_word("abra cadabra "),
33 WVPASSEQ(shquote.unfinished_word("abra cadabra"),
36 (qtype, word) = shquote.unfinished_word("this is /usr/loc")
37 WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
39 (qtype, word) = shquote.unfinished_word("this is '/usr/loc")
40 WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
42 (qtype, word) = shquote.unfinished_word("this is \"/usr/loc")
43 WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
45 (qtype, word) = shquote.unfinished_word("this is \"/usr/loc")
46 WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", False),
48 (qtype, word) = shquote.unfinished_word("this is \\ hammer\\ \"")
49 WVPASSEQ(word, ' hammer "')
50 WVPASSEQ(shquote.what_to_add(qtype, word, " hammer \"time\"", True),
53 WVPASSEQ(shquote.quotify_list(['a', '', '"word"', "'third'", "'", "x y"]),
54 "a '' '\"word\"' \"'third'\" \"'\" 'x y'")