@@ -42,8 +42,8 @@ import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
4242import { URI } from 'vs/base/common/uri' ;
4343import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService' ;
4444import { Schemas } from 'vs/base/common/network' ;
45- import { getDefaultShell } from 'vs/workbench/contrib/terminal/node/terminal' ;
4645import { IPanelService } from 'vs/workbench/services/panel/common/panelService' ;
46+ import { ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal' ;
4747
4848interface TerminalData {
4949 terminal : ITerminalInstance ;
@@ -172,6 +172,7 @@ export class TerminalTaskSystem implements ITaskSystem {
172172 private environmentService : IWorkbenchEnvironmentService ,
173173 private outputChannelId : string ,
174174 private fileService : IFileService ,
175+ private terminalInstanceService : ITerminalInstanceService ,
175176 taskSystemInfoResolver : TaskSystemInfoResolver ,
176177 ) {
177178
@@ -751,6 +752,25 @@ export class TerminalTaskSystem implements ITaskSystem {
751752 return nls . localize ( 'TerminalTaskSystem.terminalName' , 'Task - {0}' , needsFolderQualification ? task . getQualifiedLabel ( ) : task . configurationProperties . name ) ;
752753 }
753754
755+ private getDefaultShell ( platform : Platform . Platform ) : string {
756+ let defaultShell : string | undefined = undefined ;
757+ try {
758+ defaultShell = this . terminalInstanceService . getDefaultShell ( platform ) ;
759+ } catch {
760+ // Do nothing
761+ }
762+ if ( ! defaultShell ) {
763+ // Make up a guess for the default shell.
764+ if ( platform === Platform . Platform . Windows ) {
765+ defaultShell = 'cmd.exe' ;
766+ } else {
767+ defaultShell = 'bash.exe' ;
768+ }
769+ console . warn ( 'Cannot get the default shell.' ) ;
770+ }
771+ return defaultShell ;
772+ }
773+
754774 private createShellLaunchConfig ( task : CustomTask | ContributedTask , variableResolver : VariableResolver , platform : Platform . Platform , options : CommandOptions , command : CommandString , args : CommandString [ ] , waitOnExit : boolean | string ) : IShellLaunchConfig | undefined {
755775 let shellLaunchConfig : IShellLaunchConfig ;
756776 let isShellCommand = task . command . runtime === RuntimeType . Shell ;
@@ -759,7 +779,7 @@ export class TerminalTaskSystem implements ITaskSystem {
759779 let originalCommand = task . command . name ;
760780 if ( isShellCommand ) {
761781 shellLaunchConfig = { name : terminalName , executable : undefined , args : undefined , waitOnExit } ;
762- this . terminalService . configHelper . mergeDefaultShellPathAndArgs ( shellLaunchConfig , getDefaultShell ( platform ) , platform ) ;
782+ this . terminalService . configHelper . mergeDefaultShellPathAndArgs ( shellLaunchConfig , this . getDefaultShell ( platform ) , platform ) ;
763783 let shellSpecified : boolean = false ;
764784 let shellOptions : ShellConfiguration | undefined = task . command . options && task . command . options . shell ;
765785 if ( shellOptions ) {
0 commit comments