diff --git a/Extension/src/Debugger/attachToProcess.ts b/Extension/src/Debugger/attachToProcess.ts index 4ff3ce0c2..169c99218 100644 --- a/Extension/src/Debugger/attachToProcess.ts +++ b/Extension/src/Debugger/attachToProcess.ts @@ -81,7 +81,10 @@ export class RemoteAttachPicker { const pipeCmd: string = `"${pipeProgram}" ${argList}`; - processes = await this.getRemoteOSAndProcesses(pipeCmd); + // If unspecified quoteArgs defaults to true. + const quoteArgs: boolean = pipeTransport.quoteArgs ?? true; + + processes = await this.getRemoteOSAndProcesses(pipeCmd, quoteArgs); } else if (!pipeTransport && useExtendedRemote) { if (!miDebuggerPath || !miDebuggerServerAddress) { 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 { } // Creates a string to run on the host machine which will execute a shell script on the remote machine to retrieve OS and processes - private getRemoteProcessCommand(): string { + private getRemoteProcessCommand(quoteArgs: boolean): string { let innerQuote: string = `'`; let outerQuote: string = `"`; let parameterBegin: string = `$(`; @@ -127,6 +130,12 @@ export class RemoteAttachPicker { innerQuote = `"`; outerQuote = `'`; } + + // If the pipeTransport settings indicate "quoteArgs": "false", we need to skip the outer quotes. + if (!quoteArgs) { + outerQuote = ``; + } + // 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. if (os.platform() === "linux") { shPrefix = `/bin/`; @@ -138,9 +147,9 @@ export class RemoteAttachPicker { `then ${PsProcessParser.psDarwinCommand}; fi${innerQuote}${outerQuote}`; } - private async getRemoteOSAndProcesses(pipeCmd: string): Promise { + private async getRemoteOSAndProcesses(pipeCmd: string, quoteArgs: boolean): Promise { // Do not add any quoting in execCommand. - const execCommand: string = `${pipeCmd} ${this.getRemoteProcessCommand()}`; + const execCommand: string = `${pipeCmd} ${this.getRemoteProcessCommand(quoteArgs)}`; const output: string = await util.execChildProcess(execCommand, undefined, this._channel); // OS will be on first line