Skip to content

Automatic parameter escaping in syscall.StarProcess on windows is too restrictive #1849

Closed
@vanackere

Description

Windows parameters are transmitted as a single string and it is the responsibility of
each program to do it's own parameter parsing.

Microsoft's C startup code (http://msdn.microsoft.com/en-us/library/ms880421) defines a
standard way for C programs to split the command line into separate arguments and go's
syscall.StartProcess does the correct escaping for those cases.

However, some programs - and most notably the cmd.exe shell - do their own command line
parameter parsing. As an example, if passed the following arguments :
  cmd /s /c "cd "C:\Program Files" && dir"
then cmd.exe will parse its arguments as follows :
  /s
  /c
  cd "C:\Program Files" && dir

See http://ss64.com/nt/cmd.html (see section on /C or /K flags which describes the logic
used to process quote (") characters).

The bug is that there is currently no way to prevent escaping of command line parameters
and therefore no way to execute the previous command from syscall.StartProcess because
the double quotes in the last argument are automatically escaped...

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions