From 761664e512fd16676b86a22114646f128e9f33f1 Mon Sep 17 00:00:00 2001 From: JamzumSum Date: Tue, 31 Oct 2023 12:33:32 +0800 Subject: [PATCH 1/2] improve shell identify on case-insensitive system Use case-insensitive regex to remove `.exe` extension. https://github.com/microsoft/vscode-python/issues/22036#issuecomment-1786354934 --- src/client/common/terminal/shellDetectors/baseShellDetector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/common/terminal/shellDetectors/baseShellDetector.ts b/src/client/common/terminal/shellDetectors/baseShellDetector.ts index d3c3967d3e3a..29a5e548891e 100644 --- a/src/client/common/terminal/shellDetectors/baseShellDetector.ts +++ b/src/client/common/terminal/shellDetectors/baseShellDetector.ts @@ -63,7 +63,7 @@ export abstract class BaseShellDetector implements IShellDetector { export function identifyShellFromShellPath(shellPath: string): TerminalShellType { // Remove .exe extension so shells can be more consistently detected // on Windows (including Cygwin). - const basePath = shellPath.replace(/\.exe$/, ''); + const basePath = shellPath.replace(/\.exe$/i, ''); const shell = Array.from(detectableShells.keys()).reduce((matchedShell, shellToDetect) => { if (matchedShell === TerminalShellType.other) { From 1e278a9e354012d698cd014044ec2bf1b95de1d3 Mon Sep 17 00:00:00 2001 From: JamzumSum Date: Wed, 1 Nov 2023 08:31:24 +0800 Subject: [PATCH 2/2] add unittest for shell detector in case of the incoming path is case-insensitive --- .../common/terminals/shellDetectors/shellDetectors.unit.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/common/terminals/shellDetectors/shellDetectors.unit.test.ts b/src/test/common/terminals/shellDetectors/shellDetectors.unit.test.ts index 07befdda9291..e58e455ea7eb 100644 --- a/src/test/common/terminals/shellDetectors/shellDetectors.unit.test.ts +++ b/src/test/common/terminals/shellDetectors/shellDetectors.unit.test.ts @@ -41,6 +41,7 @@ suite('Shell Detectors', () => { shellPathsAndIdentification.set('/usr/bin/ksh', TerminalShellType.ksh); shellPathsAndIdentification.set('c:\\windows\\system32\\powershell.exe', TerminalShellType.powershell); shellPathsAndIdentification.set('c:\\windows\\system32\\pwsh.exe', TerminalShellType.powershellCore); + shellPathsAndIdentification.set('C:\\Program Files\\nu\\bin\\nu.EXE', TerminalShellType.nushell); shellPathsAndIdentification.set('/usr/microsoft/xxx/powershell/powershell', TerminalShellType.powershell); shellPathsAndIdentification.set('/usr/microsoft/xxx/powershell/pwsh', TerminalShellType.powershellCore); shellPathsAndIdentification.set('/usr/bin/fish', TerminalShellType.fish);