Open
Description
Go 1.7.1 on windows-amd64, Windows 10 latest.
Consider a test project:
src/github.com/calmh/wincmdtest/
main.go
folder name/
test.bat
main.go
contents:
package main
import (
"fmt"
"os/exec"
"strings"
)
func main() {
execCmd("./folder name/test.bat")
execCmd("./folder name/test.bat", "one param")
}
func execCmd(path string, args ...string) {
fmt.Printf("Running: %q %q\n", path, strings.Join(args, " "))
cmd := exec.Command(path, args...)
bs, err := cmd.CombinedOutput()
fmt.Printf("Output: %s", bs)
fmt.Printf("Error: %v\n\n", err)
}
folder name/test.bat
contents:
@echo off
echo Success
Expected output is two runs with "Success" in them.
Actual:
C:\Users\jb\Go\src\github.com\calmh\wincmdtest>go run main.go
Running: "./folder name/test.bat" ""
Output: Success
Error: <nil>
Running: "./folder name/test.bat" "one param"
Output: '.' is not recognized as an internal or external command,
operable program or batch file.
Error: exit status 1
It appears that having params on a command, where the command contains a space, breaks the parsing of it. I haven't been able to work around this by experimenting with various ways of quoting the command, using backslashes or slashes, etc.