diff --git a/src/main/providers/windows-shell-args.test.ts b/src/main/providers/windows-shell-args.test.ts index c9f6d1a470a..e7e8770a89c 100644 --- a/src/main/providers/windows-shell-args.test.ts +++ b/src/main/providers/windows-shell-args.test.ts @@ -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 diff --git a/src/main/providers/windows-shell-args.ts b/src/main/providers/windows-shell-args.ts index 826b672d271..0e3d181fdd4 100644 --- a/src/main/providers/windows-shell-args.ts +++ b/src/main/providers/windows-shell-args.ts @@ -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,