From 6c8db92ff0f2a8f65172219cb3fc2b8b9538fac1 Mon Sep 17 00:00:00 2001 From: Fabian Seidl <fabian.seidl@h-da.de> Date: Tue, 5 Sep 2023 10:08:25 +0000 Subject: [PATCH] Resolve "Exiting gosdnc causes the input in cli to be invisble" See merge request danet/gosdn!536 --- cli/cmd/prompt.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cli/cmd/prompt.go b/cli/cmd/prompt.go index 97f05b906..af3559c09 100644 --- a/cli/cmd/prompt.go +++ b/cli/cmd/prompt.go @@ -33,6 +33,7 @@ package cmd import ( "os" + "os/exec" "strings" "code.fbi.h-da.de/danet/gosdn/cli/completer" @@ -42,6 +43,7 @@ import ( "github.com/openconfig/goyang/pkg/yang" "github.com/pterm/pterm" "github.com/pterm/pterm/putils" + "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" @@ -386,8 +388,16 @@ var exitCmd = &cobra.Command{ Long: `The exit command exits the interactive prompt mode.`, RunE: func(cmd *cobra.Command, args []string) error { - os.Exit(0) + rawModeOff := exec.Command("/bin/stty", "-raw", "echo") + rawModeOff.Stdin = os.Stdin + err := rawModeOff.Run() + if err != nil { + logrus.Error(err) + os.Exit(1) + } + + os.Exit(0) return nil }, } -- GitLab