replace에 다음 실행 파라미터도 넘길 수 있음
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@ -70,7 +71,7 @@ func main() {
|
|||||||
|
|
||||||
selfext, _ := os.Executable()
|
selfext, _ := os.Executable()
|
||||||
selfext = path.Base(selfext)
|
selfext = path.Base(selfext)
|
||||||
|
nextArgs := args[4:]
|
||||||
entries, _ := os.ReadDir(args[2])
|
entries, _ := os.ReadDir(args[2])
|
||||||
for _, ent := range entries {
|
for _, ent := range entries {
|
||||||
if ent.Name() == selfext {
|
if ent.Name() == selfext {
|
||||||
@ -82,7 +83,14 @@ func main() {
|
|||||||
stdlog.Fatal(err)
|
stdlog.Fatal(err)
|
||||||
}
|
}
|
||||||
} else {
|
} 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.Println("copy failed :", path.Join(args[2], ent.Name()), ent.Name())
|
||||||
stdlog.Fatal(err)
|
stdlog.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -100,6 +108,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stdlog.Println("exec.Command :", args)
|
stdlog.Println("exec.Command :", args)
|
||||||
cmd := exec.Command(args[3], args[4:]...)
|
cmd := exec.Command(args[3], nextArgs...)
|
||||||
cmd.Start()
|
cmd.Start()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user