From c29bcb219f6d10028ba5b9137730f45c158f93b1 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 3 Oct 2023 14:37:15 +0200 Subject: [PATCH] echo: don't output "\n" if "\c" is encountered --- src/uu/echo/src/echo.rs | 2 +- tests/by-util/test_echo.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index 947887210..b3707b6f8 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -175,7 +175,7 @@ fn execute(no_newline: bool, escaped: bool, free: &[String]) -> io::Result<()> { } if escaped { if print_escaped(input, &mut output)?.is_break() { - break; + return Ok(()); } } else { write!(output, "{input}")?; diff --git a/tests/by-util/test_echo.rs b/tests/by-util/test_echo.rs index dce5a4c95..875ff66cb 100644 --- a/tests/by-util/test_echo.rs +++ b/tests/by-util/test_echo.rs @@ -122,7 +122,7 @@ fn test_escape_no_further_output() { new_ucmd!() .args(&["-e", "a\\cb", "c"]) .succeeds() - .stdout_only("a\n"); + .stdout_only("a"); } #[test]