MCPcopy Create free account
hub / github.com/FastLED/FastLED / format_cmd_for_shell

Function format_cmd_for_shell

ci/util/windows_cmd_runner.py:125–146  ·  view source on GitHub ↗

Format command list for Windows CMD shell execution. Properly quotes arguments that contain spaces or special characters. Args: cmd: Command as list of strings Returns: Command string suitable for shell=True execution

(cmd: list[str])

Source from the content-addressed store, hash-verified

123
124
125def format_cmd_for_shell(cmd: list[str]) -> str:
126 """Format command list for Windows CMD shell execution.
127
128 Properly quotes arguments that contain spaces or special characters.
129
130 Args:
131 cmd: Command as list of strings
132
133 Returns:
134 Command string suitable for shell=True execution
135 """
136 quoted_parts: list[str] = []
137 for part in cmd:
138 # Quote if contains spaces or special characters
139 if " " in part or any(c in part for c in "&|<>^"):
140 # Escape quotes inside the part
141 escaped = part.replace('"', '\\"')
142 quoted_parts.append(f'"{escaped}"')
143 else:
144 quoted_parts.append(part)
145
146 return " ".join(quoted_parts)

Callers 2

create_pio_processFunction · 0.90
run_pio_commandFunction · 0.90

Calls 2

anyFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected