614
614
return quoted, token
617
def command_line_to_argv(command_line):
618
"""Convert a Unicode command line into a set of argv arguments.
620
This does wildcard expansion, etc. It is intended to make wildcards act
621
closer to how they work in posix shells, versus how they work by default on
617
def command_line_to_argv(command_line, wildcard_expansion=True):
618
"""Convert a Unicode command line into a list of argv arguments.
620
This optionally does wildcard expansion, etc. It is intended to make
621
wildcards act closer to how they work in posix shells, versus how they
622
work by default on Windows. Quoted arguments are left untouched.
624
:param command_line: The unicode string to split into an arg list.
625
:param wildcard_expansion: Whether wildcard expansion should be applied to
626
each argument. True by default.
627
:return: A list of unicode strings.
624
629
s = UnicodeShlex(command_line)
625
# Now that we've split the content, expand globs
630
# Now that we've split the content, expand globs if necessary
626
631
# TODO: Use 'globbing' instead of 'glob.glob', this gives us stuff like
627
632
# '**/' style globs
629
634
for is_quoted, arg in s:
630
if is_quoted or not glob.has_magic(arg):
635
if is_quoted or not glob.has_magic(arg) or not wildcard_expansion:
633
638
args.extend(glob_one(arg))