惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Archives - TechRepublic
Security Archives - TechRepublic
罗磊的独立博客
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
Apple Machine Learning Research
Apple Machine Learning Research
The Register - Security
The Register - Security
J
Java Code Geeks
V2EX - 技术
V2EX - 技术
Vercel News
Vercel News
N
News and Events Feed by Topic
腾讯CDC
P
Proofpoint News Feed
N
News | PayPal Newsroom
www.infosecurity-magazine.com
www.infosecurity-magazine.com
爱范儿
爱范儿
O
OpenAI News
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
Martin Fowler
Martin Fowler
Engineering at Meta
Engineering at Meta
D
Docker
Y
Y Combinator Blog
博客园 - 聂微东
G
Google Developers Blog
S
Security @ Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
S
Schneier on Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
SegmentFault 最新的问题
云风的 BLOG
云风的 BLOG
阮一峰的网络日志
阮一峰的网络日志
C
CXSECURITY Database RSS Feed - CXSecurity.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
CERT Recently Published Vulnerability Notes
I
Intezer
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Attack and Defense Labs
Attack and Defense Labs
V
Visual Studio Blog
博客园 - Franky
博客园 - 三生石上(FineUI控件)
W
WeLiveSecurity
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hugging Face - Blog
Hugging Face - Blog
Scott Helme
Scott Helme
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
L
LINUX DO - 最新话题
C
Cybersecurity and Infrastructure Security Agency CISA

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4 test: trim doctor command hotspots · openclaw/openclaw@c66f16a test: isolate agent auth and spawn hotspots · openclaw/openclaw@9285935 test: stabilize MCP startup disposal race · openclaw/openclaw@dd9d2eb test: merge browser contract server suites · openclaw/openclaw@5817a76 test: narrow ollama provider discovery setup · openclaw/openclaw@a0d9598 build: declare qa-lab aimock runtime dependency · openclaw/openclaw@24431e5 test: speed up safe-bins exec harness · openclaw/openclaw@ee856ab test: preserve tool helpers in embedded runner mocks · openclaw/openclaw@acd86a0 refactor: move memory embeddings into provider plugins · openclaw/openclaw@77e6e4c test: reuse system-run temp fixtures · openclaw/openclaw@7e9ff0f test: trim hotspot wait overhead · openclaw/openclaw@12a59b0 Check: avoid duplicate boundary prep · openclaw/openclaw@baf11b8 test: reduce hotspot fixture overhead · openclaw/openclaw@3a59edd feat(ui): overhaul settings and slash command UX (#67819) thanks @Bun… · openclaw/openclaw@2cfb660 QA Matrix: exit cleanly on failure · openclaw/openclaw@42805d2 QA Matrix: isolate scenario coverage · openclaw/openclaw@7e659e1 Matrix: refresh crypto bootstrap state · openclaw/openclaw@94081d8 QA Lab: add provider registry · openclaw/openclaw@bb7e982 Matrix: add plugin changelog · openclaw/openclaw@4acab55 test: trim more hotspot overhead · openclaw/openclaw@f485311 test: trim remaining hotspot tests · openclaw/openclaw@6ba8626 test: narrow hotspot mocks · openclaw/openclaw@dbc8179 test: isolate gemini embedding request helpers · openclaw/openclaw@cd330f5 test: trim memory and mcp hotspots · openclaw/openclaw@fd48dfa test: slim provider registry mocks · openclaw/openclaw@2e08c77 test: harden Parallels update smoke · openclaw/openclaw@1a98090 feat: default Anthropic to Opus 4.7 · openclaw/openclaw@628b454 fix: harden node-host shell payload mutability checks · openclaw/openclaw@75c551e fix: land node-host approval binding for native binaries (#66731) (th… · openclaw/openclaw@29919bb CI: add daily schedule to CodeQL workflow (#67645) · openclaw/openclaw@69d25f5 fix(gateway): capture config hash after plugin auto-enable to prevent… · openclaw/openclaw@8c11210 fix: repair sanitized replay tool results before send (#67620) (thank… · openclaw/openclaw@c3c7a99 fix: restrict HTML timeout short-circuit to transient statuses · openclaw/openclaw@de129a6 fix: keep TUI watchdog bound to active run (#67401) (thanks @xantorres) · openclaw/openclaw@3525273 Gateway/skills: dedupe skills prefix-match + drop dead fallback on log · openclaw/openclaw@d7f489f Extensions/lmstudio: back off inference preload after consecutive fai… · openclaw/openclaw@b555214 TUI/streaming: add watchdog that resets the activity indicator after … · openclaw/openclaw@f44ab20 Agents/tool-loop: enable unknown-tool stream guard by default · openclaw/openclaw@36ed367 Gateway/skills: invalidate session skills snapshot on config write · openclaw/openclaw@b23d59a fix: classify HTML provider error pages correctly (#67642) (thanks @s… · openclaw/openclaw@e588e90 fix(skills): remove unused model-usage import (#67641) · openclaw/openclaw@55f05df docs(changelog): credit codex fix superseded PRs · openclaw/openclaw@e485f24 fix(openai-codex): normalize stale transport metadata in resolution a… · openclaw/openclaw@90801ba CI: pin Docker-related GitHub Actions (#67632) · openclaw/openclaw@f697b01 Android: modernize WebView and discovery API usage (#67627) · openclaw/openclaw@44a6e50 fix(deps): bump hono to 4.12.14 and @hono/node-server to 1.19.14 (GHS… · openclaw/openclaw@fbccc18 fix(deps): bump dompurify to 3.4.0 (#67614) · openclaw/openclaw@2c2dc00 CI: add explicit permissions to all workflow jobs (fixes code-scannin… · openclaw/openclaw@01b7516 fix: register bundled TTS providers and route overrides correctly (#6… · openclaw/openclaw@6ea3cdd fix: align host tilde paths with OS home (#62804) (thanks @stainlu) · openclaw/openclaw@ecfaf64 fix: flush creds queue before reconnect socket open (#67464) (thanks … · openclaw/openclaw@405c63f fix: strip standalone <function> tool call tags from visible text (#6… · openclaw/openclaw@78df859 fix(agents): preserve cli session metadata before transcript persist … · openclaw/openclaw@898fd04 docs(changelog): move cli transcript entry · openclaw/openclaw@c1817c6 fix(agents): normalize cli transcript api field · openclaw/openclaw@3a3fae0 docs(changelog): note cli transcript persistence · openclaw/openclaw@6c343f1 fix(agents): persist cli transcript turns · openclaw/openclaw@b8ef507 fix(msteams): harden security-sensitive flows (#65841) · openclaw/openclaw@c56b56e [Dashboard] Fix exec approval modal overflow for long command content… · openclaw/openclaw@053c5b0 Docs: remove QA changelog entry · openclaw/openclaw@7fd5771 QA: fix private runtime source loading (#67428) · openclaw/openclaw@d5933af docs(gateway): correct protocol.md schema path, hello-ok example, aut… · openclaw/openclaw@489404d CI: pin Node 22 runners to 22.18.0 · openclaw/openclaw@4ffa621 models.authStatus: normalize provider ids + tighten env-backed escape… · openclaw/openclaw@f2fdb9d Update CHANGELOG.md · openclaw/openclaw@7694a92 test(parallels): clean up npm update guard jobs · openclaw/openclaw@045ea7b Plugins: prefer scanDir override paths · openclaw/openclaw@b2974da fix(dreaming): default storage.mode to "separate" so phase blocks sto… · openclaw/openclaw@8c392f0 fix(memory-core): skip dreaming transcript ingestion via session stor… · openclaw/openclaw@a1b01f0 fix: dedupe replayed exec.finished node events (#67281) · openclaw/openclaw@5dcf526
fix(process): wrap Windows command shims · openclaw/openclaw@2248aa4
vincentkoc · 2026-06-20 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -11,50 +11,18 @@ import {

1111

decodeWindowsOutputBuffer,

1212

resolveWindowsConsoleEncoding,

1313

} from "../infra/windows-encoding.js";

14-

import { getWindowsInstallRoots } from "../infra/windows-install-roots.js";

1514

import { logDebug, logError } from "../logger.js";

1615

import { killProcessTree as terminateProcessTree } from "./kill-tree.js";

1716

import { resolveCommandStdio } from "./spawn-utils.js";

18-

import { resolveWindowsCommandShim } from "./windows-command.js";

17+

import {

18+

buildWindowsCmdExeCommandLine,

19+

isWindowsBatchCommand,

20+

resolveTrustedWindowsCmdExe,

21+

resolveWindowsCommandShim,

22+

} from "./windows-command.js";

1923
2024

const execFileAsync = promisify(execFile);

2125
22-

const WINDOWS_UNSAFE_CMD_CHARS_RE = /[&|<>^%\r\n]/;

23-
24-

function isWindowsBatchCommand(resolvedCommand: string): boolean {

25-

if (process.platform !== "win32") {

26-

return false;

27-

}

28-

const ext = normalizeLowercaseStringOrEmpty(path.extname(resolvedCommand));

29-

return ext === ".cmd" || ext === ".bat";

30-

}

31-
32-

function escapeForCmdExe(arg: string): string {

33-

// Reject cmd metacharacters to avoid injection when we must pass a single command line.

34-

if (WINDOWS_UNSAFE_CMD_CHARS_RE.test(arg)) {

35-

throw new Error(

36-

`Unsafe Windows cmd.exe argument detected: ${JSON.stringify(arg)}. ` +

37-

"Pass an explicit shell-wrapper argv at the call site instead.",

38-

);

39-

}

40-

// Quote when needed; double inner quotes for cmd parsing.

41-

if (!arg.includes(" ") && !arg.includes('"')) {

42-

return arg;

43-

}

44-

return `"${arg.replace(/"/g, '""')}"`;

45-

}

46-
47-

function buildCmdExeCommandLine(resolvedCommand: string, args: string[]): string {

48-

return [escapeForCmdExe(resolvedCommand), ...args.map(escapeForCmdExe)].join(" ");

49-

}

50-
51-

function resolveTrustedWindowsCmdExe(): string {

52-

if (process.platform !== "win32") {

53-

return "cmd.exe";

54-

}

55-

return path.win32.join(getWindowsInstallRoots().systemRoot, "System32", "cmd.exe");

56-

}

57-
5826

function assignChildEnvValue(params: {

5927

env: NodeJS.ProcessEnv;

6028

key: string;

@@ -154,7 +122,7 @@ function resolveChildProcessInvocation(params: {

154122

return {

155123

command: useCmdWrapper ? resolveTrustedWindowsCmdExe() : resolvedCommand,

156124

args: useCmdWrapper

157-

? ["/d", "/s", "/c", buildCmdExeCommandLine(resolvedCommand, finalArgv.slice(1))]

125+

? ["/d", "/s", "/c", buildWindowsCmdExeCommandLine(resolvedCommand, finalArgv.slice(1))]

158126

: finalArgv.slice(1),

159127

usesWindowsExitCodeShim:

160128

process.platform === "win32" && (useCmdWrapper || finalArgv !== params.argv),

@@ -460,11 +428,7 @@ export async function runCommandWithTimeout(

460428

} else {

461429

killIssuedByAbort = true;

462430

}

463-

if (

464-

killProcessTree &&

465-

typeof child.pid === "number" &&

466-

child.pid > 0

467-

) {

431+

if (killProcessTree && typeof child.pid === "number" && child.pid > 0) {

468432

if (process.platform === "win32") {

469433

try {

470434

spawn("taskkill", ["/PID", String(child.pid), "/T"], {

Original file line numberDiff line numberDiff line change

@@ -295,6 +295,24 @@ describe("windows command wrapper behavior", () => {

295295

});

296296

});

297297
298+

it("escapes caret arguments in Windows command wrappers", async () => {

299+

spawnMock.mockImplementation(

300+

(_command: string, _args: string[], _options: Record<string, unknown>) => createMockChild(),

301+

);

302+
303+

await withMockedWindowsPlatform(async () => {

304+

const result = await runCommandWithTimeout(

305+

["pnpm", "exec", "vitest", "-t", "@scope/pkg@^1.2.3"],

306+

{ timeoutMs: 1000 },

307+

);

308+

expect(result.code).toBe(0);

309+

const captured = requireSpawnCall(0);

310+

expect(captured[1].slice(0, 3)).toEqual(["/d", "/s", "/c"]);

311+

expect(captured[1][3]).toBe("pnpm.cmd exec vitest -t @scope/pkg@^^1.2.3");

312+

expect(captured[2].windowsVerbatimArguments).toBe(true);

313+

});

314+

});

315+
298316

it("keeps child exitCode when close reports null on Windows npm shims", async () => {

299317

const child = createMockChild({ closeCode: null, exitCode: 0 });

300318

@@ -397,6 +415,35 @@ describe("windows command wrapper behavior", () => {

397415

});

398416

});

399417
418+

it("wraps spaced .cmd command paths in an outer cmd.exe command line", async () => {

419+

const expectedComSpec = expectedTrustedCmdExe();

420+
421+

execFileMock.mockImplementation(

422+

(

423+

_command: string,

424+

_args: string[],

425+

_options: Record<string, unknown>,

426+

cb: (err: Error | null, stdout: string, stderr: string) => void,

427+

) => {

428+

cb(null, "ok", "");

429+

},

430+

);

431+
432+

await withMockedWindowsPlatform(async () => {

433+

await runExec("C:\\Program Files\\pnpm\\pnpm.cmd", ["--version"], 1000);

434+

const captured = requireExecFileCall(0);

435+

expect(captured[0]).toBe(expectedComSpec);

436+

expect(captured[1]).toEqual([

437+

"/d",

438+

"/s",

439+

"/c",

440+

'""C:\\Program Files\\pnpm\\pnpm.cmd" --version"',

441+

]);

442+

expect(captured[2].windowsHide).toBe(true);

443+

expect(captured[2].windowsVerbatimArguments).toBe(true);

444+

});

445+

});

446+
400447

it("sets windowsHide on direct runExec invocations too", async () => {

401448

execFileMock.mockImplementation(

402449

(

Original file line numberDiff line numberDiff line change

@@ -1,8 +1,13 @@

11

// Child adapter tests cover adapting child processes to supervisor runs.

22

import type { ChildProcess } from "node:child_process";

33

import { EventEmitter } from "node:events";

4+

import path from "node:path";

45

import { PassThrough } from "node:stream";

56

import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

7+

import {

8+

getWindowsInstallRoots,

9+

resetWindowsInstallRootsForTests,

10+

} from "../../../infra/windows-install-roots.js";

611

import {

712

expectRealExitWinsOverSigkillFallback,

813

expectWaitStaysPendingUntilSigkillFallback,

@@ -83,6 +88,8 @@ type SpawnWithFallbackParams = {

8388

detached?: boolean;

8489

env?: NodeJS.ProcessEnv | Record<string, string>;

8590

stdio?: string[];

91+

windowsHide?: boolean;

92+

windowsVerbatimArguments?: boolean;

8693

};

8794

fallbacks?: Array<{ options?: { detached?: boolean } }>;

8895

};

@@ -107,6 +114,10 @@ function firstMockArg(mock: { mock: { calls: readonly unknown[][] } }, label: st

107114

return call[0];

108115

}

109116
117+

function expectedTrustedCmdExe(): string {

118+

return path.win32.join(getWindowsInstallRoots().systemRoot, "System32", "cmd.exe");

119+

}

120+
110121

describe("createChildAdapter", () => {

111122

const originalServiceMarker = process.env.OPENCLAW_SERVICE_MARKER;

112123

const originalPlatformDescriptor = Object.getOwnPropertyDescriptor(process, "platform");

@@ -123,6 +134,7 @@ describe("createChildAdapter", () => {

123134

});

124135
125136

beforeEach(() => {

137+

resetWindowsInstallRootsForTests({ queryRegistryValue: () => null });

126138

spawnWithFallbackMock.mockClear();

127139

signalProcessTreeMock.mockClear();

128140

createWindowsOutputDecoderMock.mockClear();

@@ -390,6 +402,28 @@ describe("createChildAdapter", () => {

390402

expect(spawnArgs.options?.env).toBeUndefined();

391403

});

392404
405+

it("wraps Windows command shims through trusted cmd.exe", async () => {

406+

setPlatform("win32");

407+
408+

await createAdapterHarness({

409+

pid: 3335,

410+

argv: ["pnpm", "--version"],

411+

});

412+
413+

const spawnArgs = firstSpawnWithFallbackParams();

414+

expect(spawnArgs.argv).toEqual([

415+

expectedTrustedCmdExe(),

416+

"/d",

417+

"/s",

418+

"/c",

419+

"pnpm.cmd --version",

420+

]);

421+

expect(spawnArgs.options?.detached).toBe(false);

422+

expect(spawnArgs.options?.windowsHide).toBe(true);

423+

expect(spawnArgs.options?.windowsVerbatimArguments).toBe(true);

424+

expect(spawnArgs.fallbacks).toStrictEqual([]);

425+

});

426+
393427

it("wraps Linux child spawns and strips shell-init env", async () => {

394428

const originalBashEnv = process.env.BASH_ENV;

395429

const originalEnv = process.env.ENV;

Original file line numberDiff line numberDiff line change

@@ -4,7 +4,12 @@ import { createWindowsOutputDecoder } from "../../../infra/windows-encoding.js";

44

import { signalProcessTree } from "../../kill-tree.js";

55

import { prepareOomScoreAdjustedSpawn } from "../../linux-oom-score.js";

66

import { spawnWithFallback } from "../../spawn-utils.js";

7-

import { resolveWindowsCommandShim } from "../../windows-command.js";

7+

import {

8+

buildWindowsCmdExeCommandLine,

9+

isWindowsBatchCommand,

10+

resolveTrustedWindowsCmdExe,

11+

resolveWindowsCommandShim,

12+

} from "../../windows-command.js";

813

import type { ManagedRunStdin, SpawnProcessAdapter } from "../types.js";

914

import { toStringEnv } from "./env.js";

1015

@@ -18,6 +23,27 @@ function resolveCommand(command: string): string {

1823

});

1924

}

2025
26+

function resolveChildInvocation(params: { argv: string[]; windowsVerbatimArguments?: boolean }): {

27+

args: string[];

28+

command: string;

29+

windowsVerbatimArguments?: boolean;

30+

} {

31+

const resolvedCommand = resolveCommand(params.argv[0] ?? "");

32+

const args = params.argv.slice(1);

33+

if (!isWindowsBatchCommand(resolvedCommand)) {

34+

return {

35+

command: resolvedCommand,

36+

args,

37+

windowsVerbatimArguments: params.windowsVerbatimArguments,

38+

};

39+

}

40+

return {

41+

command: resolveTrustedWindowsCmdExe(),

42+

args: ["/d", "/s", "/c", buildWindowsCmdExeCommandLine(resolvedCommand, args)],

43+

windowsVerbatimArguments: true,

44+

};

45+

}

46+
2147

export type ChildAdapter = SpawnProcessAdapter<NodeJS.Signals | null>;

2248
2349

function isServiceManagedRuntime(): boolean {

@@ -32,10 +58,12 @@ export async function createChildAdapter(params: {

3258

input?: string;

3359

stdinMode?: "inherit" | "pipe-open" | "pipe-closed";

3460

}): Promise<ChildAdapter> {

35-

const resolvedArgv = [...params.argv];

36-

resolvedArgv[0] = resolveCommand(resolvedArgv[0] ?? "");

61+

const invocation = resolveChildInvocation({

62+

argv: params.argv,

63+

windowsVerbatimArguments: params.windowsVerbatimArguments,

64+

});

3765

const baseEnv = params.env ? toStringEnv(params.env) : undefined;

38-

const preparedSpawn = prepareOomScoreAdjustedSpawn(resolvedArgv[0] ?? "", resolvedArgv.slice(1), {

66+

const preparedSpawn = prepareOomScoreAdjustedSpawn(invocation.command, invocation.args, {

3967

env: baseEnv,

4068

});

4169

@@ -52,7 +80,7 @@ export async function createChildAdapter(params: {

5280

stdio: ["pipe", "pipe", "pipe"],

5381

detached: useDetached,

5482

windowsHide: true,

55-

windowsVerbatimArguments: params.windowsVerbatimArguments,

83+

windowsVerbatimArguments: invocation.windowsVerbatimArguments,

5684

};

5785

if (stdinMode === "inherit") {

5886

options.stdio = ["inherit", "pipe", "pipe"];

Original file line numberDiff line numberDiff line change

@@ -2,6 +2,47 @@

22

import path from "node:path";

33

import process from "node:process";

44

import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce";

5+

import { getWindowsInstallRoots } from "../infra/windows-install-roots.js";

6+
7+

const WINDOWS_UNSAFE_CMD_CHARS_RE = /[&|<>%\r\n]/;

8+
9+

export function isWindowsBatchCommand(

10+

resolvedCommand: string,

11+

platform: NodeJS.Platform = process.platform,

12+

): boolean {

13+

if (platform !== "win32") {

14+

return false;

15+

}

16+

const ext = normalizeLowercaseStringOrEmpty(path.extname(resolvedCommand));

17+

return ext === ".cmd" || ext === ".bat";

18+

}

19+
20+

function escapeForWindowsCmdExe(arg: string): string {

21+

if (WINDOWS_UNSAFE_CMD_CHARS_RE.test(arg)) {

22+

throw new Error(

23+

`Unsafe Windows cmd.exe argument detected: ${JSON.stringify(arg)}. ` +

24+

"Pass an explicit shell-wrapper argv at the call site instead.",

25+

);

26+

}

27+

const escaped = arg.replace(/\^/g, "^^");

28+

if (!escaped.includes(" ") && !escaped.includes('"')) {

29+

return escaped;

30+

}

31+

return `"${escaped.replace(/"/g, '""')}"`;

32+

}

33+
34+

export function buildWindowsCmdExeCommandLine(command: string, args: readonly string[]): string {

35+

const escapedCommand = escapeForWindowsCmdExe(command);

36+

const commandLine = [escapedCommand, ...args.map(escapeForWindowsCmdExe)].join(" ");

37+

return escapedCommand.startsWith('"') ? `"${commandLine}"` : commandLine;

38+

}

39+
40+

export function resolveTrustedWindowsCmdExe(platform: NodeJS.Platform = process.platform): string {

41+

if (platform !== "win32") {

42+

return "cmd.exe";

43+

}

44+

return path.win32.join(getWindowsInstallRoots().systemRoot, "System32", "cmd.exe");

45+

}

546
647

/**

748

* Resolve package-manager commands that Windows exposes through .cmd shims.