Merge pull request #304 from mimoralea/patch-1

Use direct WSL exec for absolute-path agent commands
This commit is contained in:
RAIT-09 2026-06-02 12:40:49 +09:00 committed by GitHub
commit ee01a76e96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -307,13 +307,29 @@ export function wrapCommandForWsl(
pathPrefix = `export PATH="${escapePathForShell(wslPath)}:$PATH"; `;
}
const innerCommand = `${pathPrefix}cd ${escapeShellArgBash(wslCwd)} && ${command}${argsString}`;
wslArgs.push("sh", "-c", buildWslShellWrapper(innerCommand));
const commandIsAbsoluteWslPath = command.startsWith("/");
const commandHasShellSyntax = /[\s"'`$&|;<>(){}[\]*?!\\]/.test(command);
const canUseDirectExec =
commandIsAbsoluteWslPath &&
!commandHasShellSyntax &&
!additionalPath;
return {
command: "C:\\Windows\\System32\\wsl.exe",
args: wslArgs,
};
if (canUseDirectExec) {
wslArgs.push("--cd", wslCwd, "--exec", command, ...args);
return {
command: "C:\\Windows\\System32\\wsl.exe",
args: wslArgs,
};
}
const innerCommand = `${pathPrefix}cd ${escapeShellArgBash(wslCwd)} && ${command}${argsString}`;
wslArgs.push("sh", "-c", buildWslShellWrapper(innerCommand));
return {
command: "C:\\Windows\\System32\\wsl.exe",
args: wslArgs,
};
}
/**