def safe_split_line(inputline):
parser = shlex.shlex(inputline, posix=True)
parser.whitespace_split = True
res = []
# track whether or not we're looking at quoted text -- it should suppress a
# lot of types of completion if we see an open quote without a close quote
quoted = False
try:
for val in parser:
res.append(val)
# No closing quotation
except ValueError:
quoted = True
# grab the last token from the shlexer
if parser.token:
res.append(parser.token)
return res, quoted
评论列表
文章目录