aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec/exec.go
diff options
context:
space:
mode:
authorGiovanni Bajo <rasky@develer.com>2018-08-31 23:34:39 +0200
committerGiovanni Bajo <rasky@develer.com>2018-09-01 04:45:46 +0000
commit1d15354fb931a81a66fdc4a6101df711bd738a4b (patch)
tree0e2aadc4a11deafa7028a70e7903c514fbfb0b21 /src/os/exec/exec.go
parent579768e0785f14032e3a971ad03f2deb33427e2d (diff)
downloadgo-1d15354fb931a81a66fdc4a6101df711bd738a4b.tar.gz
go-1d15354fb931a81a66fdc4a6101df711bd738a4b.zip
os/exec: document how to do special args quoting on Windows
Updates #27199 Change-Id: I5cb6540266901697d3558ce75b8de63b1bfc2ce0 Reviewed-on: https://go-review.googlesource.com/132695 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Diffstat (limited to 'src/os/exec/exec.go')
-rw-r--r--src/os/exec/exec.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go
index 88b0a91699..1aa3ab93dc 100644
--- a/src/os/exec/exec.go
+++ b/src/os/exec/exec.go
@@ -152,6 +152,15 @@ type Cmd struct {
// followed by the elements of arg, so arg should not include the
// command name itself. For example, Command("echo", "hello").
// Args[0] is always name, not the possibly resolved Path.
+//
+// On Windows, processes receive the whole command line as a single string
+// and do their own parsing. Command combines and quotes Args into a command
+// line string with an algorithm compatible with applications using
+// CommandLineToArgvW (which is the most common way). Notable exceptions are
+// msiexec.exe and cmd.exe (and thus, all batch files), which have a different
+// unquoting algorithm. In these or other similar cases, you can do the
+// quoting yourself and provide the full command line in SysProcAttr.CmdLine,
+// leaving Args empty.
func Command(name string, arg ...string) *Cmd {
cmd := &Cmd{
Path: name,