Skip to content

Conversation

@WardenGnaw
Copy link
Contributor

Allowing quoteArgs to handle the pipeProgram and pipeArgs quotes.

Moving the uname and ps command into a temp file so it can be redirected into the pipeProgram so the current shell does not mangle the command string.

Tested:
Windows -> Linux
Windows -> Docker Linux
Windows -> Mac
Mac -> Linux

  • Fixing configuration snippet formatting

Also moved list process command to be written to a temp file and
redirected to the pipeProgram.
pipeCmdList.push(pipeProgram);
pipeCmdList = pipeCmdList.concat(pipeArgs);

const scriptShellCmdList: string[] = ["bash", "-s"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bash [](start = 51, length = 4)

I am not sure it really matters much for .NET, but should we use 'sh' instead of 'bash' to make it easier to port code between this extension and C++?

pipeCmdList.push(pipeProgram);
pipeCmdList = pipeCmdList.concat(pipeArgs);

const scriptShellCmdList: string[] = ["bash", "-s"];
Copy link
Contributor

@gregg-miskelly gregg-miskelly Apr 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scriptShellCmdList [](start = 18, length = 18)

Maybe I am remembering wrong, but I think we are doing something different here than what vsdbg-ui does.

In vsdbg-ui, if quoteArgs is enabled the command line would be something like:

/mypipePath/myPipe -myPipeArg "/vsdbg/vsdbg --interpreter=vscode"

Here, it looks like we will wind up using:
/mypipePath/myPipe -myPipeArg /vsdbg/vsdbg --interpreter=vscode

And we would only quote an argument if one of the individual arguments contained a space.

I think instead you want:

let scriptShellCmd : string = "bash -s";

if (quoteArgs) {
   scriptShellCmd = `"${scriptShellCmd}"`;
}

let pipeCmd: string = `"${pipeProgram}" ${argList}`;
let pipeCmdList: string[] = [];
pipeCmdList.push(pipeProgram);
pipeCmdList = pipeCmdList.concat(pipeArgs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pipeArgs [](start = 45, length = 8)

We need code to look for ${debuggerCommand}


// Create a temp file to redirect commands to the pipeProgram to solve quoting issues.
const tempFile = tmp.fileSync();
fs.write(tempFile.fd, command);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a temp file with this, should we should stick this in a file in our extension?

Fixing syntax since = is for equality in sh.

Also tested with Mac -> Linux w/ ZSH

return execChildProcessAndOutputErrorToChannel(`${pipeCmd} < ${tempFile.name}`, null, RemoteAttachPicker._channel).then(output => {
// Remove temp file since the uname and ps commands have been executed.
tempFile.removeCallback();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tempFile [](start = 12, length = 8)

If we keep this, make sure to add a catch handler to clean it up in the case of failure as well.

Copy link
Contributor

@gregg-miskelly gregg-miskelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments


pipeCmdList = pipeCmdList.concat(scriptShellCmdList);

let pipeCmd: string = quoteArgs ? this.createArgumentList(pipeCmdList) : pipeCmdList.join(' ');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I modify createArgumentList to only insert quotes if it has a space in the string?

@@ -0,0 +1 @@
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 No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we don't need to have this as one big line, would it make sense to separate this out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there will be issues with \r\n vs \n if its separated on different lines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are probably right. Oh line endings...

@gregg-miskelly
Copy link
Contributor

RE: Should I modify createArgumentList to only insert quotes if it has a space in the string?
A: I think so. The closer we can be to vsdbg-ui the better.

@@ -0,0 +1 @@
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 No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a .gitattributes on this to make sure that it keeps Unix line endings?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can 'Won't fix" this one since the script is a single line.

pipeCmdList.push(pipeProgram);

// Remove debuggerCommand for remoteProcessPicker
pipeCmdList = pipeCmdList.concat(pipeArgs.filter(arg => arg !== "${debuggerCommand}"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work, as ${debuggerCommand} might be only part of one of the args, and because we want to preserve the order.

Copy link
Contributor

@gregg-miskelly gregg-miskelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise I think you have it.

if (pipeArgs.filter(arg => arg === "${debuggerCommand}").length > 0) {
for (let arg of pipeArgs)
{
if (arg === "${debuggerCommand}")
Copy link
Contributor

@gregg-miskelly gregg-miskelly Apr 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be:

     while (arg.indexOf("${debuggerCommand}") >= 0) {
            arg = arg.replace("${debuggerCommand}", scriptShellCmd);
        }

pipeCmdList.push(pipeProgram);

pipeCmdList.push(scriptShellCmd);
if (pipeArgs.filter(arg => arg === "${debuggerCommand}").length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace: arg === "${debuggerCommand}"
With: arg.indexOf("${debuggerCommand}") >= 0


const debuggerCommandString: string = "${debuggerCommand}";

if (pipeArgs.indexOf(debuggerCommandString) > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>= not >

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And don't you still need your filter like you did before?

Copy link
Contributor

@gregg-miskelly gregg-miskelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@WardenGnaw WardenGnaw merged commit 90c6d3b into dotnet:master Apr 11, 2017
@WardenGnaw WardenGnaw deleted the dev/waan/fixremoteprocesspick branch April 11, 2017 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants