Skip to content

Commit 23aee3d

Browse files
authored
Revert "Reland fix custom task shell doesn't work without manually passing in "run command" arg/flag" (microsoft#236726)
Revert "Reland fix custom task shell doesn't work without manually passing in…" This reverts commit 330ab6c.
1 parent 131ee0e commit 23aee3d

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

src/vs/platform/terminal/common/terminal.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,6 @@ export interface ITerminalProfile {
872872
overrideName?: boolean;
873873
color?: string;
874874
icon?: ThemeIcon | URI | { light: URI; dark: URI };
875-
isAutomationShell?: boolean;
876875
}
877876

878877
export interface ITerminalDimensionsOverride extends Readonly<ITerminalDimensions> {

src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
11121112
color: task.configurationProperties.icon?.color || undefined,
11131113
waitOnExit
11141114
};
1115+
let shellSpecified: boolean = false;
11151116
const shellOptions: IShellConfiguration | undefined = task.command.options && task.command.options.shell;
11161117
if (shellOptions) {
11171118
if (shellOptions.executable) {
@@ -1120,12 +1121,12 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
11201121
shellLaunchConfig.args = undefined;
11211122
}
11221123
shellLaunchConfig.executable = await this._resolveVariable(variableResolver, shellOptions.executable);
1124+
shellSpecified = true;
11231125
}
11241126
if (shellOptions.args) {
11251127
shellLaunchConfig.args = await this._resolveVariables(variableResolver, shellOptions.args.slice());
11261128
}
11271129
}
1128-
const taskShellArgsSpecified = (defaultProfile.isAutomationShell ? shellLaunchConfig.args : shellOptions?.args) !== undefined;
11291130
if (shellLaunchConfig.args === undefined) {
11301131
shellLaunchConfig.args = [];
11311132
}
@@ -1138,34 +1139,29 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
11381139
windowsShellArgs = true;
11391140
// If we don't have a cwd, then the terminal uses the home dir.
11401141
const userHome = await this._pathService.userHome();
1141-
if (basename === 'cmd.exe') {
1142-
if ((options.cwd && isUNC(options.cwd)) || (!options.cwd && isUNC(userHome.fsPath))) {
1143-
return undefined;
1144-
}
1145-
if (!taskShellArgsSpecified) {
1146-
toAdd.push('/d', '/c');
1147-
}
1148-
} else if ((basename === 'powershell.exe') || (basename === 'pwsh.exe')) {
1149-
if (!taskShellArgsSpecified) {
1142+
if (basename === 'cmd.exe' && ((options.cwd && isUNC(options.cwd)) || (!options.cwd && isUNC(userHome.fsPath)))) {
1143+
return undefined;
1144+
}
1145+
if ((basename === 'powershell.exe') || (basename === 'pwsh.exe')) {
1146+
if (!shellSpecified) {
11501147
toAdd.push('-Command');
11511148
}
11521149
} else if ((basename === 'bash.exe') || (basename === 'zsh.exe')) {
11531150
windowsShellArgs = false;
1154-
if (!taskShellArgsSpecified) {
1151+
if (!shellSpecified) {
11551152
toAdd.push('-c');
11561153
}
11571154
} else if (basename === 'wsl.exe') {
1158-
if (!taskShellArgsSpecified) {
1155+
if (!shellSpecified) {
11591156
toAdd.push('-e');
11601157
}
11611158
} else {
1162-
if (!taskShellArgsSpecified) {
1163-
// Push `-c` for unknown shells if the user didn't specify the args
1164-
toAdd.push('-c');
1159+
if (!shellSpecified) {
1160+
toAdd.push('/d', '/c');
11651161
}
11661162
}
11671163
} else {
1168-
if (!taskShellArgsSpecified) {
1164+
if (!shellSpecified) {
11691165
// Under Mac remove -l to not start it as a login shell.
11701166
if (platform === Platform.Platform.Mac) {
11711167
// Background on -l on osx https://github.com/microsoft/vscode/issues/107563
@@ -1272,12 +1268,11 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
12721268
const combinedShellArgs: string[] = Objects.deepClone(configuredShellArgs);
12731269
shellCommandArgs.forEach(element => {
12741270
const shouldAddShellCommandArg = configuredShellArgs.every((arg, index) => {
1275-
const isDuplicated = arg.toLowerCase() === element.toLowerCase();
1276-
if (isDuplicated && (configuredShellArgs.length > index + 1)) {
1271+
if ((arg.toLowerCase() === element) && (configuredShellArgs.length > index + 1)) {
12771272
// We can still add the argument, but only if not all of the following arguments begin with "-".
12781273
return !configuredShellArgs.slice(index + 1).every(testArg => testArg.startsWith('-'));
12791274
} else {
1280-
return !isDuplicated;
1275+
return arg.toLowerCase() !== element;
12811276
}
12821277
});
12831278
if (shouldAddShellCommandArg) {

src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ export abstract class BaseTerminalProfileResolverService extends Disposable impl
268268
const automationProfile = this._configurationService.getValue(`terminal.integrated.automationProfile.${this._getOsKey(options.os)}`);
269269
if (this._isValidAutomationProfile(automationProfile, options.os)) {
270270
automationProfile.icon = this._getCustomIcon(automationProfile.icon) || Codicon.tools;
271-
automationProfile.isAutomationShell = true;
272271
return automationProfile;
273272
}
274273

0 commit comments

Comments
 (0)