Skip to content

pickRemoteProcess SSH command variable local expansion bug #2585

@ghost

Description

While testing an attach type debugger configuration with SSH as pipeTransport on macOS/VSCode and remote target is Ubuntu Linux I found out that the pickRemoteProcess command will pick and expand the local $(uname) value instead of the remote one so the "if" statement will execute the "Darwin" "ps" command on the remote Linux target which will fail because of unsupported Linux ps command options

Command failed: "/usr/bin/ssh" "-i" "/Users/xxxx/.ssh/xxx_id_rsa" "xxx@xxxx" "sh -c 'uname && if [ $(uname) = "Linux" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = "Darwin" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi'"
error: can not use output modifiers with user-defined output

Usage:
ps [options]

Try 'ps --help <simple|list|output|threads|misc|all>'
or 'ps --help <s|l|o|t|m|a>'
for additional help text.

For more details see ps(1).

You just need to escape any variables inside the SSH command with a backslash "\"
so it's not expanded locally

"sh -c 'uname && if [ \$(uname) = "Linux" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ \$(uname) = "Darwin" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi'"
  • OS and Version: macOS 10.14
  • VS Code Version: 1.27.2
  • C/C++ Extension Version: 0.19.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    debuggerfixedCheck the Milestone for the release in which the fix is or will be available.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions