diff options
| author | Jeff Carr <[email protected]> | 2025-01-12 06:35:36 -0600 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-12 06:35:36 -0600 | 
| commit | 1534b9fbbcd883b5820d53c86e4923185574cfe0 (patch) | |
| tree | 788e72f2954cbd1621dc2cf73b11c0792083d85c | |
| parent | d5f45aef137c6298b6092e160bd1fb2476b5062f (diff) | |
shell exec for 'forge commit'v0.22.21
| -rw-r--r-- | exec.go | 48 | 
1 files changed, 48 insertions, 0 deletions
@@ -0,0 +1,48 @@ +package shell + +import ( +	"errors" +	"os" +	"os/exec" + +	"go.wit.com/log" +) + +func Exec(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.Stderr = os.Stderr +	process.Stdin = os.Stdin +	process.Stdout = os.Stdout +	process.Start() +	err := process.Wait() +	log.Log(INFO, "shell.Exec() err =", err) +	return nil +} + +func ExecCheck(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.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 +}  | 
