diff --git a/replacer/main.go b/replacer/main.go index b118af3..e6e2fd1 100644 --- a/replacer/main.go +++ b/replacer/main.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "errors" "io" "log" @@ -70,7 +71,7 @@ func main() { selfext, _ := os.Executable() selfext = path.Base(selfext) - + nextArgs := args[4:] entries, _ := os.ReadDir(args[2]) for _, ent := range entries { if ent.Name() == selfext { @@ -82,7 +83,14 @@ func main() { stdlog.Fatal(err) } } else { - if err := copy(path.Join(args[2], ent.Name()), ent.Name()); err != nil { + if ent.Name() == "@args" { + var tempArgs []string + argfile, _ := os.Open(path.Join(args[2], ent.Name())) + dec := json.NewDecoder(argfile) + if dec.Decode(&tempArgs) == nil { + nextArgs = tempArgs + } + } else if err := copy(path.Join(args[2], ent.Name()), ent.Name()); err != nil { stdlog.Println("copy failed :", path.Join(args[2], ent.Name()), ent.Name()) stdlog.Fatal(err) } @@ -100,6 +108,6 @@ func main() { } stdlog.Println("exec.Command :", args) - cmd := exec.Command(args[3], args[4:]...) + cmd := exec.Command(args[3], nextArgs...) cmd.Start() }