microsoft / vscode-docker-extensibility

Docker for Visual Studio Code: Extensibility Model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shell quoting is not working right

bwateratmsft opened this issue · comments

There are some issues with shell quoting that are preventing it from working correctly in the general case.

  • On Windows, with CMD as the default shell, some commands just fail outright (e.g. list containers)
  • When switching the default shell to PowerShell or pwsh, the command succeeds but the quoting is not correct, resulting in output that doesn't parse right
  • The command runners currently only assume Windows (and only use PowerShell quoting)

This should be fixed by #70

I'll test it out.

It's not quite right still. The commands run successfully but the output is subtly incorrect in some cases, e.g. list containers:

{
    Id:"af3f09061ee7c2971dad80813b912a4a1f1f3d054f1d3074edf64b30e432f85e",
    Names:"agitated_sinoussi",
    Image:"alpine",
    Ports:"",
    Networks:"bridge",
    CreatedAt:"2022-06-22 12:07:43 -0400 EDT",
    State:"exited",
    Status:"Exited (255) 33 minutes ago"
}

It's missing quotes around the property names, it should be:

{
    "Id":"af3f09061ee7c2971dad80813b912a4a1f1f3d054f1d3074edf64b30e432f85e",
    "Names":"agitated_sinoussi",
    "Image":"alpine",
    "Ports":"",
    "Networks":"bridge",
    "CreatedAt":"2022-06-22 12:07:43 -0400 EDT",
    "State":"exited",
    "Status":"Exited (255) 33 minutes ago"
}

Ah, looks like the template formatting needs its own escaping regardless of the shell quoting. Small update to the go template methods should fix the key quoting.