Skip to content

Commit

Permalink
Fix remote process listing #1208 (#1209)
Browse files Browse the repository at this point in the history
* Fix remote process listing #1208

The zshell fix had the unintended problem that '$(uname)' was getting evaluated locally before being sent over the pipe, which meant that remote process listing didn't work from macOS to Linux. This fixes it.

* Fix Windows client case
  • Loading branch information
gregg-miskelly committed Feb 9, 2017
1 parent add9a96 commit 1ba11cd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/features/processPicker.ts
Expand Up @@ -117,8 +117,13 @@ export class RemoteAttachPicker {
}

public static getRemoteOSAndProcesses(pipeCmd: string): Promise<AttachItem[]> {

// If the client OS is NOT Windows, we need to escape '$(uname)' as otherwise it will be evaluated on the client side
// If the client OS is Windows, we don't want to do that as it will be sent as-is, and thus the if statement will be broken
const remoteUnameCommand = os.platform() !== "win32" ? "$\\(uname\\)" : "$(uname)";

// Commands to get OS and processes
const command = `bash -c 'uname && if [ $(uname) == "Linux" ] ; then ${RemoteAttachPicker.linuxPsCommand} ; elif [ $(uname) == "Darwin" ] ; ` +
const command = `bash -c 'uname && if [ "${remoteUnameCommand}" == "Linux" ] ; then ${RemoteAttachPicker.linuxPsCommand} ; elif [ "${remoteUnameCommand}" == "Darwin" ] ; ` +
`then ${RemoteAttachPicker.osxPsCommand}; fi'`;

return execChildProcessAndOutputErrorToChannel(`${pipeCmd} "${command}"`, null, RemoteAttachPicker._channel).then(output => {
Expand Down

0 comments on commit 1ba11cd

Please sign in to comment.