From 39fdda840c12ae5fa81fe3f1da97a685bb382b87 Mon Sep 17 00:00:00 2001 From: mahdi Date: Tue, 7 Nov 2023 02:12:48 +0100 Subject: [PATCH] sys - amend RunInteractiveCmd --- sys/sys.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/sys.go b/sys/sys.go index 3f20fe0..e76b876 100644 --- a/sys/sys.go +++ b/sys/sys.go @@ -59,13 +59,17 @@ func ManageStatusCmd(cmd *exec.Cmd, err error) int { return -1 } -func RunInteractiveCmd(cmd string, withStderr bool) int { +func RunInteractiveCmd(cmd string, withStderr bool, buffers ...io.Writer) int { // fmt.Printf(" == go before command : %s\n", cmd) icmd := exec.Command("bash", "-c", cmd) icmd.Stdin = os.Stdin icmd.Stdout = os.Stdout if withStderr { - icmd.Stderr = os.Stderr + if len(buffers) > 0 { + icmd.Stderr = buffers[0] + } else { + icmd.Stderr = os.Stderr + } } return ManageStatusCmd(icmd, icmd.Run()) }