mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-19 04:00:38 +09:00
Merge pull request #2397 from HearthCore/fix/win11-opencode-cmd-shell
fix: use real cmd.exe for Windows .cmd/.bat adapter invocation
This commit is contained in:
commit
6e894f27a2
1 changed files with 8 additions and 1 deletions
|
|
@ -474,6 +474,11 @@ function quoteForCmd(arg: string) {
|
||||||
return /[\s"&<>|^()]/.test(escaped) ? `"${escaped}"` : escaped;
|
return /[\s"&<>|^()]/.test(escaped) ? `"${escaped}"` : escaped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveWindowsCmdShell(env: NodeJS.ProcessEnv): string {
|
||||||
|
const fallbackRoot = env.SystemRoot || process.env.SystemRoot || "C:\\Windows";
|
||||||
|
return path.join(fallbackRoot, "System32", "cmd.exe");
|
||||||
|
}
|
||||||
|
|
||||||
async function resolveSpawnTarget(
|
async function resolveSpawnTarget(
|
||||||
command: string,
|
command: string,
|
||||||
args: string[],
|
args: string[],
|
||||||
|
|
@ -488,7 +493,9 @@ async function resolveSpawnTarget(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/\.(cmd|bat)$/i.test(executable)) {
|
if (/\.(cmd|bat)$/i.test(executable)) {
|
||||||
const shell = env.ComSpec || process.env.ComSpec || "cmd.exe";
|
// Always use cmd.exe for .cmd/.bat wrappers. Some environments override
|
||||||
|
// ComSpec to PowerShell, which breaks cmd-specific flags like /d /s /c.
|
||||||
|
const shell = resolveWindowsCmdShell(env);
|
||||||
const commandLine = [quoteForCmd(executable), ...args.map(quoteForCmd)].join(" ");
|
const commandLine = [quoteForCmd(executable), ...args.map(quoteForCmd)].join(" ");
|
||||||
return {
|
return {
|
||||||
command: shell,
|
command: shell,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue