From 732102f7942ec8ad5d55bb023b9c87065848b204 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 11 Feb 2024 04:09:48 -0600 Subject: [PATCH] all of this is terrible Signed-off-by: Jeff Carr --- run.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/run.go b/run.go index ed62f61..4e03ac2 100644 --- a/run.go +++ b/run.go @@ -21,9 +21,25 @@ var msecDelay int = 20 // check every 20 milliseconds // use go-cmd instead here? // exiterr.Sys().(syscall.WaitStatus) +// run command and return it's output +func RunCapture(cmdline string) string { + test := New() + test.Exec(cmdline) + return Chomp(test.Buffer) +} + +func RunWait(args []string) *Shell { + test := New() + cmdline := strings.Join(args, " ") + test.Exec(cmdline) + return test +} + // var newfile *shell.File func RunString(args string) bool { - return false + // return false + parts := strings.Split(args, " ") + return Run(parts) } func Run(args []string) bool { @@ -36,6 +52,7 @@ func Run(args []string) bool { return RunPath(dir, args) } +// run, but set the working path func RunPath(path string, args []string) bool { if len(args) == 0 { log.Warn("command line was empty")