Fix Windows directory cwd prefixes (#6116)
This commit is contained in:
parent
0797966d39
commit
ffa80eb5bb
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue