Skip to content

Commit

Permalink
Revert "Reland fix custom task shell doesn't work without manually pa…
Browse files Browse the repository at this point in the history
…ssing in "run command" arg/flag" (microsoft#236726)

Revert "Reland fix custom task shell doesn't work without manually passing in…"

This reverts commit 330ab6c.
  • Loading branch information
meganrogge authored Dec 20, 2024
1 parent 131ee0e commit 23aee3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/vs/platform/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,6 @@ export interface ITerminalProfile {
overrideName?: boolean;
color?: string;
icon?: ThemeIcon | URI | { light: URI; dark: URI };
isAutomationShell?: boolean;
}

export interface ITerminalDimensionsOverride extends Readonly<ITerminalDimensions> {
Expand Down
33 changes: 14 additions & 19 deletions src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
color: task.configurationProperties.icon?.color || undefined,
waitOnExit
};
let shellSpecified: boolean = false;
const shellOptions: IShellConfiguration | undefined = task.command.options && task.command.options.shell;
if (shellOptions) {
if (shellOptions.executable) {
Expand All @@ -1120,12 +1121,12 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
shellLaunchConfig.args = undefined;
}
shellLaunchConfig.executable = await this._resolveVariable(variableResolver, shellOptions.executable);
shellSpecified = true;
}
if (shellOptions.args) {
shellLaunchConfig.args = await this._resolveVariables(variableResolver, shellOptions.args.slice());
}
}
const taskShellArgsSpecified = (defaultProfile.isAutomationShell ? shellLaunchConfig.args : shellOptions?.args) !== undefined;
if (shellLaunchConfig.args === undefined) {
shellLaunchConfig.args = [];
}
Expand All @@ -1138,34 +1139,29 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
windowsShellArgs = true;
// If we don't have a cwd, then the terminal uses the home dir.
const userHome = await this._pathService.userHome();
if (basename === 'cmd.exe') {
if ((options.cwd && isUNC(options.cwd)) || (!options.cwd && isUNC(userHome.fsPath))) {
return undefined;
}
if (!taskShellArgsSpecified) {
toAdd.push('/d', '/c');
}
} else if ((basename === 'powershell.exe') || (basename === 'pwsh.exe')) {
if (!taskShellArgsSpecified) {
if (basename === 'cmd.exe' && ((options.cwd && isUNC(options.cwd)) || (!options.cwd && isUNC(userHome.fsPath)))) {
return undefined;
}
if ((basename === 'powershell.exe') || (basename === 'pwsh.exe')) {
if (!shellSpecified) {
toAdd.push('-Command');
}
} else if ((basename === 'bash.exe') || (basename === 'zsh.exe')) {
windowsShellArgs = false;
if (!taskShellArgsSpecified) {
if (!shellSpecified) {
toAdd.push('-c');
}
} else if (basename === 'wsl.exe') {
if (!taskShellArgsSpecified) {
if (!shellSpecified) {
toAdd.push('-e');
}
} else {
if (!taskShellArgsSpecified) {
// Push `-c` for unknown shells if the user didn't specify the args
toAdd.push('-c');
if (!shellSpecified) {
toAdd.push('/d', '/c');
}
}
} else {
if (!taskShellArgsSpecified) {
if (!shellSpecified) {
// Under Mac remove -l to not start it as a login shell.
if (platform === Platform.Platform.Mac) {
// Background on -l on osx https://github.com/microsoft/vscode/issues/107563
Expand Down Expand Up @@ -1272,12 +1268,11 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
const combinedShellArgs: string[] = Objects.deepClone(configuredShellArgs);
shellCommandArgs.forEach(element => {
const shouldAddShellCommandArg = configuredShellArgs.every((arg, index) => {
const isDuplicated = arg.toLowerCase() === element.toLowerCase();
if (isDuplicated && (configuredShellArgs.length > index + 1)) {
if ((arg.toLowerCase() === element) && (configuredShellArgs.length > index + 1)) {
// We can still add the argument, but only if not all of the following arguments begin with "-".
return !configuredShellArgs.slice(index + 1).every(testArg => testArg.startsWith('-'));
} else {
return !isDuplicated;
return arg.toLowerCase() !== element;
}
});
if (shouldAddShellCommandArg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ export abstract class BaseTerminalProfileResolverService extends Disposable impl
const automationProfile = this._configurationService.getValue(`terminal.integrated.automationProfile.${this._getOsKey(options.os)}`);
if (this._isValidAutomationProfile(automationProfile, options.os)) {
automationProfile.icon = this._getCustomIcon(automationProfile.icon) || Codicon.tools;
automationProfile.isAutomationShell = true;
return automationProfile;
}

Expand Down

0 comments on commit 23aee3d

Please sign in to comment.