提交 5cbb1b0d 编写于 作者: D Daniel Imms 提交者: GitHub

Merge pull request #22565 from Microsoft/tyriar/19078

Support terminal shell args as string
......@@ -391,7 +391,7 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem {
} else {
(this.terminalService.configHelper as TerminalConfigHelper).mergeDefaultShellPathAndArgs(shellLaunchConfig);
}
let shellArgs = shellLaunchConfig.args.slice(0);
let shellArgs = <string[]>shellLaunchConfig.args.slice(0);
let toAdd: string[] = [];
let commandLine = args && args.length > 0 ? `${command} ${args.join(' ')}` : `${command}`;
if (Platform.isWindows) {
......
......@@ -79,8 +79,12 @@ export interface IShellLaunchConfig {
name?: string;
/** The shell executable (bash, cmd, etc.). */
executable?: string;
/** The CLI arguments to use with executable. */
args?: string[];
/**
* The CLI arguments to use with executable, a string[] is in argv format and will be escaped,
* a string is in "CommandLine" pre-escaped format and will be used as is. The string option is
* only supported on Windows and will throw an exception if used on macOS or Linux.
*/
args?: string[] | string;
/**
* The current working directory of the terminal, this overrides the `terminal.integrated.cwd`
* settings key.
......
......@@ -522,7 +522,9 @@ export class TerminalInstance implements ITerminalInstance {
if (exitCode) {
if (this._isLaunching) {
let args = '';
if (this._shellLaunchConfig.args && this._shellLaunchConfig.args.length) {
if (typeof this._shellLaunchConfig.args === 'string') {
args = this._shellLaunchConfig.args;
} else if (this._shellLaunchConfig.args && this._shellLaunchConfig.args.length) {
args = ' ' + this._shellLaunchConfig.args.map(a => {
if (a.indexOf(' ') !== -1) {
return `'${a}'`;
......@@ -578,9 +580,11 @@ export class TerminalInstance implements ITerminalInstance {
env['PTYPID'] = process.pid.toString();
env['PTYSHELL'] = shell.executable;
if (shell.args) {
shell.args.forEach((arg, i) => {
env[`PTYSHELLARG${i}`] = arg;
});
if (typeof shell.args === 'string') {
env[`PTYSHELLCMDLINE`] = shell.args;
} else {
shell.args.forEach((arg, i) => env[`PTYSHELLARG${i}`] = arg);
}
}
env['PTYCWD'] = cwd;
env['LANG'] = TerminalInstance._getLangEnvVariable(locale);
......
......@@ -63,6 +63,9 @@ sendProcessId();
setupTitlePolling();
function getArgs() {
if (process.env['PTYSHELLCMDLINE']) {
return process.env['PTYSHELLCMDLINE'];
}
var args = [];
var i = 0;
while (process.env['PTYSHELLARG' + i]) {
......@@ -79,7 +82,8 @@ function cleanEnv() {
'PTYPID',
'PTYSHELL',
'PTYCOLS',
'PTYROWS'
'PTYROWS',
'PTYSHELLCMDLINE'
];
keys.forEach(function (key) {
if (process.env[key]) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册