mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
Fix Windows directory cwd prefixes (#6116)
This commit is contained in:
@@ -214,6 +214,19 @@ describe('resolveWindowsShellLaunchArgs', () => {
|
||||
expect(result.validationCwd).toBe('C:\\Users\\alice\\project')
|
||||
})
|
||||
|
||||
it('does not treat MSYS drive cwd as a WSL POSIX cwd', () => {
|
||||
const result = resolveWindowsShellLaunchArgs(
|
||||
'wsl.exe',
|
||||
'/c/Users/alice/project',
|
||||
'C:\\Users\\alice',
|
||||
{ distro: 'Ubuntu', treatPosixCwdAsWsl: true }
|
||||
)
|
||||
|
||||
expect(result.shellArgs).toEqual(expectedWslArgs('/mnt/c/Users/alice/project', 'Ubuntu'))
|
||||
expect(result.effectiveCwd).toBe('C:\\Users\\alice')
|
||||
expect(result.validationCwd).toBe('C:\\Users\\alice\\project')
|
||||
})
|
||||
|
||||
it('escapes single quotes when translating a WSL cwd', () => {
|
||||
const result = resolveWindowsShellLaunchArgs('wsl.exe', "C:\\weird'path", 'C:\\Users\\alice')
|
||||
// The injected sh cmd must not break out of the surrounding single quotes
|
||||
|
||||
@@ -136,6 +136,7 @@ export function resolveWindowsShellLaunchArgs(
|
||||
): WindowsShellLaunchArgs {
|
||||
const shellBasename = pathWin32.basename(shellPath).toLowerCase()
|
||||
const nativeCwd = normalizeMsysDrivePath(cwd)
|
||||
const isMsysDriveCwd = nativeCwd !== cwd
|
||||
|
||||
if (shellBasename === 'cmd.exe') {
|
||||
const shellArgStartupCommand = getCmdShellArgStartupCommand(startupCommand)
|
||||
@@ -183,7 +184,7 @@ export function resolveWindowsShellLaunchArgs(
|
||||
validationCwd: cwd
|
||||
}
|
||||
}
|
||||
if (wslContext?.treatPosixCwdAsWsl && cwd.startsWith('/')) {
|
||||
if (wslContext?.treatPosixCwdAsWsl && cwd.startsWith('/') && !isMsysDriveCwd) {
|
||||
return {
|
||||
shellArgs: buildWslShellArgs(cwd, wslContext.distro),
|
||||
effectiveCwd: defaultCwd,
|
||||
|
||||
Reference in New Issue
Block a user