diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index d9bc00de3..b1117984c 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -174,7 +174,6 @@ enum LsError { IOError(std::io::Error), IOErrorContext(std::io::Error, PathBuf, bool), BlockSizeParseError(String), - ConflictingArgumentDired, DiredAndZeroAreIncompatible, AlreadyListedError(PathBuf), TimeStyleParseError(String, Vec), @@ -188,7 +187,6 @@ impl UError for LsError { Self::IOErrorContext(_, _, false) => 1, Self::IOErrorContext(_, _, true) => 2, Self::BlockSizeParseError(_) => 2, - Self::ConflictingArgumentDired => 1, Self::DiredAndZeroAreIncompatible => 2, Self::AlreadyListedError(_) => 2, Self::TimeStyleParseError(_, _) => 2, @@ -204,9 +202,6 @@ impl Display for LsError { Self::BlockSizeParseError(s) => { write!(f, "invalid --block-size argument {}", s.quote()) } - Self::ConflictingArgumentDired => { - write!(f, "--dired requires --format=long") - } Self::DiredAndZeroAreIncompatible => { write!(f, "--dired and --zero are incompatible") } @@ -1084,8 +1079,9 @@ impl Config { }; let dired = options.get_flag(options::DIRED); - if dired && format != Format::Long { - return Err(Box::new(LsError::ConflictingArgumentDired)); + if dired { + // --dired implies --format=long + format = Format::Long; } if dired && format == Format::Long && options.get_flag(options::ZERO) { return Err(Box::new(LsError::DiredAndZeroAreIncompatible)); diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 498d6284f..ce56868c5 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -3929,15 +3929,16 @@ fn test_ls_perm_io_errors() { } #[test] -fn test_ls_dired_incompatible() { +fn test_ls_dired_implies_long() { let scene = TestScenario::new(util_name!()); scene .ucmd() .arg("--dired") - .fails() - .code_is(1) - .stderr_contains("--dired requires --format=long"); + .succeeds() + .stdout_does_not_contain("//DIRED//") + .stdout_contains(" total 0") + .stdout_contains("//DIRED-OPTIONS// --quoting-style"); } #[test]