diff options
| author | Jeff Carr <[email protected]> | 2024-03-21 16:17:31 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-03-21 16:17:31 -0500 |
| commit | 16715e0252c5b545e5e6d3dabef169ec5fce5305 (patch) | |
| tree | 9f96888070284e728970bcb981e393324ee965c1 | |
| parent | ec6f0a17781a279470eadce634513f37b27e59cb (diff) | |
make an exec to STDOUT
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | run.go | 41 |
1 files changed, 21 insertions, 20 deletions
@@ -46,7 +46,7 @@ func Run(args []string) bool { } r := RunPath(dir, args) - if r.ok { + if r.Ok { return true } return false @@ -55,27 +55,27 @@ func Run(args []string) bool { var ErrorArgvEmpty error = errors.New("command was empty") type RunResult struct { - ok bool - argv []string - path string - output []byte - err error - outerr error + Ok bool + Argv []string + Path string + Output []byte + Err error + Outerr error } // run, but set the working path func RunPath(path string, args []string) *RunResult { r := new(RunResult) - r.path = path - r.argv = args + r.Path = path + r.Argv = args if len(args) == 0 { - r.ok = true - r.err = ErrorArgvEmpty + r.Ok = true + r.Err = ErrorArgvEmpty return r } if args[0] == "" { - r.ok = false - r.err = ErrorArgvEmpty + r.Ok = false + r.Err = ErrorArgvEmpty return r } thing := args[0] @@ -84,6 +84,7 @@ func RunPath(path string, args []string) *RunResult { cmd.Dir = path cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr + log.Info("path =", path, "cmd =", strings.Join(args, " ")) if err := cmd.Run(); err != nil { // Handle error if the command execution fails @@ -95,16 +96,16 @@ func RunPath(path string, args []string) *RunResult { // log.Info("path =", path) // log.Info("args =", args) // log.Info("err =", err.Error()) - r.ok = false - r.err = err - r.output = out - r.outerr = outerr + r.Ok = false + r.Err = err + r.Output = out + r.Outerr = outerr return r } out, outerr := cmd.Output() - r.output = out - r.outerr = outerr - r.ok = true + r.Output = out + r.Outerr = outerr + r.Ok = true return r } |
