-
Notifications
You must be signed in to change notification settings - Fork 33.3k
TerminalTaskSystem: Fix addtion arguments for string command #251201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree |
} | ||
const combinedShellArgs = this._addExecStringFlags(shellSpecified, basename, shellArgs, platform); | ||
if (windowsShellArgs) { | ||
combinedShellArgs.push('"' + commandLine + '"'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we wanted commandLine to come be BEFORE all of the shell arguments? @dylanchu @meganrogge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, no, we didn't. The previous code is like this:
const combinedShellArgs = this._addAllArgument(toAdd, shellArgs);
combinedShellArgs.push(commandLine); // also after other arguments
shellLaunchConfig.args = windowsShellArgs ? combinedShellArgs.join(' ') : combinedShellArgs;
commandLine
is the payload command string specified in tasks by command
field. To pass it to the executable, we need to put it exactly behind the "execute command from string" flag (i.e. -c, -Command).
Take cmd.exe
and nu.exe
as examples, we would like the combined result to be
cmd.exe /d /q /c "echo hello"
nu.exe -I . -c "echo hello"
instead of
cmd.exe "echo hello" /d /c
nu.exe "echo hello" -I . -c
# or
cmd.exe /d /c /q "echo hello"
nu.exe -c -I . "echo hello"
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining this :)
Looking forward to the approval @anthonykim1 @meganrogge |
}; | ||
return defaults[basename] || []; | ||
} else { | ||
return ['-c']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we want to check whether shellSpecified is false like before when we add -c
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
// TODO: Handle by pulling the default terminal profile?
// const osxShellArgs = this._configurationService.inspect(TerminalSettingId.ShellArgsMacOs);
// if ((osxShellArgs.user === undefined) && (osxShellArgs.userLocal === undefined) && (osxShellArgs.userLocalValue === undefined)
// && (osxShellArgs.userRemote === undefined) && (osxShellArgs.userRemoteValue === undefined)
// && (osxShellArgs.userValue === undefined) && (osxShellArgs.workspace === undefined)
// && (osxShellArgs.workspaceFolder === undefined) && (osxShellArgs.workspaceFolderValue === undefined)
// && (osxShellArgs.workspaceValue === undefined)) {
// const index = shellArgs.indexOf('-l');
// if (index !== -1) {
// shellArgs.splice(index, 1);
// }
// }
}
toAdd.push('-c');
}
}
Changes:
cmd.exe
cmd.exe
: the "/d" argument should always be the first argument if there are other arguments specified in profilescmd.exe
: argument "/k" from profiles will be ignored as it conflicts with "/c"msys2.cmd
&msys2_shell.cmd
: "-c" will be added automatically if not specified in profilesThis should fix #169821.