From d0e636ae7a36873e3e9795ca325904e39a0d7d4f Mon Sep 17 00:00:00 2001 From: Reilly Wood <26268125+rgwood@users.noreply.github.com> Date: Tue, 5 Apr 2022 10:52:09 -0700 Subject: [PATCH] Trim newline from `input` results (#5097) --- crates/nu-command/src/platform/input.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/platform/input.rs b/crates/nu-command/src/platform/input.rs index 45ffbf468..36bccad64 100644 --- a/crates/nu-command/src/platform/input.rs +++ b/crates/nu-command/src/platform/input.rs @@ -121,8 +121,14 @@ impl Command for Input { .into_pipeline_data()); } - // Just read a normal line of text + // Just read a normal line of text, and trim the newline at the end let input = std::io::stdin().read_line(&mut buf); + if buf.ends_with('\n') { + buf.pop(); + if buf.ends_with('\r') { + buf.pop(); + } + } match input { Ok(_) => Ok(Value::String {