From 2b1f7f54d5585d69c4372f0005ecdd2db5351000 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 14 Feb 2025 18:40:31 -0600 Subject: [PATCH] testing for using 'sudo' --- exec.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/exec.go b/exec.go index c5fb298..49294d2 100644 --- a/exec.go +++ b/exec.go @@ -49,6 +49,28 @@ func ExecCheck(args []string) error { return nil } +func PathExecVerbose(path string, args []string) error { + if len(args) == 0 { + return errors.New("Error: Command slice is empty.") + } + + // Start a long-running process, capture stdout and stderr + a, b := RemoveFirstElement(args) + + process := exec.Command(a, b...) + process.Dir = path + process.Stderr = os.Stderr + process.Stdin = os.Stdin + process.Stdout = os.Stdout + err := process.Run() + if err != nil { + log.Info("ExecCheck() err", err) + return err + } + // log.Info("ExecCheck() nil") + return nil +} + func SudoRaw(c []string) { args := []string{"-S"} args = append(args, c...)