@@ -161,6 +161,20 @@ export function getShellIntegrationInjection(
161
161
envMixin [ 'VSCODE_SUGGEST' ] = '1' ;
162
162
}
163
163
return { newArgs, envMixin } ;
164
+ } else if ( shell === 'bash.exe' ) {
165
+ if ( ! originalArgs || originalArgs . length === 0 ) {
166
+ newArgs = shellIntegrationArgs . get ( ShellIntegrationExecutable . Bash ) ;
167
+ } else if ( areZshBashLoginArgs ( originalArgs ) ) {
168
+ envMixin [ 'VSCODE_SHELL_LOGIN' ] = '1' ;
169
+ addEnvMixinPathPrefix ( options , envMixin ) ;
170
+ newArgs = shellIntegrationArgs . get ( ShellIntegrationExecutable . Bash ) ;
171
+ }
172
+ if ( ! newArgs ) {
173
+ return undefined ;
174
+ }
175
+ newArgs = [ ...newArgs ] ; // Shallow clone the array to avoid setting the default array
176
+ newArgs [ newArgs . length - 1 ] = format ( newArgs [ newArgs . length - 1 ] , appRoot ) ;
177
+ return { newArgs, envMixin } ;
164
178
}
165
179
logService . warn ( `Shell integration cannot be enabled for executable "${ shellLaunchConfig . executable } " and args` , shellLaunchConfig . args ) ;
166
180
return undefined ;
@@ -310,16 +324,18 @@ shellIntegrationArgs.set(ShellIntegrationExecutable.PwshLogin, ['-l', '-noexit',
310
324
shellIntegrationArgs . set ( ShellIntegrationExecutable . Zsh , [ '-i' ] ) ;
311
325
shellIntegrationArgs . set ( ShellIntegrationExecutable . ZshLogin , [ '-il' ] ) ;
312
326
shellIntegrationArgs . set ( ShellIntegrationExecutable . Bash , [ '--init-file' , '{0}/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh' ] ) ;
313
- const loginArgs = [ '-login' , '-l' ] ;
327
+ const pwshLoginArgs = [ '-login' , '-l' ] ;
328
+ const shLoginArgs = [ '--login' , '-l' ] ;
329
+ const shInteractiveArgs = [ '-i' , '--interactive' ] ;
314
330
const pwshImpliedArgs = [ '-nol' , '-nologo' ] ;
315
331
316
332
function arePwshLoginArgs ( originalArgs : string | string [ ] ) : boolean {
317
333
if ( typeof originalArgs === 'string' ) {
318
- return loginArgs . includes ( originalArgs . toLowerCase ( ) ) ;
334
+ return pwshLoginArgs . includes ( originalArgs . toLowerCase ( ) ) ;
319
335
} else {
320
- return originalArgs . length === 1 && loginArgs . includes ( originalArgs [ 0 ] . toLowerCase ( ) ) ||
336
+ return originalArgs . length === 1 && pwshLoginArgs . includes ( originalArgs [ 0 ] . toLowerCase ( ) ) ||
321
337
( originalArgs . length === 2 &&
322
- ( ( ( loginArgs . includes ( originalArgs [ 0 ] . toLowerCase ( ) ) ) || loginArgs . includes ( originalArgs [ 1 ] . toLowerCase ( ) ) ) )
338
+ ( ( ( pwshLoginArgs . includes ( originalArgs [ 0 ] . toLowerCase ( ) ) ) || pwshLoginArgs . includes ( originalArgs [ 1 ] . toLowerCase ( ) ) ) )
323
339
&& ( ( pwshImpliedArgs . includes ( originalArgs [ 0 ] . toLowerCase ( ) ) ) || pwshImpliedArgs . includes ( originalArgs [ 1 ] . toLowerCase ( ) ) ) ) ;
324
340
}
325
341
}
@@ -333,6 +349,9 @@ function arePwshImpliedArgs(originalArgs: string | string[]): boolean {
333
349
}
334
350
335
351
function areZshBashLoginArgs ( originalArgs : string | string [ ] ) : boolean {
336
- return originalArgs === 'string' && loginArgs . includes ( originalArgs . toLowerCase ( ) )
337
- || typeof originalArgs !== 'string' && originalArgs . length === 1 && loginArgs . includes ( originalArgs [ 0 ] . toLowerCase ( ) ) ;
352
+ if ( typeof originalArgs !== 'string' ) {
353
+ originalArgs = originalArgs . filter ( arg => ! shInteractiveArgs . includes ( arg . toLowerCase ( ) ) ) ;
354
+ }
355
+ return originalArgs === 'string' && shLoginArgs . includes ( originalArgs . toLowerCase ( ) )
356
+ || typeof originalArgs !== 'string' && originalArgs . length === 1 && shLoginArgs . includes ( originalArgs [ 0 ] . toLowerCase ( ) ) ;
338
357
}
0 commit comments