From b3abd40400dac96cdd175193dc4cad3c0b5fd702 Mon Sep 17 00:00:00 2001 From: Matt <59707001+mjrist@users.noreply.github.com> Date: Wed, 30 Jul 2025 18:45:12 +0000 Subject: [PATCH 1/2] Makes remote attach picker respect the pipeTransport.quoteArgs configuration --- Extension/src/Debugger/attachToProcess.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Extension/src/Debugger/attachToProcess.ts b/Extension/src/Debugger/attachToProcess.ts index 4ff3ce0c2..b42c2b82c 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 === false) { + 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 From 906e1d30352a2e6270d945b60e4b5b6508d2ab35 Mon Sep 17 00:00:00 2001 From: Matt <59707001+mjrist@users.noreply.github.com> Date: Wed, 30 Jul 2025 21:31:40 +0000 Subject: [PATCH 2/2] fixes linter error - don't compare boolean value to a boolean --- Extension/src/Debugger/attachToProcess.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/src/Debugger/attachToProcess.ts b/Extension/src/Debugger/attachToProcess.ts index b42c2b82c..169c99218 100644 --- a/Extension/src/Debugger/attachToProcess.ts +++ b/Extension/src/Debugger/attachToProcess.ts @@ -132,7 +132,7 @@ export class RemoteAttachPicker { } // If the pipeTransport settings indicate "quoteArgs": "false", we need to skip the outer quotes. - if (quoteArgs === false) { + if (!quoteArgs) { outerQuote = ``; }