From af8726af4307825a7eed3f60eeb5e9449a03ba99 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 20 Mar 2022 19:58:21 +0100 Subject: [PATCH 1/3] ls: when -aA are provided, the order matters --- 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 fa1900bbb..d7562c29e 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1202,12 +1202,14 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(options::files::ALL) .short('a') .long(options::files::ALL) + .overrides_with(options::files::ALMOST_ALL) .help("Do not ignore hidden files (files with names that start with '.')."), ) .arg( Arg::new(options::files::ALMOST_ALL) .short('A') .long(options::files::ALMOST_ALL) + .overrides_with(options::files::ALL) .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 bb3b24670..540381cc0 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -2869,3 +2869,25 @@ fn test_ls_context_format() { ); } } + +#[test] +#[allow(non_snake_case)] +fn test_ls_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(".."); +} From 3009c73e9c080d89ca24e9396945afd36179c2eb Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 21 Mar 2022 09:13:56 +0100 Subject: [PATCH 2/3] ls -aA: Add a comment --- src/uu/ls/src/ls.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index d7562c29e..a63e9fd07 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1202,6 +1202,7 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(options::files::ALL) .short('a') .long(options::files::ALL) + // Overrides -A (as the order matters) .overrides_with(options::files::ALMOST_ALL) .help("Do not ignore hidden files (files with names that start with '.')."), ) @@ -1209,6 +1210,7 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(options::files::ALMOST_ALL) .short('A') .long(options::files::ALMOST_ALL) + // Overrides -a (as the order matters) .overrides_with(options::files::ALL) .help( "In a directory, do not ignore all file names that start with '.', \ From 187bddb6afa73b634e98a85d63c814756e90089b Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 21 Mar 2022 13:32:23 +0100 Subject: [PATCH 3/3] 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(".."); +}