From 631188c626bf81d52421aea5315c04808bca9049 Mon Sep 17 00:00:00 2001 From: kortschak Date: Thu, 21 Aug 2014 15:55:05 +0930 Subject: [PATCH] Fix error in REPL term shutdown leaving tty unsane Previously we did not close the liner term unless a SIGINT or SIGKILL was received. This left the terminal in raw. Fix that. --- db/repl.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/db/repl.go b/db/repl.go index ac36ea4..da3aff9 100644 --- a/db/repl.go +++ b/db/repl.go @@ -104,6 +104,7 @@ func Repl(h *graph.Handle, queryLanguage string, cfg *config.Config) error { line, err := term.Prompt(prompt) if err != nil { if err == io.EOF { + fmt.Println() return nil } return err @@ -170,9 +171,7 @@ func terminal(path string) (*liner.State, error) { signal.Notify(c, os.Interrupt, os.Kill) <-c - persist(term, history) - - err := term.Close() + err := persist(term, history) if err != nil { fmt.Fprintf(os.Stderr, "failed to properly clean up terminal: %v\n", err) os.Exit(1) @@ -200,5 +199,5 @@ func persist(term *liner.State, path string) error { if err != nil { return fmt.Errorf("could not write history to %q: %v", path, err) } - return nil + return term.Close() }