From 2e4b7811db8d1accfbd31099e5b4edbd0490086e Mon Sep 17 00:00:00 2001 From: mountain Date: Wed, 14 Jun 2023 01:50:25 +0900 Subject: [PATCH] =?UTF-8?q?replace=EC=97=90=20=EB=8B=A4=EC=9D=8C=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0?= =?UTF-8?q?=EB=8F=84=20=EB=84=98=EA=B8=B8=20=EC=88=98=20=EC=9E=88=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- replacer/main.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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() }