-
Notifications
You must be signed in to change notification settings - Fork 184
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
Multiple lines sent on pty input by expect
are not seen by process
#690
Comments
expect
is not seen by process
expect
is not seen by processexpect
are not seen by process
I will try to reproduce. let config = Config::builder()
.behavior(Behavior::PreferTerm)
.build();
let mut rl = DefaultEditor::with_config(config)?; |
Ok, I can reproduce. |
Ok, diff --git a/src/tty/unix.rs b/src/tty/unix.rs
index 23bfcce..70e02f4 100644
--- a/src/tty/unix.rs
+++ b/src/tty/unix.rs
@@ -144,6 +144,7 @@ impl Read for TtyIn {
return Err(error);
}
} else {
+ debug!(target: "rustyline", "read: {:?}", &buf[..res as usize]);
#[allow(clippy::cast_sign_loss)]
return Ok(res as usize);
}
The |
With the following patch, I manage to fix the issue: diff --git a/src/tty/unix.rs b/src/tty/unix.rs
index 23bfcce..ff96dd6 100644
--- a/src/tty/unix.rs
+++ b/src/tty/unix.rs
@@ -229,8 +229,13 @@ impl PosixRawReader {
key_map: PosixKeyMap,
pipe_reader: Option<PipeReader>,
) -> Self {
+ let buffer_size = if config.enable_bracketed_paste() {
+ 1024
+ } else {
+ 1
+ };
Self {
- tty_in: BufReader::with_capacity(1024, TtyIn { fd, sigwinch_pipe }),
+ tty_in: BufReader::with_capacity(buffer_size, TtyIn { fd, sigwinch_pipe }),
timeout_ms: config.keyseq_timeout(),
parser: Parser::new(),
key_map, Or maybe the expect file could be like this:
? |
I think I am running into this issue when I pipe the output of a command with multiple lines into my app that uses rustyline, here is a simulation of my example, I can create a code example if needed. echo "test\ninput" | cargo run rustylineapp Should produce:
but it produces
|
@cosmikwolf For me, this is the expected behaviour when liner % echo "test\ninput" | target/debug/examples/comments history
History file: history
[prompt]
% test
[prompt]
% nput
[prompt]
% exiting... linenoise % echo "test\ninput" | ./linenoise_example
echo: 'test'
echo: 'input' replxx % echo "test\ninput" | ./build/replxx-example-c-api
starting...
thanks for the input: test
thanks for the input: input
Exiting Replxx
|
|
Version 14.0.0 released |
When sending input via
expect
,rustyline
doesn't appear to process anything but the first line.example.expect
Run
expect example.expect
Expected:
Output should be
Num 1
followed byNum 2
.Actual:
Output is just
Num 1
Workaround:
It does work without using
expect
, however:The text was updated successfully, but these errors were encountered: