From 187bddb6afa73b634e98a85d63c814756e90089b Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 21 Mar 2022 13:32:23 +0100 Subject: [PATCH] ls: support multiple -a or -A --- src/uu/ls/src/ls.rs | 2 ++ tests/by-util/test_ls.rs | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index a63e9fd07..a3fdef344 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1204,6 +1204,7 @@ pub fn uu_app<'a>() -> Command<'a> { .long(options::files::ALL) // Overrides -A (as the order matters) .overrides_with(options::files::ALMOST_ALL) + .multiple_occurrences(true) .help("Do not ignore hidden files (files with names that start with '.')."), ) .arg( @@ -1212,6 +1213,7 @@ pub fn uu_app<'a>() -> Command<'a> { .long(options::files::ALMOST_ALL) // Overrides -a (as the order matters) .overrides_with(options::files::ALL) + .multiple_occurrences(true) .help( "In a directory, do not ignore all file names that start with '.', \ only ignore '.' and '..'.", diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 540381cc0..3cfba4312 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -2891,3 +2891,25 @@ fn test_ls_a_A() { .stdout_does_not_contain(".") .stdout_does_not_contain(".."); } + +#[test] +#[allow(non_snake_case)] +fn test_ls_multiple_a_A() { + let scene = TestScenario::new(util_name!()); + + scene + .ucmd() + .arg("-a") + .arg("-a") + .succeeds() + .stdout_contains(".") + .stdout_contains(".."); + + scene + .ucmd() + .arg("-A") + .arg("-A") + .succeeds() + .stdout_does_not_contain(".") + .stdout_does_not_contain(".."); +}