Skip to content

Commit

Permalink
Improve shell identifier on case-insensitive system (#22391)
Browse files Browse the repository at this point in the history
Use case-insensitive regex to remove `.exe`  extension.

See:
#22036 (comment)
  • Loading branch information
JamzumSum authored Nov 7, 2023
1 parent 7bc45e5 commit 67b4801
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 67b4801

Please sign in to comment.