From 4312f3c43e3d3f7445350fba79c9476bcab5709f Mon Sep 17 00:00:00 2001 From: Jadi Date: Wed, 3 Apr 2024 22:08:36 +0330 Subject: [PATCH 1/4] cksum: adding -b as the short form for --base64 closes #5706 --- src/uu/cksum/src/cksum.rs | 1 + tests/by-util/test_cksum.rs | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index c5c362c59..679d06ff7 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -448,6 +448,7 @@ pub fn uu_app() -> Command { .arg( Arg::new(options::BASE64) .long(options::BASE64) + .short('b') .help("emit a base64 digest, not hexadecimal") .action(ArgAction::SetTrue) // Even though this could easily just override an earlier '--raw', diff --git a/tests/by-util/test_cksum.rs b/tests/by-util/test_cksum.rs index 818b7e799..71b32bdfa 100644 --- a/tests/by-util/test_cksum.rs +++ b/tests/by-util/test_cksum.rs @@ -379,13 +379,15 @@ fn test_base64_raw_conflicts() { #[test] fn test_base64_single_file() { for algo in ALGOS { - new_ucmd!() - .arg("--base64") - .arg("lorem_ipsum.txt") - .arg(format!("--algorithm={algo}")) - .succeeds() - .no_stderr() - .stdout_is_fixture_bytes(format!("base64/{algo}_single_file.expected")); + for base64_option in ["--base64", "-b"] { + new_ucmd!() + .arg(base64_option) + .arg("lorem_ipsum.txt") + .arg(format!("--algorithm={algo}")) + .succeeds() + .no_stderr() + .stdout_is_fixture_bytes(format!("base64/{algo}_single_file.expected")); + } } } #[test] From d11878403cbbf553740aca954933e2c4bb1a6857 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 4 Apr 2024 14:51:47 +0200 Subject: [PATCH 2/4] Readme: fix links to docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dbcd7d860..895e3c9a9 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ that scripts can be easily transferred between platforms. ## Documentation uutils has both user and developer documentation available: -- [User Manual](https://uutils.github.io/coreutils/book/) +- [User Manual](https://uutils.github.io/coreutils/docs/) - [Developer Documentation](https://docs.rs/crate/coreutils/) Both can also be generated locally, the instructions for that can be found in @@ -302,7 +302,7 @@ make PREFIX=/my/path uninstall Below is the evolution of how many GNU tests uutils passes. A more detailed breakdown of the GNU test results of the main branch can be found -[in the user manual](https://uutils.github.io/coreutils/book/test_coverage.html). +[in the user manual](https://uutils.github.io/coreutils/docs/test_coverage.html). See for the main meta bugs (many are missing). From 1137d9a62d7ef5d05c4b8417ab41b5de814c51fc Mon Sep 17 00:00:00 2001 From: Jadi Date: Thu, 4 Apr 2024 21:33:22 +0330 Subject: [PATCH 3/4] cut: two new tests; -d conflict & no arg --- tests/by-util/test_cut.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/by-util/test_cut.rs b/tests/by-util/test_cut.rs index 50d158f96..86d3ddf0f 100644 --- a/tests/by-util/test_cut.rs +++ b/tests/by-util/test_cut.rs @@ -117,6 +117,17 @@ fn test_whitespace_with_char() { .code_is(1); } +#[test] +fn test_delimiter_with_byte_and_char() { + for conflicting_arg in ["-c", "-b"] { + new_ucmd!() + .args(&[conflicting_arg, COMPLEX_SEQUENCE.sequence, "-d="]) + .fails() + .stderr_is("cut: invalid input: The '--delimiter' ('-d') option only usable if printing a sequence of fields\n") + .code_is(1); + } +} + #[test] fn test_too_large() { new_ucmd!() @@ -289,6 +300,13 @@ fn test_multiple_mode_args() { } } +#[test] +fn test_no_argument() { + new_ucmd!().fails().stderr_is( + "cut: invalid usage: expects one of --fields (-f), --chars (-c) or --bytes (-b)\n", + ); +} + #[test] #[cfg(unix)] fn test_8bit_non_utf8_delimiter() { From ac12957307f871770037b1108a4edbfced4d9169 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 5 Apr 2024 07:14:37 +0200 Subject: [PATCH 4/4] cksum: fix code formatting --- src/uu/cksum/src/cksum.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index 679d06ff7..312e4355f 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -436,24 +436,27 @@ pub fn uu_app() -> Command { .long(options::LENGTH) .value_parser(value_parser!(usize)) .short('l') - .help("digest length in bits; must not exceed the max for the blake2 algorithm and must be a multiple of 8") + .help( + "digest length in bits; must not exceed the max for the blake2 algorithm \ + and must be a multiple of 8", + ) .action(ArgAction::Set), ) .arg( Arg::new(options::RAW) - .long(options::RAW) - .help("emit a raw binary digest, not hexadecimal") - .action(ArgAction::SetTrue), + .long(options::RAW) + .help("emit a raw binary digest, not hexadecimal") + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::BASE64) - .long(options::BASE64) - .short('b') - .help("emit a base64 digest, not hexadecimal") - .action(ArgAction::SetTrue) - // Even though this could easily just override an earlier '--raw', - // GNU cksum does not permit these flags to be combined: - .conflicts_with(options::RAW), + .long(options::BASE64) + .short('b') + .help("emit a base64 digest, not hexadecimal") + .action(ArgAction::SetTrue) + // Even though this could easily just override an earlier '--raw', + // GNU cksum does not permit these flags to be combined: + .conflicts_with(options::RAW), ) .after_help(AFTER_HELP) }