ls: --format will override the --dired option

Closes: #6488

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
This commit is contained in:
Sylvestre Ledru 2024-06-22 09:45:00 +02:00
parent cd44a3d1fd
commit 4d705621e6
2 changed files with 26 additions and 2 deletions

View file

@ -1083,7 +1083,7 @@ impl Config {
// --dired implies --format=long
format = Format::Long;
}
if dired && format == Format::Long && options.get_flag(options::ZERO) {
if dired && options.get_flag(options::ZERO) {
return Err(Box::new(LsError::DiredAndZeroAreIncompatible));
}
@ -1211,6 +1211,7 @@ pub fn uu_app() -> Command {
options::format::LONG,
options::format::ACROSS,
options::format::COLUMNS,
options::DIRED,
]),
)
.arg(
@ -1303,7 +1304,8 @@ pub fn uu_app() -> Command {
.num_args(0..=1)
.default_missing_value("always")
.default_value("never")
.value_name("WHEN").overrides_with(options::DIRED),
.value_name("WHEN")
.overrides_with(options::DIRED),
)
// The next four arguments do not override with the other format
// options, see the comment in Config::from for the reason.

View file

@ -3969,6 +3969,28 @@ fn test_ls_dired_hyperlink() {
.stdout_contains("//DIRED//");
}
#[test]
fn test_ls_dired_order_format() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.mkdir("dir");
at.touch("dir/a");
scene
.ucmd()
.arg("--dired")
.arg("--format=vertical")
.arg("-R")
.succeeds()
.stdout_does_not_contain("//DIRED//");
scene
.ucmd()
.arg("--format=vertical")
.arg("--dired")
.arg("-R")
.succeeds()
.stdout_contains("//DIRED//");
}
#[test]
fn test_ls_dired_and_zero_are_incompatible() {
let scene = TestScenario::new(util_name!());