input -s
does not append newline when user finished typing #14902
Open
Description
Describe the bug
the first writing to stdout after input -s
will print on the same line as the input prompt, whereas normal input
would append a new line char at the end of user input so that subsequent stdout write is shown on a new line.
Looking at the source code, these lines appears to cause such behavior, which are added in this PR. It seems like a deliberate choice to not appending "\n" when -s
specified, but I don't quite understand the rationale, and IMHO the current behavior breaks the ordinary use cases for using -s
, see "How to reproduce" for example.
How to reproduce
The following two snippets show the difference (assuming user types "ABC" in both cases):
❯ let x = (input "your password: ") ; print "<output_from_subsequent_command>"
your password: mysecretpass
<output_from_subsequent_command>
❯ let x = (input -s "your password: ") ; print "<output_from_subsequent_command>"
your password: <output_from_subsequent_command>
Expected behavior
input
always appends a newline at the end of user input
Configuration
key | value |
---|---|
version | 0.101.0 |
major | 0 |
minor | 101 |
patch | 0 |
branch | |
commit_hash | |
build_os | linux-x86_64 |
build_target | x86_64-unknown-linux-gnu |
rust_version | rustc 1.83.0 (90b35a623 2024-11-26) (built from a source tarball) |
cargo_version | cargo 1.83.0 (5ffbef321 2024-10-29) |
build_time | 1980-01-01 00:00:00 +00:00 |
build_rust_channel | release |
allocator | mimalloc |
features | default, sqlite, trash |
installed_plugins |