Skip to content

Commit 83ba416

Browse files
authored
Makes remote attach picker respect the pipeTransport.quoteArgs config… (#13794)
* Makes remote attach picker respect the pipeTransport.quoteArgs configuration * fixes linter error - don't compare boolean value to a boolean
1 parent 33bdfeb commit 83ba416

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Extension/src/Debugger/attachToProcess.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ export class RemoteAttachPicker {
8181

8282
const pipeCmd: string = `"${pipeProgram}" ${argList}`;
8383

84-
processes = await this.getRemoteOSAndProcesses(pipeCmd);
84+
// If unspecified quoteArgs defaults to true.
85+
const quoteArgs: boolean = pipeTransport.quoteArgs ?? true;
86+
87+
processes = await this.getRemoteOSAndProcesses(pipeCmd, quoteArgs);
8588
} else if (!pipeTransport && useExtendedRemote) {
8689
if (!miDebuggerPath || !miDebuggerServerAddress) {
8790
throw new Error(localize("debugger.path.and.server.address.required", "{0} in debug configuration requires {1} and {2}", "useExtendedRemote", "miDebuggerPath", "miDebuggerServerAddress"));
@@ -106,7 +109,7 @@ export class RemoteAttachPicker {
106109
}
107110

108111
// Creates a string to run on the host machine which will execute a shell script on the remote machine to retrieve OS and processes
109-
private getRemoteProcessCommand(): string {
112+
private getRemoteProcessCommand(quoteArgs: boolean): string {
110113
let innerQuote: string = `'`;
111114
let outerQuote: string = `"`;
112115
let parameterBegin: string = `$(`;
@@ -127,6 +130,12 @@ export class RemoteAttachPicker {
127130
innerQuote = `"`;
128131
outerQuote = `'`;
129132
}
133+
134+
// If the pipeTransport settings indicate "quoteArgs": "false", we need to skip the outer quotes.
135+
if (!quoteArgs) {
136+
outerQuote = ``;
137+
}
138+
130139
// Also use a full path on Linux, so that we can use transports that need a full path such as 'machinectl' to connect to nspawn containers.
131140
if (os.platform() === "linux") {
132141
shPrefix = `/bin/`;
@@ -138,9 +147,9 @@ export class RemoteAttachPicker {
138147
`then ${PsProcessParser.psDarwinCommand}; fi${innerQuote}${outerQuote}`;
139148
}
140149

141-
private async getRemoteOSAndProcesses(pipeCmd: string): Promise<AttachItem[]> {
150+
private async getRemoteOSAndProcesses(pipeCmd: string, quoteArgs: boolean): Promise<AttachItem[]> {
142151
// Do not add any quoting in execCommand.
143-
const execCommand: string = `${pipeCmd} ${this.getRemoteProcessCommand()}`;
152+
const execCommand: string = `${pipeCmd} ${this.getRemoteProcessCommand(quoteArgs)}`;
144153

145154
const output: string = await util.execChildProcess(execCommand, undefined, this._channel);
146155
// OS will be on first line

0 commit comments

Comments
 (0)