Merge pull request #132 from kortschak/repl
Fix error in REPL term shutdown leaving tty unsane
This commit is contained in:
commit
c8c7f1ff8c
1 changed files with 3 additions and 4 deletions
|
|
@ -104,6 +104,7 @@ func Repl(h *graph.Handle, queryLanguage string, cfg *config.Config) error {
|
||||||
line, err := term.Prompt(prompt)
|
line, err := term.Prompt(prompt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
fmt.Println()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
@ -170,9 +171,7 @@ func terminal(path string) (*liner.State, error) {
|
||||||
signal.Notify(c, os.Interrupt, os.Kill)
|
signal.Notify(c, os.Interrupt, os.Kill)
|
||||||
<-c
|
<-c
|
||||||
|
|
||||||
persist(term, history)
|
err := persist(term, history)
|
||||||
|
|
||||||
err := term.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed to properly clean up terminal: %v\n", err)
|
fmt.Fprintf(os.Stderr, "failed to properly clean up terminal: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
@ -200,5 +199,5 @@ func persist(term *liner.State, path string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not write history to %q: %v", path, err)
|
return fmt.Errorf("could not write history to %q: %v", path, err)
|
||||||
}
|
}
|
||||||
return nil
|
return term.Close()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue