peterh / liner

Pure Go line editor with history, inspired by linenoise
MIT License
1.05k stars 132 forks source link

Ctrl-C in PasswordPrompt does not return ErrPromptAborted. #31

Closed cmcoffee closed 9 years ago

cmcoffee commented 9 years ago

Using PasswordPrompt with SetCtrlCAborts(true) doesn't result in liner.ErrPromptAborted as expected, instead results in an "liner: internal error" error.

peterh commented 9 years ago

I can't reproduce this.

What platform? What exact keystrokes reproduce this?

cmcoffee commented 9 years ago

go version go1.4 darwin/ad64 Keystrokes are ctrl-c, Prompt doesn't create the issue, only PasswordPrompt.

func main() {
    cli := liner.NewLiner()
    cli.SetCtrlCAborts(true)

    for {
        input, err := cli.PasswordPrompt("Test Password Prompt: ")
        fmt.Println(input, err, "\n")
        input, err = cli.Prompt("Test Prompt: ")
        fmt.Println(input, err, "\n")
        if input == "exit" {
            cli.Close()
            break;
        }
    }
}

Test Password Prompt: Test Password Prompt: liner: internal error

Test Prompt: ^C prompt aborted

peterh commented 9 years ago

PasswordPrompt, not Prompt. It was in both the title and the body, and I still somehow managed to read it as Prompt each time.

Thanks for the bug report. There will be a fix soon.