Skip to content

Commit

Permalink
Fix quoting for tasks (#142400)
Browse files Browse the repository at this point in the history
Fixes #142196
  • Loading branch information
alexr00 authored Feb 9, 2022
1 parent 0a21487 commit 24d703a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,8 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
}

private buildShellCommandLine(platform: Platform.Platform, shellExecutable: string, shellOptions: ShellConfiguration | undefined, command: CommandString, originalCommand: CommandString | undefined, args: CommandString[]): string {
let shellQuoteOptions = this.getQuotingOptions(shellExecutable, shellOptions, platform);
const basename = path.parse(shellExecutable).name.toLowerCase();
const shellQuoteOptions = this.getQuotingOptions(basename, shellOptions, platform);

function needsQuotes(value: string): boolean {
if (value.length >= 2) {
Expand Down Expand Up @@ -1440,9 +1441,9 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
let commandLine = result.join(' ');
// There are special rules quoted command line in cmd.exe
if (platform === Platform.Platform.Windows) {
if (shellExecutable === 'cmd' && commandQuoted && argQuoted) {
if (basename === 'cmd' && commandQuoted && argQuoted) {
commandLine = '"' + commandLine + '"';
} else if ((shellExecutable === 'powershell' || shellExecutable === 'pwsh') && commandQuoted) {
} else if ((basename === 'powershell' || basename === 'pwsh') && commandQuoted) {
commandLine = '& ' + commandLine;
}
}
Expand Down

0 comments on commit 24d703a

Please sign in to comment.