diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index b3707b6f8..7c03159d5 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -154,13 +154,15 @@ pub fn uu_app() -> Command { Arg::new(options::ENABLE_BACKSLASH_ESCAPE) .short('e') .help("enable interpretation of backslash escapes") - .action(ArgAction::SetTrue), + .action(ArgAction::SetTrue) + .overrides_with(options::DISABLE_BACKSLASH_ESCAPE), ) .arg( Arg::new(options::DISABLE_BACKSLASH_ESCAPE) .short('E') .help("disable interpretation of backslash escapes (default)") - .action(ArgAction::SetTrue), + .action(ArgAction::SetTrue) + .overrides_with(options::ENABLE_BACKSLASH_ESCAPE), ) .arg(Arg::new(options::STRING).action(ArgAction::Append)) } diff --git a/tests/by-util/test_echo.rs b/tests/by-util/test_echo.rs index 875ff66cb..ac6bd74d1 100644 --- a/tests/by-util/test_echo.rs +++ b/tests/by-util/test_echo.rs @@ -117,6 +117,19 @@ fn test_escape_newline() { .stdout_only("\na\n"); } +#[test] +fn test_escape_override() { + new_ucmd!() + .args(&["-e", "-E", "\\na"]) + .succeeds() + .stdout_only("\\na\n"); + + new_ucmd!() + .args(&["-E", "-e", "\\na"]) + .succeeds() + .stdout_only("\na\n"); +} + #[test] fn test_escape_no_further_output() { new_ucmd!()