sys - amend RunInteractiveCmd

This commit is contained in:
Mahdi Abu Yasmine 2023-11-07 02:12:48 +01:00
parent bb1c03b1a1
commit 39fdda840c

View File

@ -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())
}