From f26d3bf8d7fc600843cdcf7cabfe8859828af948 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Tue, 17 May 2022 09:27:12 -0500 Subject: [PATCH] make print flush (#5566) --- crates/nu-cli/src/print.rs | 1 - crates/nu-protocol/src/pipeline_data.rs | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/nu-cli/src/print.rs b/crates/nu-cli/src/print.rs index 6dc823d7c..626577c8d 100644 --- a/crates/nu-cli/src/print.rs +++ b/crates/nu-cli/src/print.rs @@ -37,7 +37,6 @@ impl Command for Print { ) -> Result { let args: Vec = call.rest(engine_state, stack, 0)?; let no_newline = call.has_flag("no_newline"); - let head = call.head; for arg in args { diff --git a/crates/nu-protocol/src/pipeline_data.rs b/crates/nu-protocol/src/pipeline_data.rs index d65bfcf2c..4441679ae 100644 --- a/crates/nu-protocol/src/pipeline_data.rs +++ b/crates/nu-protocol/src/pipeline_data.rs @@ -437,6 +437,7 @@ impl PipelineData { if let Some(stream) = stream { for s in stream { let _ = stdout.lock().write_all(s?.as_binary()?); + let _ = stdout.lock().flush()?; } } @@ -475,7 +476,9 @@ impl PipelineData { } match stdout.lock().write_all(out.as_bytes()) { - Ok(_) => (), + Ok(_) => { + let _ = stdout.lock().flush()?; + } Err(err) => eprintln!("{}", err), }; } @@ -498,7 +501,9 @@ impl PipelineData { } match stdout.lock().write_all(out.as_bytes()) { - Ok(_) => (), + Ok(_) => { + let _ = stdout.lock().flush()?; + } Err(err) => eprintln!("{}", err), }; }