mirror of
https://github.com/rait-09/obsidian-agent-client.git
synced 2026-07-22 06:43:37 +00:00
Merge pull request #304 from mimoralea/patch-1
Use direct WSL exec for absolute-path agent commands
This commit is contained in:
commit
ee01a76e96
1 changed files with 22 additions and 6 deletions
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue