Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rlwrap modifies a line after entering #178

Closed
ser-vasilich opened this issue Apr 11, 2023 · 1 comment
Closed

rlwrap modifies a line after entering #178

ser-vasilich opened this issue Apr 11, 2023 · 1 comment

Comments

@ser-vasilich
Copy link

I have a simple program in Rust that prints a prompt, reads a string, and prints it.
read1line.rs

use std::io::{self, BufRead};
use std::io::Write;

fn main() {
    print!("prompt>");
    let _ = io::stdout().lock().flush();
    let stdin = io::stdin();
    let line = stdin.lock().lines().next().unwrap().unwrap();
    println!("{}",line);
}

When I run the program in terminal and enter line 123, I get the result:

->rustc read1line.rs
->./read1line
prompt>123
123

The result of running in terminal on MacOS with rlwrap:

->uname -v
Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64

->rlwrap ./rea1line
prompt>123    123
123

The result of running in terminal on Ubuntu with rlwrap:

->uname -av
Linux serhii-desktop 5.15.0-47-generic #51-Ubuntu SMP Thu Aug 11 07:51:15 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

->rlwrap ./read1line
123
123

On Linux, the prompt disappears, and on MacOS, there is an extra text as long as the prompt.

@hanslub42
Copy link
Owner

hanslub42 commented Apr 12, 2023

Because rlwrap has to rely on undocumented (and changing) readline behaviour (like the positioning of the cursor right after accepting a line) there have been some problems with bracketed paste mode (which have become much more widespread after readline started enabling this mode by default)

Your Ubuntu problem is a duplicate of #108, your MacOS problem is a duplicate of #168.

To avoid problems, either use the newest readline and rlwrap, or disabe bracketed-paste by putting ...

 set enable-bracketed-paste off

... somewhere in ~/.inputrc

@hanslub42 hanslub42 changed the title rlwrap modifies a row after entering rlwrap modifies a line after entering Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants