conradkleinespel / rpassword

Cross platform Rust library to read a password in the terminal (Linux, BSD, OSX, Windows, WASM).
Apache License 2.0
244 stars 38 forks source link

Ctrl+C in zsh shell leads to a staying extra empty line in prompt on macOS #59

Closed nmlt closed 3 years ago

nmlt commented 3 years ago

I created a new user, installed minimal rust and wrote this little program:

testtest@MacBook ~ % cd rpass
testtest@MacBook rpass % cat src/main.rs
fn main() {
    println!("Hello, world!");
    rpassword::read_password().unwrap();
}
testtest@MacBook rpass %
testtest@MacBook rpass % cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/rpass`
Hello, world!

testtest@MacBook rpass %

testtest@MacBook rpass %

Between the first command and the next there is no empty line. Afther the "Hello, world!" print, I pressed Ctrl+C. When I then pressed enter there is an empty line between the two prompt lines.

I tested zsh 5.7 and 5.8 (via brew) on macOS Catalina, both Terminal.app and iTerm2.app.

On the other hand it's not really problematic to fix it, just open a new tab.

conradkleinespel commented 3 years ago

Hello @nmlt, thanks for reporting ! :+1: I do not currently have time to look into this because it seems non-critical, so I'm going to close the issue. Feel free to open a PR with a fix and a test case if this bothers you.

conradkleinespel commented 3 years ago

@nmlt Actually, I might think this is problematic. Currently rpassword does not handle signals. But I'm working on some updates in this repo: https://github.com/conradkleinespel/duck. It makes use of the Drop trait to restore the terminal, which should be more reliable.

I'm not 100% sure that this repo is usable from the outside yet, but you could try using rpassword like this:

[dependencies]
rpassword = { git = "https://github.com/conradkleinespel/duck.git" }

I'll try to publish an updated version within a few weeks (want to test a bit more first).

nmlt commented 3 years ago

Using rpassword from your mono repo worked fine for me, but the problem persisted.

You're absolutely right that it is not really a very pressing problem and I have no idea what could cause this. I just found it a curious problem.

Something I forgot to mention: it doesn't happen on bash on macOS (v3.2.57(1)) and also not on linux zsh version 5.0.2

conradkleinespel commented 3 years ago

Good to know that the monorepo works, thanks a lot for testing! :+1:

Back to this bug, I'm really not sure what could be causing it and unfortunately I don't have access to a Mac. If you want to make a PR with a test case I'll be happy to review it, for now I'm going to close this issue.