summaryrefslogtreecommitdiff
path: root/util/autoport/log_maker.go
diff options
context:
space:
mode:
Diffstat (limited to 'util/autoport/log_maker.go')
-rw-r--r--util/autoport/log_maker.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/util/autoport/log_maker.go b/util/autoport/log_maker.go
index b991ea715d..e2440b4891 100644
--- a/util/autoport/log_maker.go
+++ b/util/autoport/log_maker.go
@@ -9,7 +9,7 @@ import (
"strings"
)
-func RunAndSave(output string, name string, arg ...string) {
+func TryRunAndSave(output string, name string, arg []string) error {
cmd := exec.Command(name, arg...)
f, err := os.Create(output)
@@ -22,9 +22,27 @@ func RunAndSave(output string, name string, arg ...string) {
err = cmd.Start()
if err != nil {
- log.Fatal(err)
+ return err
}
cmd.Wait()
+ return nil
+}
+
+func RunAndSave(output string, name string, arg ...string) {
+ err := TryRunAndSave(output, name, arg)
+ if err == nil {
+ return
+ }
+ idx := strings.LastIndex(name, "/")
+ relname := name
+ if idx >= 0 {
+ relname = name[idx+1:]
+ }
+ relname = "./" + relname
+ err = TryRunAndSave(output, relname, arg)
+ if err != nil {
+ log.Fatal(err)
+ }
}
func MakeLogs(outDir string) {