Shell quoting is not working right
bwateratmsft opened this issue · comments
Brandon Waterloo [MSFT] commented
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)
David Negstad commented
This should be fixed by #70
Brandon Waterloo [MSFT] commented
I'll test it out.
Brandon Waterloo [MSFT] commented
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"
}
David Negstad commented
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.