~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/win32utils.py

  • Committer: Gordon Tyler
  • Date: 2009-12-22 19:13:59 UTC
  • mto: (5037.3.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5046.
  • Revision ID: gordon@doxxx.net-20091222191359-cbnne2l1bjbja82p
Changed shlex_split_unicode to prevent wildcard expansion in the win32 codepath.

Show diffs side-by-side

added added

removed removed

Lines of Context:
614
614
        return quoted, token
615
615
 
616
616
 
617
 
def command_line_to_argv(command_line):
618
 
    """Convert a Unicode command line into a set of argv arguments.
619
 
 
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
622
 
    Windows.
 
617
def command_line_to_argv(command_line, wildcard_expansion=True):
 
618
    """Convert a Unicode command line into a list of argv arguments.
 
619
 
 
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.
 
623
 
 
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.
623
628
    """
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
628
633
    args = []
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:
631
636
            args.append(arg)
632
637
        else:
633
638
            args.extend(glob_one(arg))