Skip to content

Commit

Permalink
Revert "Fix custom task shell doesn't work without manually passing i…
Browse files Browse the repository at this point in the history
…n "run command" arg/flag (#181760)" (#236043)

This reverts commit fc3cc5b.
  • Loading branch information
alexr00 authored Dec 13, 2024
1 parent 7112b3b commit fa09409
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,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 @@ -1119,12 +1120,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 shellArgsSpecified: boolean = shellLaunchConfig.args !== undefined;
if (shellLaunchConfig.args === undefined) {
shellLaunchConfig.args = [];
}
Expand All @@ -1137,29 +1138,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 (!shellArgsSpecified) {
toAdd.push('/d', '/c');
}
} else if ((basename === 'powershell.exe') || (basename === 'pwsh.exe')) {
if (!shellArgsSpecified) {
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 (!shellArgsSpecified) {
if (!shellSpecified) {
toAdd.push('-c');
}
} else if (basename === 'wsl.exe') {
if (!shellArgsSpecified) {
if (!shellSpecified) {
toAdd.push('-e');
}
} else {
if (!shellSpecified) {
toAdd.push('/d', '/c');
}
}
} else {
if (!shellArgsSpecified) {
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 @@ -1266,12 +1267,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

0 comments on commit fa09409

Please sign in to comment.