1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

ls --dired: v9.5 automatically set --format=long

This commit is contained in:
Sylvestre Ledru 2024-03-29 14:02:09 +01:00
parent 32c5d23f91
commit da11981026
2 changed files with 8 additions and 11 deletions

View file

@ -174,7 +174,6 @@ enum LsError {
IOError(std::io::Error), IOError(std::io::Error),
IOErrorContext(std::io::Error, PathBuf, bool), IOErrorContext(std::io::Error, PathBuf, bool),
BlockSizeParseError(String), BlockSizeParseError(String),
ConflictingArgumentDired,
DiredAndZeroAreIncompatible, DiredAndZeroAreIncompatible,
AlreadyListedError(PathBuf), AlreadyListedError(PathBuf),
TimeStyleParseError(String, Vec<String>), TimeStyleParseError(String, Vec<String>),
@ -188,7 +187,6 @@ impl UError for LsError {
Self::IOErrorContext(_, _, false) => 1, Self::IOErrorContext(_, _, false) => 1,
Self::IOErrorContext(_, _, true) => 2, Self::IOErrorContext(_, _, true) => 2,
Self::BlockSizeParseError(_) => 2, Self::BlockSizeParseError(_) => 2,
Self::ConflictingArgumentDired => 1,
Self::DiredAndZeroAreIncompatible => 2, Self::DiredAndZeroAreIncompatible => 2,
Self::AlreadyListedError(_) => 2, Self::AlreadyListedError(_) => 2,
Self::TimeStyleParseError(_, _) => 2, Self::TimeStyleParseError(_, _) => 2,
@ -204,9 +202,6 @@ impl Display for LsError {
Self::BlockSizeParseError(s) => { Self::BlockSizeParseError(s) => {
write!(f, "invalid --block-size argument {}", s.quote()) write!(f, "invalid --block-size argument {}", s.quote())
} }
Self::ConflictingArgumentDired => {
write!(f, "--dired requires --format=long")
}
Self::DiredAndZeroAreIncompatible => { Self::DiredAndZeroAreIncompatible => {
write!(f, "--dired and --zero are incompatible") write!(f, "--dired and --zero are incompatible")
} }
@ -1084,8 +1079,9 @@ impl Config {
}; };
let dired = options.get_flag(options::DIRED); let dired = options.get_flag(options::DIRED);
if dired && format != Format::Long { if dired {
return Err(Box::new(LsError::ConflictingArgumentDired)); // --dired implies --format=long
format = Format::Long;
} }
if dired && format == Format::Long && options.get_flag(options::ZERO) { if dired && format == Format::Long && options.get_flag(options::ZERO) {
return Err(Box::new(LsError::DiredAndZeroAreIncompatible)); return Err(Box::new(LsError::DiredAndZeroAreIncompatible));

View file

@ -3929,15 +3929,16 @@ fn test_ls_perm_io_errors() {
} }
#[test] #[test]
fn test_ls_dired_incompatible() { fn test_ls_dired_implies_long() {
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());
scene scene
.ucmd() .ucmd()
.arg("--dired") .arg("--dired")
.fails() .succeeds()
.code_is(1) .stdout_does_not_contain("//DIRED//")
.stderr_contains("--dired requires --format=long"); .stdout_contains(" total 0")
.stdout_contains("//DIRED-OPTIONS// --quoting-style");
} }
#[test] #[test]