summaryrefslogtreecommitdiff
path: root/cmd.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd.go')
-rw-r--r--cmd.go40
1 files changed, 17 insertions, 23 deletions
diff --git a/cmd.go b/cmd.go
index c3a861a..d20ad2b 100644
--- a/cmd.go
+++ b/cmd.go
@@ -2,7 +2,7 @@ package shell
import (
"errors"
- "fmt"
+ "os"
"time"
"github.com/go-cmd/cmd"
@@ -139,6 +139,21 @@ func RunRealtime(args []string) cmd.Status {
return PathRunRealtime("", args)
}
+func RunEcho(cmd []string) cmd.Status {
+ result := RunQuiet(cmd)
+ pwd, _ := os.Getwd()
+ log.Warn("shell.RunEcho() cmd:", cmd, pwd)
+ log.Warn("shell.RunEcho() Exit:", result.Exit)
+ log.Warn("shell.RunEcho() Error:", result.Error)
+ for _, line := range result.Stdout {
+ log.Warn("STDOUT:", line)
+ }
+ for _, line := range result.Stderr {
+ log.Warn("STDERR:", line)
+ }
+ return result
+}
+
// echos twice a second if anything sends to STDOUT or STDERR
// not great, but it's really just for watching things run in real time anyway
// TODO: fix \r handling for things like git-clone so the terminal doesn't
@@ -210,29 +225,8 @@ func PathRunRealtime(pwd string, args []string) cmd.Status {
// Block waiting for command to exit, be stopped, or be killed
finalStatus := <-statusChan
+ log.Info("shell.Run() notsure finalStatus", finalStatus.Cmd)
return findCmd.Status()
- return finalStatus
-}
-
-func blah(cmd []string) {
- r := Run(cmd)
- log.Info("cmd =", r.Cmd)
- log.Info("complete =", r.Complete)
- log.Info("exit =", r.Exit)
- log.Info("err =", r.Error)
- log.Info("len(stdout+stderr) =", len(r.Stdout))
-}
-
-// run these to see confirm the sytem behaves as expected
-func RunTest() {
- blah([]string{"ping", "-c", "3", "localhost"})
- blah([]string{"exit", "0"})
- blah([]string{"exit", "-1"})
- blah([]string{"true"})
- blah([]string{"false"})
- blah([]string{"grep", "root", "/etc/", "/proc/cmdline", "/usr/bin/chmod"})
- blah([]string{"grep", "root", "/proc/cmdline"})
- fmt.Sprint("blahdone")
}
// this is stuff from a long time ago that there must be a replacement for