diff --git a/Extension/src/Debugger/attachToProcess.ts b/Extension/src/Debugger/attachToProcess.ts index a278d4d3f8..7a6cebf65e 100644 --- a/Extension/src/Debugger/attachToProcess.ts +++ b/Extension/src/Debugger/attachToProcess.ts @@ -112,6 +112,7 @@ export class RemoteAttachPicker { let parameterBegin: string = `$(`; let parameterEnd: string = `)`; let escapedQuote: string = `\\\"`; + let shPrefix: string = ``; const settings: CppSettings = new CppSettings(); if (settings.useBacktickCommandSubstitution) { @@ -122,12 +123,14 @@ export class RemoteAttachPicker { // Must use single quotes around the whole command and double quotes for the argument to `sh -c` because Linux evaluates $() inside of double quotes. // Having double quotes for the outerQuote will have $(uname) replaced before it is sent to the remote machine. + // Also use a full path on Linux, so that we can use transports that need a full patch such as 'machinectl' to connect to nspawn containers. if (os.platform() !== "win32") { innerQuote = `"`; outerQuote = `'`; + shPrefix = `/bin/`; } - return `${outerQuote}sh -c ${innerQuote}uname && if [ ${parameterBegin}uname${parameterEnd} = ${escapedQuote}Linux${escapedQuote} ] ; ` + + return `${outerQuote}${shPrefix}sh -c ${innerQuote}uname && if [ ${parameterBegin}uname${parameterEnd} = ${escapedQuote}Linux${escapedQuote} ] ; ` + `then ${PsProcessParser.psLinuxCommand} ; elif [ ${parameterBegin}uname${parameterEnd} = ${escapedQuote}Darwin${escapedQuote} ] ; ` + `then ${PsProcessParser.psDarwinCommand}; fi${innerQuote}${outerQuote}`; }