diff options
Diffstat (limited to 'unix.go')
| -rw-r--r-- | unix.go | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -102,3 +102,38 @@ func splitVersion(version string) (a, b, c string) { return parts[0], parts[1], parts[2] } } + +func runCmd(path string, parts []string) (bool, string) { + if len(parts) == 0 { + log.Warn("command line was empty") + return false, "" + } + if parts[0] == "" { + log.Warn("command line was empty") + return false, "" + } + thing := parts[0] + parts = parts[1:] + + log.Warn("path =", path, "thing =", thing, "cmdline =", parts) + // Create the command + cmd := exec.Command(thing, parts...) + + // Set the working directory + cmd.Dir = fullpath(path) + + // Execute the command + output, err := cmd.CombinedOutput() + if err != nil { + log.Error(err) + log.Warn("output was", output) + log.Warn("cmd exited with error", err) + return false, string(output) + } + + tmp := string(output) + tmp = strings.TrimSpace(tmp) + + // Print the output + return true, tmp +} |
