compiler: run flash command in a shell

This commit is contained in:
Ayke van Laethem
2018-09-22 01:40:46 +02:00
parent 7517ac86e4
commit 895d109fc4
+3 -7
View File
@@ -174,15 +174,11 @@ func Flash(pkgName, target, port string, printIR, dumpSSA bool, printSizes strin
return Compile(pkgName, ".hex", spec, printIR, dumpSSA, printSizes, func(tmppath string) error { return Compile(pkgName, ".hex", spec, printIR, dumpSSA, printSizes, func(tmppath string) error {
// Create the command. // Create the command.
flashCmd := spec.Flasher flashCmd := spec.Flasher
parts := strings.Split(flashCmd, " ") // TODO: this should be a real shell split flashCmd = strings.Replace(flashCmd, "{hex}", tmppath, -1)
for i, part := range parts { flashCmd = strings.Replace(flashCmd, "{port}", port, -1)
part = strings.Replace(part, "{hex}", tmppath, -1)
part = strings.Replace(part, "{port}", port, -1)
parts[i] = part
}
// Execute the command. // Execute the command.
cmd := exec.Command(parts[0], parts[1:]...) cmd := exec.Command("/bin/sh", "-c", flashCmd)
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
return cmd.Run() return cmd.Run()