From a84aa225ab3bbea69d2427a69c9875398f5f2cfc Mon Sep 17 00:00:00 2001 From: niten94 <127052329+niten94@users.noreply.github.com> Date: Sat, 22 Jun 2024 21:21:13 +0800 Subject: [PATCH] Return error with start in RunInteractiveShell Print and return error with process start in RunInteractiveShell if process was not able to be started. Wait until enter is pressed even if `wait` is false. Co-authored-by: Dmitry Maluka --- internal/shell/shell.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/shell/shell.go b/internal/shell/shell.go index 5bf5973f..9149da9f 100644 --- a/internal/shell/shell.go +++ b/internal/shell/shell.go @@ -101,16 +101,19 @@ func RunInteractiveShell(input string, wait bool, getOutput bool) (string, error c := make(chan os.Signal, 1) signal.Reset(os.Interrupt) signal.Notify(c, os.Interrupt) - cmd.Start() - err = cmd.Wait() + err = cmd.Start() + if err == nil { + err = cmd.Wait() + if wait { + // This is just so we don't return right away and let the user press enter to return + screen.TermMessage("") + } + } else { + screen.TermMessage(err) + } output := outputBytes.String() - if wait { - // This is just so we don't return right away and let the user press enter to return - screen.TermMessage("") - } - // Start the screen back up screen.TempStart(screenb)