536
536
:return: A list of unicode strings.
538
# First, spit the command line
538
539
s = cmdline.Splitter(command_line, single_quotes_allowed=single_quotes_allowed)
539
# Now that we've split the content, expand globs if necessary
541
# Bug #587868 Now make sure that the length of s agrees with sys.argv
542
# we do this by simply counting the number of arguments in each. The counts should
543
# agree no matter what encoding sys.argv is in (AFAIK)
544
# len(arguments) < len(sys.argv) should be an impossibility since python gets
545
# args from the very same PEB as does GetCommandLineW
548
# Bug #588277 remove the --profile-imports from the command line arguments
549
# as is also done in the main bzr module
550
if '--profile-imports' not in sys.argv:
551
if (False, '--profile-imports') in arguments:
552
arguments.remove((False, '--profile-imports'))
553
elif (True, '--profile-imports') in arguments:
554
arguments.remove((True, '--profile-imports'))
556
# Now shorten the command line we get from GetCommandLineW to match sys.argv
557
if len(arguments) < len(sys.argv):
558
from bzrlib.errors import InternalBzrError
559
raise InternalBzrError("len(GetCommandLineW(...)) < len(sys.argv) should not be possible")
560
arguments = arguments[len(arguments) - len(sys.argv):]
562
# Carry on to process globs (metachars) in the command line
563
# expand globs if necessary
540
564
# TODO: Use 'globbing' instead of 'glob.glob', this gives us stuff like
541
565
# '**/' style globs
543
for is_quoted, arg in s:
567
for is_quoted, arg in arguments:
544
568
if is_quoted or not glob.has_magic(arg):
547
args.extend(glob_one(arg))
571
argv.extend(glob_one(arg))
551
575
if has_ctypes and winver != 'Windows 98':
558
582
raise ctypes.WinError()
559
583
# Skip the first argument, since we only care about parameters
560
584
argv = _command_line_to_argv(command_line)[1:]
561
if getattr(sys, 'frozen', None) is None:
562
# Invoked via 'python.exe' which takes the form:
563
# python.exe [PYTHON_OPTIONS] C:\Path\bzr [BZR_OPTIONS]
564
# we need to get only BZR_OPTIONS part,
565
# We already removed 'python.exe' so we remove everything up to and
566
# including the first non-option ('-') argument.
567
for idx in xrange(len(argv)):
568
if argv[idx][:1] != '-':
573
587
get_unicode_argv = None