@@ -19,14 +19,14 @@ When identifying the shell use the following algorithm:
19
19
20
20
// Types of shells can be found here:
21
21
// 1. https://wiki.ubuntu.com/ChangingShells
22
- const IS_GITBASH = / ( g i t b a s h . e x e $ ) / i;
23
- const IS_BASH = / ( b a s h . e x e $ | b a s h $ ) / i;
24
- const IS_WSL = / ( w s l . e x e $ ) / i;
22
+ const IS_GITBASH = / ( g i t b a s h $ ) / i;
23
+ const IS_BASH = / ( b a s h $ ) / i;
24
+ const IS_WSL = / ( w s l $ ) / i;
25
25
const IS_ZSH = / ( z s h $ ) / i;
26
26
const IS_KSH = / ( k s h $ ) / i;
27
- const IS_COMMAND = / ( c m d . e x e $ | c m d $ ) / i;
28
- const IS_POWERSHELL = / ( p o w e r s h e l l . e x e $ | p o w e r s h e l l $ ) / i;
29
- const IS_POWERSHELL_CORE = / ( p w s h . e x e $ | p w s h $ ) / i;
27
+ const IS_COMMAND = / ( c m d $ ) / i;
28
+ const IS_POWERSHELL = / ( p o w e r s h e l l $ ) / i;
29
+ const IS_POWERSHELL_CORE = / ( p w s h $ ) / i;
30
30
const IS_FISH = / ( f i s h $ ) / i;
31
31
const IS_CSHELL = / ( c s h $ ) / i;
32
32
const IS_TCSHELL = / ( t c s h $ ) / i;
@@ -54,17 +54,21 @@ export abstract class BaseShellDetector implements IShellDetector {
54
54
terminal ?: Terminal ,
55
55
) : TerminalShellType | undefined ;
56
56
public identifyShellFromShellPath ( shellPath : string ) : TerminalShellType {
57
+ // Remove .exe extension so shells can be more consistently detected
58
+ // on Windows (including Cygwin).
59
+ const basePath = shellPath . replace ( / \. e x e $ / , '' ) ;
60
+
57
61
const shell = Array . from ( detectableShells . keys ( ) ) . reduce ( ( matchedShell , shellToDetect ) => {
58
62
if ( matchedShell === TerminalShellType . other ) {
59
63
const pat = detectableShells . get ( shellToDetect ) ;
60
- if ( pat && pat . test ( shellPath ) ) {
64
+ if ( pat && pat . test ( basePath ) ) {
61
65
return shellToDetect ;
62
66
}
63
67
}
64
68
return matchedShell ;
65
69
} , TerminalShellType . other ) ;
66
70
67
- traceVerbose ( `Shell path '${ shellPath } '` ) ;
71
+ traceVerbose ( `Shell path '${ shellPath } ', base path ' ${ basePath } ' ` ) ;
68
72
traceVerbose ( `Shell path identified as shell '${ shell } '` ) ;
69
73
return shell ;
70
74
}
0 commit comments