Closed dpecos closed 6 years ago
Did you forget to call line.Close() before exiting? This behaviour should be the same regardless of whether "SetCtrlCAborts" is set or not.
I already have something like this:
line := liner.NewLiner()
defer line.Close()
line.SetCtrlCAborts(true)
But looks like is not good enough :( . Here you can find the method I'm using it, just in case you would like to have a futher look: https://github.com/dpecos/cmdbox/blob/master/tools/console.go
Thanks!
Ok, I managed to solve my issue: I was deferring line.Close() but I also was executing log.Fatal() within the error handling for line.Prompt, so line.Close() was not being invoked. Using this kind of error handling solved the problem:
text, err := line.Prompt(label)
if err != nil {
if err == liner.ErrPromptAborted {
line.Close()
os.Exit(0)
} else {
log.Fatal(err)
}
}
Thx a lot!