MCPcopy Index your code
hub / github.com/bugy/script-server / split_command

Function split_command

src/utils/process_utils.py:46–69  ·  view source on GitHub ↗
(script_command, working_directory=None)

Source from the content-addressed store, hash-verified

44
45
46def split_command(script_command, working_directory=None):
47 if ' ' in script_command:
48 if _is_file_path(script_command, working_directory):
49 args = [script_command]
50 else:
51 posix = not os_utils.is_win()
52 args = shlex.split(script_command, posix=posix)
53
54 if not posix:
55 args = [string_utils.unwrap_quotes(arg) for arg in args]
56 else:
57 args = [script_command]
58
59 script_path = file_utils.normalize_path(args[0], working_directory)
60 if (not os.path.isabs(script_path)) or (not os.path.exists(script_path)):
61 script_path = args[0]
62
63 script_args = args[1:]
64 for i, body_arg in enumerate(script_args):
65 expanded = os.path.expanduser(body_arg)
66 if expanded != body_arg:
67 script_args[i] = expanded
68
69 return [script_path] + script_args
70
71
72def _is_file_path(script_command_with_whitespaces, working_directory):

Callers 1

invokeMethod · 0.85

Calls 1

_is_file_pathFunction · 0.85

Tested by

no test coverage detected