From 2afa9cd1a0ee42bf6ba85c7dc77590f37c39a41c Mon Sep 17 00:00:00 2001 From: Eli Youngs Date: Sun, 6 Feb 2022 14:26:59 -0800 Subject: [PATCH 01/38] printf - Update %g formatting to match GNU --- .../tokenize/num_format/formatters/decf.rs | 123 +++++++++++++----- tests/by-util/test_printf.rs | 66 +++++++++- 2 files changed, 156 insertions(+), 33 deletions(-) diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatters/decf.rs b/src/uucore/src/lib/features/tokenize/num_format/formatters/decf.rs index 52b8515c9..3d420ecdb 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatters/decf.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatters/decf.rs @@ -5,21 +5,88 @@ use super::super::format_field::FormatField; use super::super::formatter::{FormatPrimitive, Formatter, InitialPrefix}; use super::float_common::{get_primitive_dec, primitive_to_str_common, FloatAnalysis}; -fn get_len_fmt_primitive(fmt: &FormatPrimitive) -> usize { - let mut len = 0; - if let Some(ref s) = fmt.prefix { - len += s.len(); +const SIGNIFICANT_FIGURES: usize = 6; + +fn round_to_significance(input: &str, significant_figures: usize) -> u32 { + if significant_figures < input.len() { + let digits = &input[..significant_figures + 1]; + let float_representation = digits.parse::().unwrap(); + (float_representation / 10.0).round() as u32 + } else { + input.parse::().unwrap_or(0) } - if let Some(ref s) = fmt.pre_decimal { - len += s.len(); +} + +fn round(mut format: FormatPrimitive) -> FormatPrimitive { + let mut significant_figures = SIGNIFICANT_FIGURES; + + if format.pre_decimal.is_some() { + let input = format.pre_decimal.as_ref().unwrap(); + let rounded = round_to_significance(input, significant_figures); + let mut rounded_str = rounded.to_string(); + significant_figures -= rounded_str.len(); + + if significant_figures == 0 { + if let Some(digits) = &format.post_decimal { + if digits.chars().next().unwrap_or('0') >= '5' { + let rounded = rounded + 1; + rounded_str = rounded.to_string(); + } + } + } + format.pre_decimal = Some(rounded_str); } - if let Some(ref s) = fmt.post_decimal { - len += s.len(); + + if significant_figures == 0 { + format.post_decimal = Some(String::new()); + } else if let Some(input) = format.post_decimal { + let leading_zeroes = input.len() - input.trim_start_matches('0').len(); + + let rounded_str = if leading_zeroes <= significant_figures { + let mut post_decimal = String::with_capacity(significant_figures); + for _ in 0..leading_zeroes { + post_decimal.push('0'); + } + + significant_figures -= leading_zeroes; + let rounded = round_to_significance(&input[leading_zeroes..], significant_figures); + post_decimal.push_str(&rounded.to_string()); + post_decimal + } else { + input[..significant_figures].to_string() + }; + format.post_decimal = Some(rounded_str); } - if let Some(ref s) = fmt.suffix { - len += s.len(); + format +} + +fn truncate(mut format: FormatPrimitive) -> FormatPrimitive { + if let Some(ref post_dec) = format.post_decimal { + let trimmed = post_dec.trim_end_matches('0'); + + if trimmed.is_empty() { + format.post_decimal = Some("".into()); + if format.suffix == Some("e+00".into()) { + format.suffix = Some("".into()); + } + } else if trimmed.len() != post_dec.len() { + format.post_decimal = Some(trimmed.to_owned()); + } + } + format +} + +fn is_float_magnitude(suffix: &Option) -> bool { + match suffix { + Some(exponent) => { + if exponent.chars().nth(1) == Some('-') { + exponent < &"e-05".into() + } else { + exponent < &"e+06".into() + } + } + None => true, } - len } pub struct Decf; @@ -46,34 +113,26 @@ impl Formatter for Decf { None, false, ); - let mut f_sci = get_primitive_dec( + let mut f_dec = get_primitive_dec( initial_prefix, &str_in[initial_prefix.offset..], &analysis, second_field as usize, Some(*field.field_char == 'G'), ); - // strip trailing zeroes - if let Some(ref post_dec) = f_sci.post_decimal { - let trimmed = post_dec.trim_end_matches('0'); - if trimmed.len() != post_dec.len() { - f_sci.post_decimal = Some(trimmed.to_owned()); - } + + if is_float_magnitude(&f_dec.suffix) { + f_dec = get_primitive_dec( + initial_prefix, + &str_in[initial_prefix.offset..], + &analysis, + second_field as usize, + None, + ); } - let f_fl = get_primitive_dec( - initial_prefix, - &str_in[initial_prefix.offset..], - &analysis, - second_field as usize, - None, - ); - Some( - if get_len_fmt_primitive(&f_fl) >= get_len_fmt_primitive(&f_sci) { - f_sci - } else { - f_fl - }, - ) + + f_dec = truncate(round(f_dec)); + Some(f_dec) } fn primitive_to_str(&self, prim: &FormatPrimitive, field: FormatField) -> String { primitive_to_str_common(prim, &field) diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index 72ca4535a..0f2ad9ce3 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -289,7 +289,7 @@ fn sub_num_dec_trunc() { new_ucmd!() .args(&["pi is ~ %g", "3.1415926535"]) .succeeds() - .stdout_only("pi is ~ 3.141593"); + .stdout_only("pi is ~ 3.14159"); } #[cfg_attr(not(feature = "test_unimplemented"), ignore)] @@ -469,3 +469,67 @@ fn sub_float_leading_zeroes() { .succeeds() .stdout_only("001.000000"); } + +#[test] +fn sub_general_float() { + new_ucmd!() + .args(&["%g", "1.1"]) + .succeeds() + .stdout_only("1.1"); +} + +#[test] +fn sub_general_truncate_to_integer() { + new_ucmd!() + .args(&["%g", "1.0"]) + .succeeds() + .stdout_only("1"); +} + +#[test] +fn sub_general_prefix_with_spaces() { + new_ucmd!() + .args(&["%5g", "1.1"]) + .succeeds() + .stdout_only(" 1.1"); +} + +#[test] +fn sub_general_large_integer() { + new_ucmd!() + .args(&["%g", "1000000"]) + .succeeds() + .stdout_only("1e+06"); +} + +#[test] +fn sub_general_round_scientific_notation() { + new_ucmd!() + .args(&["%g", "123456789"]) + .succeeds() + .stdout_only("1.23457e+08"); +} + +#[test] +fn sub_general_scientific_leading_zeroes() { + new_ucmd!() + .args(&["%g", "1000010"]) + .succeeds() + .stdout_only("1.00001e+06"); +} + +#[test] +fn sub_general_round_float() { + new_ucmd!() + .args(&["%g", "12345.6789"]) + .succeeds() + .stdout_only("12345.7"); +} + +#[test] +fn sub_general_round_float_to_integer() { + new_ucmd!() + .args(&["%g", "123456.7"]) + .succeeds() + .stdout_only("123457"); +} From e23219289aac55bad22808676861dab41720c96b Mon Sep 17 00:00:00 2001 From: Eli Youngs Date: Sun, 6 Feb 2022 14:52:20 -0800 Subject: [PATCH 02/38] Simplify test cases --- tests/by-util/test_printf.rs | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index 0f2ad9ce3..4f1b52b32 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -487,19 +487,11 @@ fn sub_general_truncate_to_integer() { } #[test] -fn sub_general_prefix_with_spaces() { +fn sub_general_scientific_notation() { new_ucmd!() - .args(&["%5g", "1.1"]) + .args(&["%g", "1000010"]) .succeeds() - .stdout_only(" 1.1"); -} - -#[test] -fn sub_general_large_integer() { - new_ucmd!() - .args(&["%g", "1000000"]) - .succeeds() - .stdout_only("1e+06"); + .stdout_only("1.00001e+06"); } #[test] @@ -510,14 +502,6 @@ fn sub_general_round_scientific_notation() { .stdout_only("1.23457e+08"); } -#[test] -fn sub_general_scientific_leading_zeroes() { - new_ucmd!() - .args(&["%g", "1000010"]) - .succeeds() - .stdout_only("1.00001e+06"); -} - #[test] fn sub_general_round_float() { new_ucmd!() From 565af8237b17c4c658f3b965c0a28b414b0de9d3 Mon Sep 17 00:00:00 2001 From: Eli Youngs Date: Sun, 6 Feb 2022 23:57:54 -0800 Subject: [PATCH 03/38] Fix formatting --- tests/by-util/test_printf.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index 4f1b52b32..cb7126b9b 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -480,10 +480,7 @@ fn sub_general_float() { #[test] fn sub_general_truncate_to_integer() { - new_ucmd!() - .args(&["%g", "1.0"]) - .succeeds() - .stdout_only("1"); + new_ucmd!().args(&["%g", "1.0"]).succeeds().stdout_only("1"); } #[test] From 59440d35c0c766ffcabf359a2157a591082ffade Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Mar 2022 13:06:29 +0000 Subject: [PATCH 04/38] build(deps): bump clap from 3.0.10 to 3.1.6 Bumps [clap](https://github.com/clap-rs/clap) from 3.0.10 to 3.1.6. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v3.0.10...v3.1.6) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 219 +++++++++++++++++++----------------- Cargo.toml | 2 +- src/uu/arch/Cargo.toml | 2 +- src/uu/base32/Cargo.toml | 2 +- src/uu/basename/Cargo.toml | 2 +- src/uu/basenc/Cargo.toml | 2 +- src/uu/cat/Cargo.toml | 2 +- src/uu/chcon/Cargo.toml | 2 +- src/uu/chgrp/Cargo.toml | 2 +- src/uu/chmod/Cargo.toml | 2 +- src/uu/chown/Cargo.toml | 2 +- src/uu/chroot/Cargo.toml | 2 +- src/uu/cksum/Cargo.toml | 2 +- src/uu/comm/Cargo.toml | 2 +- src/uu/cp/Cargo.toml | 2 +- src/uu/csplit/Cargo.toml | 2 +- src/uu/cut/Cargo.toml | 2 +- src/uu/date/Cargo.toml | 2 +- src/uu/dd/Cargo.toml | 2 +- src/uu/df/Cargo.toml | 2 +- src/uu/dircolors/Cargo.toml | 2 +- src/uu/dirname/Cargo.toml | 2 +- src/uu/du/Cargo.toml | 2 +- src/uu/echo/Cargo.toml | 2 +- src/uu/env/Cargo.toml | 2 +- src/uu/expand/Cargo.toml | 2 +- src/uu/expr/Cargo.toml | 2 +- src/uu/factor/Cargo.toml | 2 +- src/uu/false/Cargo.toml | 2 +- src/uu/fmt/Cargo.toml | 2 +- src/uu/fold/Cargo.toml | 2 +- src/uu/groups/Cargo.toml | 2 +- src/uu/hashsum/Cargo.toml | 2 +- src/uu/head/Cargo.toml | 2 +- src/uu/hostid/Cargo.toml | 2 +- src/uu/hostname/Cargo.toml | 2 +- src/uu/id/Cargo.toml | 2 +- src/uu/install/Cargo.toml | 2 +- src/uu/join/Cargo.toml | 2 +- src/uu/kill/Cargo.toml | 2 +- src/uu/link/Cargo.toml | 2 +- src/uu/ln/Cargo.toml | 2 +- src/uu/logname/Cargo.toml | 2 +- src/uu/ls/Cargo.toml | 2 +- src/uu/mkdir/Cargo.toml | 2 +- src/uu/mkfifo/Cargo.toml | 2 +- src/uu/mknod/Cargo.toml | 2 +- src/uu/mktemp/Cargo.toml | 2 +- src/uu/more/Cargo.toml | 2 +- src/uu/mv/Cargo.toml | 2 +- src/uu/nice/Cargo.toml | 2 +- src/uu/nl/Cargo.toml | 2 +- src/uu/nohup/Cargo.toml | 2 +- src/uu/nproc/Cargo.toml | 2 +- src/uu/numfmt/Cargo.toml | 2 +- src/uu/od/Cargo.toml | 2 +- src/uu/paste/Cargo.toml | 2 +- src/uu/pathchk/Cargo.toml | 2 +- src/uu/pinky/Cargo.toml | 2 +- src/uu/pr/Cargo.toml | 2 +- src/uu/printenv/Cargo.toml | 2 +- src/uu/printf/Cargo.toml | 2 +- src/uu/ptx/Cargo.toml | 2 +- src/uu/pwd/Cargo.toml | 2 +- src/uu/readlink/Cargo.toml | 2 +- src/uu/realpath/Cargo.toml | 2 +- src/uu/relpath/Cargo.toml | 2 +- src/uu/rm/Cargo.toml | 2 +- src/uu/rmdir/Cargo.toml | 2 +- src/uu/runcon/Cargo.toml | 2 +- src/uu/seq/Cargo.toml | 2 +- src/uu/shred/Cargo.toml | 2 +- src/uu/shuf/Cargo.toml | 2 +- src/uu/sleep/Cargo.toml | 2 +- src/uu/sort/Cargo.toml | 2 +- src/uu/split/Cargo.toml | 2 +- src/uu/stat/Cargo.toml | 2 +- src/uu/stdbuf/Cargo.toml | 2 +- src/uu/sum/Cargo.toml | 2 +- src/uu/sync/Cargo.toml | 2 +- src/uu/tac/Cargo.toml | 2 +- src/uu/tail/Cargo.toml | 2 +- src/uu/tee/Cargo.toml | 2 +- src/uu/test/Cargo.toml | 2 +- src/uu/timeout/Cargo.toml | 2 +- src/uu/touch/Cargo.toml | 2 +- src/uu/tr/Cargo.toml | 2 +- src/uu/true/Cargo.toml | 2 +- src/uu/truncate/Cargo.toml | 2 +- src/uu/tsort/Cargo.toml | 2 +- src/uu/tty/Cargo.toml | 2 +- src/uu/uname/Cargo.toml | 2 +- src/uu/unexpand/Cargo.toml | 2 +- src/uu/uniq/Cargo.toml | 2 +- src/uu/unlink/Cargo.toml | 2 +- src/uu/uptime/Cargo.toml | 2 +- src/uu/users/Cargo.toml | 2 +- src/uu/wc/Cargo.toml | 2 +- src/uu/who/Cargo.toml | 2 +- src/uu/whoami/Cargo.toml | 2 +- src/uu/yes/Cargo.toml | 2 +- src/uucore/Cargo.toml | 4 +- 102 files changed, 216 insertions(+), 207 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4e46ba99..a944712b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,9 +280,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.0.10" +version = "3.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a30c3bf9ff12dfe5dae53f0a96e0febcd18420d1c0e7fad77796d9d5c4b5375" +checksum = "d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123" dependencies = [ "atty", "bitflags", @@ -292,7 +292,7 @@ dependencies = [ "strsim 0.10.0", "termcolor", "terminal_size", - "textwrap 0.14.2", + "textwrap 0.15.0", ] [[package]] @@ -301,7 +301,7 @@ version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d044e9db8cd0f68191becdeb5246b7462e4cf0c069b19ae00d1bf3fa9889498d" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", ] [[package]] @@ -331,7 +331,7 @@ version = "0.0.12" dependencies = [ "atty", "chrono", - "clap 3.0.10", + "clap 3.1.6", "clap_complete", "conv", "filetime", @@ -2122,6 +2122,15 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "textwrap" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" +dependencies = [ + "terminal_size", +] + [[package]] name = "thiserror" version = "1.0.30" @@ -2307,7 +2316,7 @@ checksum = "7cf7d77f457ef8dfa11e4cd5933c5ddb5dc52a94664071951219a97710f0a32b" name = "uu_arch" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "platform-info", "uucore", ] @@ -2316,7 +2325,7 @@ dependencies = [ name = "uu_base32" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2332,7 +2341,7 @@ dependencies = [ name = "uu_basename" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2340,7 +2349,7 @@ dependencies = [ name = "uu_basenc" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uu_base32", "uucore", ] @@ -2350,7 +2359,7 @@ name = "uu_cat" version = "0.0.12" dependencies = [ "atty", - "clap 3.0.10", + "clap 3.1.6", "nix 0.23.1", "thiserror", "unix_socket", @@ -2362,7 +2371,7 @@ dependencies = [ name = "uu_chcon" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "fts-sys", "libc", "selinux", @@ -2374,7 +2383,7 @@ dependencies = [ name = "uu_chgrp" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2382,7 +2391,7 @@ dependencies = [ name = "uu_chmod" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2391,7 +2400,7 @@ dependencies = [ name = "uu_chown" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2399,7 +2408,7 @@ dependencies = [ name = "uu_chroot" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2407,7 +2416,7 @@ dependencies = [ name = "uu_cksum" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2416,7 +2425,7 @@ dependencies = [ name = "uu_comm" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2425,7 +2434,7 @@ dependencies = [ name = "uu_cp" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "exacl", "filetime", "ioctl-sys", @@ -2442,7 +2451,7 @@ dependencies = [ name = "uu_csplit" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "regex", "thiserror", "uucore", @@ -2454,7 +2463,7 @@ version = "0.0.12" dependencies = [ "atty", "bstr", - "clap 3.0.10", + "clap 3.1.6", "memchr 2.4.1", "uucore", ] @@ -2464,7 +2473,7 @@ name = "uu_date" version = "0.0.12" dependencies = [ "chrono", - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", "winapi 0.3.9", @@ -2475,7 +2484,7 @@ name = "uu_dd" version = "0.0.12" dependencies = [ "byte-unit", - "clap 3.0.10", + "clap 3.1.6", "gcd", "libc", "signal-hook", @@ -2487,7 +2496,7 @@ dependencies = [ name = "uu_df" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "number_prefix", "uucore", ] @@ -2496,7 +2505,7 @@ dependencies = [ name = "uu_dircolors" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "glob", "uucore", ] @@ -2505,7 +2514,7 @@ dependencies = [ name = "uu_dirname" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2515,7 +2524,7 @@ name = "uu_du" version = "0.0.12" dependencies = [ "chrono", - "clap 3.0.10", + "clap 3.1.6", "uucore", "winapi 0.3.9", ] @@ -2524,7 +2533,7 @@ dependencies = [ name = "uu_echo" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2532,7 +2541,7 @@ dependencies = [ name = "uu_env" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "rust-ini", "uucore", @@ -2542,7 +2551,7 @@ dependencies = [ name = "uu_expand" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "unicode-width", "uucore", ] @@ -2551,7 +2560,7 @@ dependencies = [ name = "uu_expr" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "num-bigint", "num-traits", @@ -2563,7 +2572,7 @@ dependencies = [ name = "uu_factor" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "coz", "num-traits", "paste 0.1.18", @@ -2577,7 +2586,7 @@ dependencies = [ name = "uu_false" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2585,7 +2594,7 @@ dependencies = [ name = "uu_fmt" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "unicode-width", "uucore", @@ -2595,7 +2604,7 @@ dependencies = [ name = "uu_fold" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2603,7 +2612,7 @@ dependencies = [ name = "uu_groups" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2613,7 +2622,7 @@ version = "0.0.12" dependencies = [ "blake2b_simd", "blake3", - "clap 3.0.10", + "clap 3.1.6", "digest", "hex", "libc", @@ -2631,7 +2640,7 @@ dependencies = [ name = "uu_head" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "memchr 2.4.1", "uucore", ] @@ -2640,7 +2649,7 @@ dependencies = [ name = "uu_hostid" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2649,7 +2658,7 @@ dependencies = [ name = "uu_hostname" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "hostname", "libc", "uucore", @@ -2660,7 +2669,7 @@ dependencies = [ name = "uu_id" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "selinux", "uucore", ] @@ -2669,7 +2678,7 @@ dependencies = [ name = "uu_install" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "file_diff", "filetime", "libc", @@ -2681,7 +2690,7 @@ dependencies = [ name = "uu_join" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "memchr 2.4.1", "uucore", ] @@ -2690,7 +2699,7 @@ dependencies = [ name = "uu_kill" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2699,7 +2708,7 @@ dependencies = [ name = "uu_link" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2708,7 +2717,7 @@ dependencies = [ name = "uu_ln" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2717,7 +2726,7 @@ dependencies = [ name = "uu_logname" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2728,7 +2737,7 @@ version = "0.0.12" dependencies = [ "atty", "chrono", - "clap 3.0.10", + "clap 3.1.6", "glob", "lazy_static", "lscolors", @@ -2745,7 +2754,7 @@ dependencies = [ name = "uu_mkdir" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2754,7 +2763,7 @@ dependencies = [ name = "uu_mkfifo" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2763,7 +2772,7 @@ dependencies = [ name = "uu_mknod" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2772,7 +2781,7 @@ dependencies = [ name = "uu_mktemp" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "rand", "tempfile", "uucore", @@ -2783,7 +2792,7 @@ name = "uu_more" version = "0.0.12" dependencies = [ "atty", - "clap 3.0.10", + "clap 3.1.6", "crossterm", "nix 0.23.1", "redox_syscall", @@ -2797,7 +2806,7 @@ dependencies = [ name = "uu_mv" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "fs_extra", "uucore", ] @@ -2806,7 +2815,7 @@ dependencies = [ name = "uu_nice" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "nix 0.23.1", "uucore", @@ -2817,7 +2826,7 @@ name = "uu_nl" version = "0.0.12" dependencies = [ "aho-corasick", - "clap 3.0.10", + "clap 3.1.6", "libc", "memchr 2.4.1", "regex", @@ -2830,7 +2839,7 @@ name = "uu_nohup" version = "0.0.12" dependencies = [ "atty", - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2839,7 +2848,7 @@ dependencies = [ name = "uu_nproc" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "num_cpus", "uucore", @@ -2849,7 +2858,7 @@ dependencies = [ name = "uu_numfmt" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2858,7 +2867,7 @@ name = "uu_od" version = "0.0.12" dependencies = [ "byteorder", - "clap 3.0.10", + "clap 3.1.6", "half", "libc", "uucore", @@ -2868,7 +2877,7 @@ dependencies = [ name = "uu_paste" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2876,7 +2885,7 @@ dependencies = [ name = "uu_pathchk" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2885,7 +2894,7 @@ dependencies = [ name = "uu_pinky" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2894,7 +2903,7 @@ name = "uu_pr" version = "0.0.12" dependencies = [ "chrono", - "clap 3.0.10", + "clap 3.1.6", "itertools", "quick-error", "regex", @@ -2905,7 +2914,7 @@ dependencies = [ name = "uu_printenv" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2913,7 +2922,7 @@ dependencies = [ name = "uu_printf" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "itertools", "uucore", ] @@ -2923,7 +2932,7 @@ name = "uu_ptx" version = "0.0.12" dependencies = [ "aho-corasick", - "clap 3.0.10", + "clap 3.1.6", "libc", "memchr 2.4.1", "regex", @@ -2935,7 +2944,7 @@ dependencies = [ name = "uu_pwd" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2943,7 +2952,7 @@ dependencies = [ name = "uu_readlink" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2952,7 +2961,7 @@ dependencies = [ name = "uu_realpath" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2960,7 +2969,7 @@ dependencies = [ name = "uu_relpath" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -2968,7 +2977,7 @@ dependencies = [ name = "uu_rm" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "remove_dir_all", "uucore", "walkdir", @@ -2979,7 +2988,7 @@ dependencies = [ name = "uu_rmdir" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -2988,7 +2997,7 @@ dependencies = [ name = "uu_runcon" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "fts-sys", "libc", "selinux", @@ -3001,7 +3010,7 @@ name = "uu_seq" version = "0.0.12" dependencies = [ "bigdecimal", - "clap 3.0.10", + "clap 3.1.6", "num-bigint", "num-traits", "uucore", @@ -3011,7 +3020,7 @@ dependencies = [ name = "uu_shred" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "rand", "uucore", @@ -3021,7 +3030,7 @@ dependencies = [ name = "uu_shuf" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "rand", "rand_core", "uucore", @@ -3031,7 +3040,7 @@ dependencies = [ name = "uu_sleep" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -3040,7 +3049,7 @@ name = "uu_sort" version = "0.0.12" dependencies = [ "binary-heap-plus", - "clap 3.0.10", + "clap 3.1.6", "compare", "ctrlc", "fnv", @@ -3058,7 +3067,7 @@ dependencies = [ name = "uu_split" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "memchr 2.4.1", "uucore", ] @@ -3067,7 +3076,7 @@ dependencies = [ name = "uu_stat" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -3075,7 +3084,7 @@ dependencies = [ name = "uu_stdbuf" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "tempfile", "uu_stdbuf_libstdbuf", "uucore", @@ -3095,7 +3104,7 @@ dependencies = [ name = "uu_sum" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -3103,7 +3112,7 @@ dependencies = [ name = "uu_sync" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", "winapi 0.3.9", @@ -3113,7 +3122,7 @@ dependencies = [ name = "uu_tac" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "memchr 2.4.1", "memmap2", "regex", @@ -3124,7 +3133,7 @@ dependencies = [ name = "uu_tail" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "nix 0.23.1", "redox_syscall", @@ -3136,7 +3145,7 @@ dependencies = [ name = "uu_tee" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "retain_mut", "uucore", @@ -3146,7 +3155,7 @@ dependencies = [ name = "uu_test" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "redox_syscall", "uucore", @@ -3156,7 +3165,7 @@ dependencies = [ name = "uu_timeout" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "nix 0.23.1", "uucore", @@ -3166,7 +3175,7 @@ dependencies = [ name = "uu_touch" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "filetime", "time", "uucore", @@ -3177,7 +3186,7 @@ dependencies = [ name = "uu_tr" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "nom", "uucore", ] @@ -3186,7 +3195,7 @@ dependencies = [ name = "uu_true" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -3194,7 +3203,7 @@ dependencies = [ name = "uu_truncate" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -3202,7 +3211,7 @@ dependencies = [ name = "uu_tsort" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -3211,7 +3220,7 @@ name = "uu_tty" version = "0.0.12" dependencies = [ "atty", - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", ] @@ -3220,7 +3229,7 @@ dependencies = [ name = "uu_uname" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "platform-info", "uucore", ] @@ -3229,7 +3238,7 @@ dependencies = [ name = "uu_unexpand" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "unicode-width", "uucore", ] @@ -3238,7 +3247,7 @@ dependencies = [ name = "uu_uniq" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "strum", "strum_macros", "uucore", @@ -3248,7 +3257,7 @@ dependencies = [ name = "uu_unlink" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -3257,7 +3266,7 @@ name = "uu_uptime" version = "0.0.12" dependencies = [ "chrono", - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -3265,7 +3274,7 @@ dependencies = [ name = "uu_users" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -3274,7 +3283,7 @@ name = "uu_wc" version = "0.0.12" dependencies = [ "bytecount", - "clap 3.0.10", + "clap 3.1.6", "libc", "nix 0.23.1", "unicode-width", @@ -3286,7 +3295,7 @@ dependencies = [ name = "uu_who" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "uucore", ] @@ -3294,7 +3303,7 @@ dependencies = [ name = "uu_whoami" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "libc", "uucore", "winapi 0.3.9", @@ -3304,7 +3313,7 @@ dependencies = [ name = "uu_yes" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "nix 0.23.1", "uucore", ] @@ -3313,7 +3322,7 @@ dependencies = [ name = "uucore" version = "0.0.12" dependencies = [ - "clap 3.0.10", + "clap 3.1.6", "data-encoding", "data-encoding-macro", "dns-lookup", diff --git a/Cargo.toml b/Cargo.toml index 43797e71e..7668a27a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -245,7 +245,7 @@ test = [ "uu_test" ] [workspace] [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } clap_complete = "3.0" phf = "0.10.1" lazy_static = { version="1.3" } diff --git a/src/uu/arch/Cargo.toml b/src/uu/arch/Cargo.toml index 207100f59..96f6c4c8a 100644 --- a/src/uu/arch/Cargo.toml +++ b/src/uu/arch/Cargo.toml @@ -16,7 +16,7 @@ path = "src/arch.rs" [dependencies] platform-info = "0.2" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/base32/Cargo.toml b/src/uu/base32/Cargo.toml index 0b695f0aa..d61477fee 100644 --- a/src/uu/base32/Cargo.toml +++ b/src/uu/base32/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/base32.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] } [[bin]] diff --git a/src/uu/basename/Cargo.toml b/src/uu/basename/Cargo.toml index 6426e5046..399433109 100644 --- a/src/uu/basename/Cargo.toml +++ b/src/uu/basename/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/basename.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/basenc/Cargo.toml b/src/uu/basenc/Cargo.toml index a0f652cee..638c7e26c 100644 --- a/src/uu/basenc/Cargo.toml +++ b/src/uu/basenc/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/basenc.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] } uu_base32 = { version=">=0.0.8", package="uu_base32", path="../base32"} diff --git a/src/uu/cat/Cargo.toml b/src/uu/cat/Cargo.toml index 3eef5598b..f0a26fdac 100644 --- a/src/uu/cat/Cargo.toml +++ b/src/uu/cat/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/cat.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } thiserror = "1.0" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "pipes"] } diff --git a/src/uu/chcon/Cargo.toml b/src/uu/chcon/Cargo.toml index 75ce3fbd9..4a001b885 100644 --- a/src/uu/chcon/Cargo.toml +++ b/src/uu/chcon/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" path = "src/chcon.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version = ">=0.0.9", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } selinux = { version = "0.2" } fts-sys = { version = "0.2" } diff --git a/src/uu/chgrp/Cargo.toml b/src/uu/chgrp/Cargo.toml index ff60de836..d06c9adfa 100644 --- a/src/uu/chgrp/Cargo.toml +++ b/src/uu/chgrp/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/chgrp.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } [[bin]] diff --git a/src/uu/chmod/Cargo.toml b/src/uu/chmod/Cargo.toml index b2eb42574..da23c62ef 100644 --- a/src/uu/chmod/Cargo.toml +++ b/src/uu/chmod/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/chmod.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] } diff --git a/src/uu/chown/Cargo.toml b/src/uu/chown/Cargo.toml index b18310646..710a7b850 100644 --- a/src/uu/chown/Cargo.toml +++ b/src/uu/chown/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/chown.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } [[bin]] diff --git a/src/uu/chroot/Cargo.toml b/src/uu/chroot/Cargo.toml index d6a9dd080..a46f46a90 100644 --- a/src/uu/chroot/Cargo.toml +++ b/src/uu/chroot/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/chroot.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries"] } [[bin]] diff --git a/src/uu/cksum/Cargo.toml b/src/uu/cksum/Cargo.toml index 6643a2bab..8a03db6d5 100644 --- a/src/uu/cksum/Cargo.toml +++ b/src/uu/cksum/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/cksum.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/comm/Cargo.toml b/src/uu/comm/Cargo.toml index 58868dfc5..80a03bbc2 100644 --- a/src/uu/comm/Cargo.toml +++ b/src/uu/comm/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/comm.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index ffc008503..46637dadf 100644 --- a/src/uu/cp/Cargo.toml +++ b/src/uu/cp/Cargo.toml @@ -19,7 +19,7 @@ edition = "2018" path = "src/cp.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } filetime = "0.2" libc = "0.2.85" quick-error = "2.0.1" diff --git a/src/uu/csplit/Cargo.toml b/src/uu/csplit/Cargo.toml index 89fc118dd..f956db9fc 100644 --- a/src/uu/csplit/Cargo.toml +++ b/src/uu/csplit/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/csplit.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } thiserror = "1.0" regex = "1.0.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs"] } diff --git a/src/uu/cut/Cargo.toml b/src/uu/cut/Cargo.toml index 302f8f0c1..fb8e75470 100644 --- a/src/uu/cut/Cargo.toml +++ b/src/uu/cut/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/cut.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } memchr = "2" bstr = "0.2" diff --git a/src/uu/date/Cargo.toml b/src/uu/date/Cargo.toml index 793022992..c423bbe0f 100644 --- a/src/uu/date/Cargo.toml +++ b/src/uu/date/Cargo.toml @@ -16,7 +16,7 @@ path = "src/date.rs" [dependencies] chrono = "^0.4.11" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [target.'cfg(unix)'.dependencies] diff --git a/src/uu/dd/Cargo.toml b/src/uu/dd/Cargo.toml index 139a4845d..414f0a0aa 100644 --- a/src/uu/dd/Cargo.toml +++ b/src/uu/dd/Cargo.toml @@ -16,7 +16,7 @@ path = "src/dd.rs" [dependencies] byte-unit = "4.0" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } gcd = "2.0" libc = "0.2" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } diff --git a/src/uu/df/Cargo.toml b/src/uu/df/Cargo.toml index 29f32c6cf..3e9010f1e 100644 --- a/src/uu/df/Cargo.toml +++ b/src/uu/df/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/df.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } number_prefix = "0.4" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc", "fsext"] } diff --git a/src/uu/dircolors/Cargo.toml b/src/uu/dircolors/Cargo.toml index 28a520eef..ebc9d5cd9 100644 --- a/src/uu/dircolors/Cargo.toml +++ b/src/uu/dircolors/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/dircolors.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } glob = "0.3.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/dirname/Cargo.toml b/src/uu/dirname/Cargo.toml index 9b85edac0..980fee8a6 100644 --- a/src/uu/dirname/Cargo.toml +++ b/src/uu/dirname/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/dirname.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/du/Cargo.toml b/src/uu/du/Cargo.toml index a6af1a3ae..73fa5e3a5 100644 --- a/src/uu/du/Cargo.toml +++ b/src/uu/du/Cargo.toml @@ -16,7 +16,7 @@ path = "src/du.rs" [dependencies] chrono = "^0.4.11" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [target.'cfg(target_os = "windows")'.dependencies] diff --git a/src/uu/echo/Cargo.toml b/src/uu/echo/Cargo.toml index 8b8ba0819..fcfaec160 100644 --- a/src/uu/echo/Cargo.toml +++ b/src/uu/echo/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/echo.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/env/Cargo.toml b/src/uu/env/Cargo.toml index d5537fb54..da9ad66d1 100644 --- a/src/uu/env/Cargo.toml +++ b/src/uu/env/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/env.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" rust-ini = "0.17.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/expand/Cargo.toml b/src/uu/expand/Cargo.toml index ba2cdd317..053a2a530 100644 --- a/src/uu/expand/Cargo.toml +++ b/src/uu/expand/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/expand.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } unicode-width = "0.1.5" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/expr/Cargo.toml b/src/uu/expr/Cargo.toml index 278ebe46e..537f7e4c4 100644 --- a/src/uu/expr/Cargo.toml +++ b/src/uu/expr/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/expr.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" num-bigint = "0.4.0" num-traits = "0.2.14" diff --git a/src/uu/factor/Cargo.toml b/src/uu/factor/Cargo.toml index aec43af76..592867ddf 100644 --- a/src/uu/factor/Cargo.toml +++ b/src/uu/factor/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" num-traits = "0.2.13" # used in src/numerics.rs, which is included by build.rs [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } coz = { version = "0.1.3", optional = true } num-traits = "0.2.13" # Needs at least version 0.2.13 for "OverflowingAdd" rand = { version = "0.8", features = ["small_rng"] } diff --git a/src/uu/false/Cargo.toml b/src/uu/false/Cargo.toml index 7cbdcd41c..d12702620 100644 --- a/src/uu/false/Cargo.toml +++ b/src/uu/false/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/false.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/fmt/Cargo.toml b/src/uu/fmt/Cargo.toml index 47574b384..b3422d886 100644 --- a/src/uu/fmt/Cargo.toml +++ b/src/uu/fmt/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/fmt.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" unicode-width = "0.1.5" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/fold/Cargo.toml b/src/uu/fold/Cargo.toml index 40e3fceb0..a6ffee120 100644 --- a/src/uu/fold/Cargo.toml +++ b/src/uu/fold/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/fold.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/groups/Cargo.toml b/src/uu/groups/Cargo.toml index d7b3bf01f..bca2cc458 100644 --- a/src/uu/groups/Cargo.toml +++ b/src/uu/groups/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/groups.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "process"] } [[bin]] diff --git a/src/uu/hashsum/Cargo.toml b/src/uu/hashsum/Cargo.toml index d0362e3a3..0122bb116 100644 --- a/src/uu/hashsum/Cargo.toml +++ b/src/uu/hashsum/Cargo.toml @@ -16,7 +16,7 @@ path = "src/hashsum.rs" [dependencies] digest = "0.10.1" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } hex = "0.4.3" libc = "0.2.42" memchr = "2" diff --git a/src/uu/head/Cargo.toml b/src/uu/head/Cargo.toml index 65ac7f7cb..1744a4980 100644 --- a/src/uu/head/Cargo.toml +++ b/src/uu/head/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/head.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } memchr = "2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer", "lines"] } diff --git a/src/uu/hostid/Cargo.toml b/src/uu/hostid/Cargo.toml index f0013fb05..c1eeb413a 100644 --- a/src/uu/hostid/Cargo.toml +++ b/src/uu/hostid/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/hostid.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/hostname/Cargo.toml b/src/uu/hostname/Cargo.toml index 8f72dc402..4214b056f 100644 --- a/src/uu/hostname/Cargo.toml +++ b/src/uu/hostname/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/hostname.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" hostname = { version = "0.3", features = ["set"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] } diff --git a/src/uu/id/Cargo.toml b/src/uu/id/Cargo.toml index a0ccefbd0..ef7375691 100644 --- a/src/uu/id/Cargo.toml +++ b/src/uu/id/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/id.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "process"] } selinux = { version="0.2", optional = true } diff --git a/src/uu/install/Cargo.toml b/src/uu/install/Cargo.toml index c5ca889ec..bed17c6e3 100644 --- a/src/uu/install/Cargo.toml +++ b/src/uu/install/Cargo.toml @@ -18,7 +18,7 @@ edition = "2018" path = "src/install.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } filetime = "0.2" file_diff = "1.0.0" libc = ">= 0.2" diff --git a/src/uu/join/Cargo.toml b/src/uu/join/Cargo.toml index 706b246c2..025307e7a 100644 --- a/src/uu/join/Cargo.toml +++ b/src/uu/join/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/join.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } memchr = "2" diff --git a/src/uu/kill/Cargo.toml b/src/uu/kill/Cargo.toml index 46853a85d..a542cbd31 100644 --- a/src/uu/kill/Cargo.toml +++ b/src/uu/kill/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/kill.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["signals"] } diff --git a/src/uu/link/Cargo.toml b/src/uu/link/Cargo.toml index 46d7d26f0..80b7a3d19 100644 --- a/src/uu/link/Cargo.toml +++ b/src/uu/link/Cargo.toml @@ -16,7 +16,7 @@ path = "src/link.rs" [dependencies] libc = "0.2.42" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/ln/Cargo.toml b/src/uu/ln/Cargo.toml index b1f42cad0..32fed44a5 100644 --- a/src/uu/ln/Cargo.toml +++ b/src/uu/ln/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/ln.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/logname/Cargo.toml b/src/uu/logname/Cargo.toml index 8e1241b3b..69bb32dbc 100644 --- a/src/uu/logname/Cargo.toml +++ b/src/uu/logname/Cargo.toml @@ -16,7 +16,7 @@ path = "src/logname.rs" [dependencies] libc = "0.2.42" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index 6ad91e8e7..20b289173 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -16,7 +16,7 @@ path = "src/ls.rs" [dependencies] chrono = "0.4.19" -clap = { version = "3.0", features = ["wrap_help", "cargo", "env"] } +clap = { version = "3.1", features = ["wrap_help", "cargo", "env"] } unicode-width = "0.1.8" number_prefix = "0.4" term_grid = "0.1.5" diff --git a/src/uu/mkdir/Cargo.toml b/src/uu/mkdir/Cargo.toml index 4bb12e43d..b3a6462a5 100644 --- a/src/uu/mkdir/Cargo.toml +++ b/src/uu/mkdir/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/mkdir.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] } diff --git a/src/uu/mkfifo/Cargo.toml b/src/uu/mkfifo/Cargo.toml index 473cc0143..2a849fd3b 100644 --- a/src/uu/mkfifo/Cargo.toml +++ b/src/uu/mkfifo/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/mkfifo.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/mknod/Cargo.toml b/src/uu/mknod/Cargo.toml index 9bed05fd4..c3eef1129 100644 --- a/src/uu/mknod/Cargo.toml +++ b/src/uu/mknod/Cargo.toml @@ -16,7 +16,7 @@ name = "uu_mknod" path = "src/mknod.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "^0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["mode"] } diff --git a/src/uu/mktemp/Cargo.toml b/src/uu/mktemp/Cargo.toml index 1ae00fa6f..0fe2ea07d 100644 --- a/src/uu/mktemp/Cargo.toml +++ b/src/uu/mktemp/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/mktemp.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } rand = "0.8" tempfile = "3" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/more/Cargo.toml b/src/uu/more/Cargo.toml index 6975a3ecc..a62033ffe 100644 --- a/src/uu/more/Cargo.toml +++ b/src/uu/more/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/more.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version = ">=0.0.7", package = "uucore", path = "../../uucore" } crossterm = ">=0.19" atty = "0.2" diff --git a/src/uu/mv/Cargo.toml b/src/uu/mv/Cargo.toml index 79012b5e0..3d7ae0791 100644 --- a/src/uu/mv/Cargo.toml +++ b/src/uu/mv/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/mv.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } fs_extra = "1.1.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/nice/Cargo.toml b/src/uu/nice/Cargo.toml index fc42cb801..e814cd466 100644 --- a/src/uu/nice/Cargo.toml +++ b/src/uu/nice/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/nice.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" nix = "0.23.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/nl/Cargo.toml b/src/uu/nl/Cargo.toml index 9ce451f27..591255609 100644 --- a/src/uu/nl/Cargo.toml +++ b/src/uu/nl/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/nl.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } aho-corasick = "0.7.3" libc = "0.2.42" memchr = "2.2.0" diff --git a/src/uu/nohup/Cargo.toml b/src/uu/nohup/Cargo.toml index a19de6eb5..dd76cb703 100644 --- a/src/uu/nohup/Cargo.toml +++ b/src/uu/nohup/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/nohup.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/nproc/Cargo.toml b/src/uu/nproc/Cargo.toml index ef9ee5b2a..8620b9cf2 100644 --- a/src/uu/nproc/Cargo.toml +++ b/src/uu/nproc/Cargo.toml @@ -17,7 +17,7 @@ path = "src/nproc.rs" [dependencies] libc = "0.2.42" num_cpus = "1.10" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } [[bin]] diff --git a/src/uu/numfmt/Cargo.toml b/src/uu/numfmt/Cargo.toml index 8afc04f11..a2160beca 100644 --- a/src/uu/numfmt/Cargo.toml +++ b/src/uu/numfmt/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/numfmt.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/od/Cargo.toml b/src/uu/od/Cargo.toml index 10609ae47..a7d614d32 100644 --- a/src/uu/od/Cargo.toml +++ b/src/uu/od/Cargo.toml @@ -16,7 +16,7 @@ path = "src/od.rs" [dependencies] byteorder = "1.3.2" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } half = "1.6" libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/paste/Cargo.toml b/src/uu/paste/Cargo.toml index c37c7a939..a2e3049b2 100644 --- a/src/uu/paste/Cargo.toml +++ b/src/uu/paste/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/paste.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/pathchk/Cargo.toml b/src/uu/pathchk/Cargo.toml index 982a4ea89..2877efca3 100644 --- a/src/uu/pathchk/Cargo.toml +++ b/src/uu/pathchk/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/pathchk.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/pinky/Cargo.toml b/src/uu/pinky/Cargo.toml index 3bbffe981..57eabb874 100644 --- a/src/uu/pinky/Cargo.toml +++ b/src/uu/pinky/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/pinky.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["utmpx", "entries"] } [[bin]] diff --git a/src/uu/pr/Cargo.toml b/src/uu/pr/Cargo.toml index 100f37998..e5e6ddcb8 100644 --- a/src/uu/pr/Cargo.toml +++ b/src/uu/pr/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/pr.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries"] } chrono = "0.4.19" quick-error = "2.0.1" diff --git a/src/uu/printenv/Cargo.toml b/src/uu/printenv/Cargo.toml index ff8e6ffe1..bb684a1c4 100644 --- a/src/uu/printenv/Cargo.toml +++ b/src/uu/printenv/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/printenv.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/printf/Cargo.toml b/src/uu/printf/Cargo.toml index 98257f9aa..aaeb1583e 100644 --- a/src/uu/printf/Cargo.toml +++ b/src/uu/printf/Cargo.toml @@ -18,7 +18,7 @@ edition = "2018" path = "src/printf.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } itertools = "0.10.0" uucore = { version = ">=0.0.11", package = "uucore", path = "../../uucore", features = ["memo"] } diff --git a/src/uu/ptx/Cargo.toml b/src/uu/ptx/Cargo.toml index 90285ebf3..913ea1c04 100644 --- a/src/uu/ptx/Cargo.toml +++ b/src/uu/ptx/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/ptx.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } aho-corasick = "0.7.3" libc = "0.2.42" memchr = "2.2.0" diff --git a/src/uu/pwd/Cargo.toml b/src/uu/pwd/Cargo.toml index faf718ebd..d6c5567e2 100644 --- a/src/uu/pwd/Cargo.toml +++ b/src/uu/pwd/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/pwd.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/readlink/Cargo.toml b/src/uu/readlink/Cargo.toml index 30bb7e925..e5357ffdc 100644 --- a/src/uu/readlink/Cargo.toml +++ b/src/uu/readlink/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/readlink.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/realpath/Cargo.toml b/src/uu/realpath/Cargo.toml index cabd33256..706b73c1b 100644 --- a/src/uu/realpath/Cargo.toml +++ b/src/uu/realpath/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/realpath.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } [[bin]] diff --git a/src/uu/relpath/Cargo.toml b/src/uu/relpath/Cargo.toml index 29eab9ac2..3c31e7f3e 100644 --- a/src/uu/relpath/Cargo.toml +++ b/src/uu/relpath/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/relpath.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } [[bin]] diff --git a/src/uu/rm/Cargo.toml b/src/uu/rm/Cargo.toml index 2ef29d435..1e1b2464e 100644 --- a/src/uu/rm/Cargo.toml +++ b/src/uu/rm/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/rm.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } walkdir = "2.2" remove_dir_all = "0.5.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/rmdir/Cargo.toml b/src/uu/rmdir/Cargo.toml index 86d5031c8..d79e41d7f 100644 --- a/src/uu/rmdir/Cargo.toml +++ b/src/uu/rmdir/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/rmdir.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } libc = "0.2.42" diff --git a/src/uu/runcon/Cargo.toml b/src/uu/runcon/Cargo.toml index 5c68a8d68..4aec11dbf 100644 --- a/src/uu/runcon/Cargo.toml +++ b/src/uu/runcon/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" path = "src/runcon.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version = ">=0.0.9", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } selinux = { version = "0.2" } fts-sys = { version = "0.2" } diff --git a/src/uu/seq/Cargo.toml b/src/uu/seq/Cargo.toml index fe986529d..ef405d531 100644 --- a/src/uu/seq/Cargo.toml +++ b/src/uu/seq/Cargo.toml @@ -17,7 +17,7 @@ path = "src/seq.rs" [dependencies] bigdecimal = "0.3" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } num-bigint = "0.4.0" num-traits = "0.2.14" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["memo"] } diff --git a/src/uu/shred/Cargo.toml b/src/uu/shred/Cargo.toml index c73e0741b..68f287973 100644 --- a/src/uu/shred/Cargo.toml +++ b/src/uu/shred/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/shred.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" rand = "0.8" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/shuf/Cargo.toml b/src/uu/shuf/Cargo.toml index ab74e08b8..37c84da85 100644 --- a/src/uu/shuf/Cargo.toml +++ b/src/uu/shuf/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/shuf.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } rand = "0.8" rand_core = "0.6" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/sleep/Cargo.toml b/src/uu/sleep/Cargo.toml index 7f5413a3f..fc91d43b6 100644 --- a/src/uu/sleep/Cargo.toml +++ b/src/uu/sleep/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/sleep.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index 12b171b74..2adf49c44 100644 --- a/src/uu/sort/Cargo.toml +++ b/src/uu/sort/Cargo.toml @@ -16,7 +16,7 @@ path = "src/sort.rs" [dependencies] binary-heap-plus = "0.4.1" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } compare = "0.1.0" ctrlc = { version = "3.0", features = ["termination"] } fnv = "1.0.7" diff --git a/src/uu/split/Cargo.toml b/src/uu/split/Cargo.toml index 233563d1c..2f34311c1 100644 --- a/src/uu/split/Cargo.toml +++ b/src/uu/split/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/split.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } memchr = "2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/stat/Cargo.toml b/src/uu/stat/Cargo.toml index ecf5aa5bd..20086bef5 100644 --- a/src/uu/stat/Cargo.toml +++ b/src/uu/stat/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/stat.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "libc", "fs", "fsext"] } [[bin]] diff --git a/src/uu/stdbuf/Cargo.toml b/src/uu/stdbuf/Cargo.toml index a977adfe6..939913c36 100644 --- a/src/uu/stdbuf/Cargo.toml +++ b/src/uu/stdbuf/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/stdbuf.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } tempfile = "3" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/sum/Cargo.toml b/src/uu/sum/Cargo.toml index 56a4edf9a..cca85e030 100644 --- a/src/uu/sum/Cargo.toml +++ b/src/uu/sum/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/sum.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/sync/Cargo.toml b/src/uu/sync/Cargo.toml index a84d8c192..ce085a1d8 100644 --- a/src/uu/sync/Cargo.toml +++ b/src/uu/sync/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/sync.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] } winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "std", "winbase", "winerror"] } diff --git a/src/uu/tac/Cargo.toml b/src/uu/tac/Cargo.toml index a430c1e53..89d1f6571 100644 --- a/src/uu/tac/Cargo.toml +++ b/src/uu/tac/Cargo.toml @@ -20,7 +20,7 @@ path = "src/tac.rs" memchr = "2" memmap2 = "0.5" regex = "1" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index 7abc10a56..927e2bff3 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/tail.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer", "lines"] } diff --git a/src/uu/tee/Cargo.toml b/src/uu/tee/Cargo.toml index b71e9b0ef..f121d22ce 100644 --- a/src/uu/tee/Cargo.toml +++ b/src/uu/tee/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/tee.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" retain_mut = "=0.1.2" # ToDO: [2021-01-01; rivy; maint/MinSRV] ~ v0.1.5 uses const generics which aren't stabilized until rust v1.51.0 uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc"] } diff --git a/src/uu/test/Cargo.toml b/src/uu/test/Cargo.toml index bf0558a7a..10e411b51 100644 --- a/src/uu/test/Cargo.toml +++ b/src/uu/test/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/test.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/timeout/Cargo.toml b/src/uu/timeout/Cargo.toml index c250381e8..9dbd87240 100644 --- a/src/uu/timeout/Cargo.toml +++ b/src/uu/timeout/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/timeout.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" nix = "0.23.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["process", "signals"] } diff --git a/src/uu/touch/Cargo.toml b/src/uu/touch/Cargo.toml index bb6e0dc1e..6a2d46f84 100644 --- a/src/uu/touch/Cargo.toml +++ b/src/uu/touch/Cargo.toml @@ -16,7 +16,7 @@ path = "src/touch.rs" [dependencies] filetime = "0.2.1" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } time = "0.1.40" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc"] } diff --git a/src/uu/tr/Cargo.toml b/src/uu/tr/Cargo.toml index 4ecfe2045..efaa09fd1 100644 --- a/src/uu/tr/Cargo.toml +++ b/src/uu/tr/Cargo.toml @@ -16,7 +16,7 @@ path = "src/tr.rs" [dependencies] nom = "7.1.0" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/true/Cargo.toml b/src/uu/true/Cargo.toml index c737d2234..3dc1535e1 100644 --- a/src/uu/true/Cargo.toml +++ b/src/uu/true/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/true.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/truncate/Cargo.toml b/src/uu/truncate/Cargo.toml index 3048df521..ce74d1367 100644 --- a/src/uu/truncate/Cargo.toml +++ b/src/uu/truncate/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/truncate.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/tsort/Cargo.toml b/src/uu/tsort/Cargo.toml index 39e73f0a1..a107e8f27 100644 --- a/src/uu/tsort/Cargo.toml +++ b/src/uu/tsort/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/tsort.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index 43a0d2edc..30c32b459 100644 --- a/src/uu/tty/Cargo.toml +++ b/src/uu/tty/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/tty.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } libc = "0.2.42" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/uname/Cargo.toml b/src/uu/uname/Cargo.toml index 4a68e1b64..7bfa19750 100644 --- a/src/uu/uname/Cargo.toml +++ b/src/uu/uname/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/uname.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } platform-info = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/unexpand/Cargo.toml b/src/uu/unexpand/Cargo.toml index 86de08b9f..1df7061f3 100644 --- a/src/uu/unexpand/Cargo.toml +++ b/src/uu/unexpand/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/unexpand.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } unicode-width = "0.1.5" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/uniq/Cargo.toml b/src/uu/uniq/Cargo.toml index 1fe571b0e..3f3840cbf 100644 --- a/src/uu/uniq/Cargo.toml +++ b/src/uu/uniq/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/uniq.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } strum = "0.24.0" strum_macros = "0.23.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/unlink/Cargo.toml b/src/uu/unlink/Cargo.toml index 8d3ac6b26..323c74dba 100644 --- a/src/uu/unlink/Cargo.toml +++ b/src/uu/unlink/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/unlink.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/uptime/Cargo.toml b/src/uu/uptime/Cargo.toml index 8edb568d3..471a1d950 100644 --- a/src/uu/uptime/Cargo.toml +++ b/src/uu/uptime/Cargo.toml @@ -16,7 +16,7 @@ path = "src/uptime.rs" [dependencies] chrono = "^0.4.11" -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc", "utmpx"] } [[bin]] diff --git a/src/uu/users/Cargo.toml b/src/uu/users/Cargo.toml index dfd6d0309..2b155ee03 100644 --- a/src/uu/users/Cargo.toml +++ b/src/uu/users/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/users.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["utmpx"] } [[bin]] diff --git a/src/uu/wc/Cargo.toml b/src/uu/wc/Cargo.toml index 0e998b74e..d21e606dd 100644 --- a/src/uu/wc/Cargo.toml +++ b/src/uu/wc/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/wc.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["pipes"] } bytecount = "0.6.2" utf-8 = "0.7.6" diff --git a/src/uu/who/Cargo.toml b/src/uu/who/Cargo.toml index c0fd70ae8..eac59709d 100644 --- a/src/uu/who/Cargo.toml +++ b/src/uu/who/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/who.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["utmpx"] } [[bin]] diff --git a/src/uu/whoami/Cargo.toml b/src/uu/whoami/Cargo.toml index 151ef1141..8b92e7e63 100644 --- a/src/uu/whoami/Cargo.toml +++ b/src/uu/whoami/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/whoami.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries"] } [target.'cfg(target_os = "windows")'.dependencies] diff --git a/src/uu/yes/Cargo.toml b/src/uu/yes/Cargo.toml index 2054274f8..aad1af357 100644 --- a/src/uu/yes/Cargo.toml +++ b/src/uu/yes/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/yes.rs" [dependencies] -clap = { version = "3.0", features = ["wrap_help", "cargo"] } +clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["pipes"] } [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index c62e25d0b..1edf4c34f 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -17,7 +17,7 @@ path="src/lib/lib.rs" [dependencies] uucore_procs = { version=">=0.0.12", path="../uucore_procs" } -clap = "3.0" +clap = "3.1" dns-lookup = { version="1.0.5", optional=true } dunce = "1.0.0" wild = "2.0" @@ -38,7 +38,7 @@ walkdir = { version="2.3.2", optional=true } nix = { version="0.23.1", optional=true } [dev-dependencies] -clap = "3.0" +clap = "3.1" lazy_static = "1.3" [target.'cfg(target_os = "windows")'.dependencies] From 20212be4c8ce733c1247c974064c67521fddd83d Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Thu, 17 Mar 2022 14:40:40 +0100 Subject: [PATCH 05/38] fix clippy errors related to clap upgrade from 3.0.10 to 3.1.6 --- build.rs | 2 +- src/bin/coreutils.rs | 16 +++---- src/bin/uudoc.rs | 32 +++++++------- src/uu/arch/src/arch.rs | 8 ++-- src/uu/base32/src/base32.rs | 4 +- src/uu/base32/src/base_common.rs | 12 +++--- src/uu/basename/src/basename.rs | 8 ++-- src/uu/basenc/src/basenc.rs | 10 ++--- src/uu/cat/src/cat.rs | 8 ++-- src/uu/chcon/src/chcon.rs | 12 +++--- src/uu/chgrp/src/chgrp.rs | 8 ++-- src/uu/chmod/src/chmod.rs | 8 ++-- src/uu/chown/src/chown.rs | 8 ++-- src/uu/chroot/src/chroot.rs | 15 ++++--- src/uu/cksum/src/cksum.rs | 8 ++-- src/uu/comm/src/comm.rs | 8 ++-- src/uu/cp/src/cp.rs | 10 ++--- src/uu/csplit/src/csplit.rs | 8 ++-- src/uu/cut/src/cut.rs | 8 ++-- src/uu/date/src/date.rs | 8 ++-- src/uu/dd/src/dd.rs | 20 ++++----- src/uu/df/src/df.rs | 12 +++--- src/uu/dircolors/src/dircolors.rs | 8 ++-- src/uu/dirname/src/dirname.rs | 8 ++-- src/uu/du/src/du.rs | 8 ++-- src/uu/echo/src/echo.rs | 12 +++--- src/uu/env/src/env.rs | 14 +++--- src/uu/expand/src/expand.rs | 8 ++-- src/uu/expr/src/expr.rs | 8 ++-- src/uu/factor/src/cli.rs | 8 ++-- src/uu/false/src/false.rs | 17 ++++---- src/uu/fmt/src/fmt.rs | 8 ++-- src/uu/fold/src/fold.rs | 8 ++-- src/uu/groups/src/groups.rs | 8 ++-- src/uu/hashsum/src/hashsum.rs | 22 +++++----- src/uu/head/src/head.rs | 8 ++-- src/uu/hostid/src/hostid.rs | 8 ++-- src/uu/hostname/src/hostname.rs | 8 ++-- src/uu/id/src/id.rs | 8 ++-- src/uu/install/src/install.rs | 12 +++--- src/uu/join/src/join.rs | 8 ++-- src/uu/kill/src/kill.rs | 8 ++-- src/uu/link/src/link.rs | 8 ++-- src/uu/ln/src/ln.rs | 8 ++-- src/uu/logname/src/logname.rs | 8 ++-- src/uu/ls/src/ls.rs | 12 +++--- src/uu/mkdir/src/mkdir.rs | 8 ++-- src/uu/mkfifo/src/mkfifo.rs | 8 ++-- src/uu/mknod/src/mknod.rs | 8 ++-- src/uu/mktemp/src/mktemp.rs | 8 ++-- src/uu/more/src/more.rs | 8 ++-- src/uu/mv/src/mv.rs | 8 ++-- src/uu/nice/src/nice.rs | 10 ++--- src/uu/nl/src/nl.rs | 8 ++-- src/uu/nohup/src/nohup.rs | 10 ++--- src/uu/nproc/src/nproc.rs | 8 ++-- src/uu/numfmt/src/numfmt.rs | 10 ++--- src/uu/od/src/od.rs | 18 ++++---- src/uu/paste/src/paste.rs | 8 ++-- src/uu/pathchk/src/pathchk.rs | 8 ++-- src/uu/pinky/src/pinky.rs | 8 ++-- src/uu/pr/src/pr.rs | 18 ++++---- src/uu/printenv/src/printenv.rs | 8 ++-- src/uu/printf/src/printf.rs | 8 ++-- src/uu/ptx/src/ptx.rs | 8 ++-- src/uu/pwd/src/pwd.rs | 8 ++-- src/uu/readlink/src/readlink.rs | 8 ++-- src/uu/realpath/src/realpath.rs | 8 ++-- src/uu/relpath/src/relpath.rs | 8 ++-- src/uu/rm/src/rm.rs | 8 ++-- src/uu/rmdir/src/rmdir.rs | 8 ++-- src/uu/runcon/src/runcon.rs | 14 +++--- src/uu/seq/src/seq.rs | 12 +++--- src/uu/shred/src/shred.rs | 8 ++-- src/uu/shuf/src/shuf.rs | 10 ++--- src/uu/sleep/src/sleep.rs | 8 ++-- src/uu/sort/src/sort.rs | 8 ++-- src/uu/split/src/split.rs | 8 ++-- src/uu/stat/src/stat.rs | 8 ++-- src/uu/stdbuf/src/stdbuf.rs | 16 +++---- src/uu/sum/src/sum.rs | 8 ++-- src/uu/sync/src/sync.rs | 8 ++-- src/uu/tac/src/tac.rs | 8 ++-- src/uu/tail/src/tail.rs | 8 ++-- src/uu/tee/src/tee.rs | 8 ++-- src/uu/test/src/test.rs | 8 ++-- src/uu/timeout/src/timeout.rs | 18 ++++---- src/uu/touch/src/touch.rs | 8 ++-- src/uu/tr/src/tr.rs | 10 ++--- src/uu/true/src/true.rs | 17 ++++---- src/uu/truncate/src/truncate.rs | 10 ++--- src/uu/tsort/src/tsort.rs | 8 ++-- src/uu/tty/src/tty.rs | 8 ++-- src/uu/uname/src/uname.rs | 8 ++-- src/uu/unexpand/src/unexpand.rs | 8 ++-- src/uu/uniq/src/uniq.rs | 8 ++-- src/uu/unlink/src/unlink.rs | 8 ++-- src/uu/uptime/src/uptime.rs | 8 ++-- src/uu/users/src/users.rs | 8 ++-- src/uu/wc/src/wc.rs | 8 ++-- src/uu/who/src/who.rs | 8 ++-- src/uu/whoami/src/whoami.rs | 8 ++-- src/uu/yes/src/yes.rs | 8 ++-- src/uucore/src/lib/features/perms.rs | 12 +++--- src/uucore/src/lib/mods/backup_control.rs | 52 +++++++++++------------ tests/by-util/test_link.rs | 2 +- tests/by-util/test_mknod.rs | 4 +- 107 files changed, 532 insertions(+), 529 deletions(-) diff --git a/build.rs b/build.rs index c4f135e64..50b8cfa3f 100644 --- a/build.rs +++ b/build.rs @@ -43,7 +43,7 @@ pub fn main() { let mut tf = File::create(Path::new(&out_dir).join("test_modules.rs")).unwrap(); mf.write_all( - "type UtilityMap = phf::Map<&'static str, (fn(T) -> i32, fn() -> App<'static>)>;\n\ + "type UtilityMap = phf::Map<&'static str, (fn(T) -> i32, fn() -> Command<'static>)>;\n\ \n\ fn util_map() -> UtilityMap {\n" .as_bytes(), diff --git a/src/bin/coreutils.rs b/src/bin/coreutils.rs index fcd86c93f..7a8986035 100644 --- a/src/bin/coreutils.rs +++ b/src/bin/coreutils.rs @@ -5,7 +5,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use clap::{App, Arg}; +use clap::{Arg, Command}; use clap_complete::Shell; use std::cmp; use std::ffi::OsStr; @@ -138,7 +138,7 @@ fn gen_completions( .chain(util_map.keys().copied()) .collect(); - let matches = App::new("completion") + let matches = Command::new("completion") .about("Prints completions to stdout") .arg( Arg::new("utility") @@ -155,7 +155,7 @@ fn gen_completions( let utility = matches.value_of("utility").unwrap(); let shell = matches.value_of("shell").unwrap(); - let mut app = if utility == "coreutils" { + let mut command = if utility == "coreutils" { gen_coreutils_app(util_map) } else { util_map.get(utility).unwrap().1() @@ -163,15 +163,15 @@ fn gen_completions( let shell: Shell = shell.parse().unwrap(); let bin_name = std::env::var("PROG_PREFIX").unwrap_or_default() + utility; - clap_complete::generate(shell, &mut app, bin_name, &mut io::stdout()); + clap_complete::generate(shell, &mut command, bin_name, &mut io::stdout()); io::stdout().flush().unwrap(); process::exit(0); } -fn gen_coreutils_app(util_map: &UtilityMap) -> App<'static> { - let mut app = App::new("coreutils"); +fn gen_coreutils_app(util_map: &UtilityMap) -> Command<'static> { + let mut command = Command::new("coreutils"); for (_, (_, sub_app)) in util_map { - app = app.subcommand(sub_app()); + command = command.subcommand(sub_app()); } - app + command } diff --git a/src/bin/uudoc.rs b/src/bin/uudoc.rs index a6bc16cc2..24c347fe7 100644 --- a/src/bin/uudoc.rs +++ b/src/bin/uudoc.rs @@ -4,7 +4,7 @@ // file that was distributed with this source code. // spell-checker:ignore tldr -use clap::App; +use clap::Command; use std::ffi::OsString; use std::fs::File; use std::io::Cursor; @@ -46,13 +46,13 @@ fn main() -> io::Result<()> { let mut utils = utils.entries().collect::>(); utils.sort(); - for (&name, (_, app)) in utils { + for (&name, (_, command)) in utils { if name == "[" { continue; } let p = format!("docs/src/utils/{}.md", name); if let Ok(f) = File::create(&p) { - write_markdown(f, &mut app(), name, &mut tldr_zip)?; + write_markdown(f, &mut command(), name, &mut tldr_zip)?; println!("Wrote to '{}'", p); } else { println!("Error writing to {}", p); @@ -64,29 +64,29 @@ fn main() -> io::Result<()> { fn write_markdown( mut w: impl Write, - app: &mut App, + command: &mut Command, name: &str, tldr_zip: &mut zip::ZipArchive, ) -> io::Result<()> { write!(w, "# {}\n\n", name)?; - write_version(&mut w, app)?; - write_usage(&mut w, app, name)?; - write_description(&mut w, app)?; - write_options(&mut w, app)?; + write_version(&mut w, command)?; + write_usage(&mut w, command, name)?; + write_description(&mut w, command)?; + write_options(&mut w, command)?; write_examples(&mut w, name, tldr_zip) } -fn write_version(w: &mut impl Write, app: &App) -> io::Result<()> { +fn write_version(w: &mut impl Write, command: &Command) -> io::Result<()> { writeln!( w, "
version: {}
", - app.render_version().split_once(' ').unwrap().1 + command.render_version().split_once(' ').unwrap().1 ) } -fn write_usage(w: &mut impl Write, app: &mut App, name: &str) -> io::Result<()> { +fn write_usage(w: &mut impl Write, command: &mut Command, name: &str) -> io::Result<()> { writeln!(w, "\n```")?; - let mut usage: String = app + let mut usage: String = command .render_usage() .lines() .skip(1) @@ -99,8 +99,8 @@ fn write_usage(w: &mut impl Write, app: &mut App, name: &str) -> io::Result<()> writeln!(w, "```") } -fn write_description(w: &mut impl Write, app: &App) -> io::Result<()> { - if let Some(about) = app.get_long_about().or_else(|| app.get_about()) { +fn write_description(w: &mut impl Write, command: &Command) -> io::Result<()> { + if let Some(about) = command.get_long_about().or_else(|| command.get_about()) { writeln!(w, "{}", about) } else { Ok(()) @@ -152,10 +152,10 @@ fn get_zip_content(archive: &mut ZipArchive, name: &str) -> Op Some(s) } -fn write_options(w: &mut impl Write, app: &App) -> io::Result<()> { +fn write_options(w: &mut impl Write, command: &Command) -> io::Result<()> { writeln!(w, "

Options

")?; write!(w, "
")?; - for arg in app.get_arguments() { + for arg in command.get_arguments() { write!(w, "
")?; let mut first = true; for l in arg.get_long_and_visible_aliases().unwrap_or_default() { diff --git a/src/uu/arch/src/arch.rs b/src/uu/arch/src/arch.rs index b588adbb9..502e2d5a0 100644 --- a/src/uu/arch/src/arch.rs +++ b/src/uu/arch/src/arch.rs @@ -8,7 +8,7 @@ use platform_info::*; -use clap::{crate_version, App, AppSettings}; +use clap::{crate_version, Command}; use uucore::error::{FromIo, UResult}; static ABOUT: &str = "Display machine architecture"; @@ -23,10 +23,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(SUMMARY) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) } diff --git a/src/uu/base32/src/base32.rs b/src/uu/base32/src/base32.rs index ff1ba502a..4260c472e 100644 --- a/src/uu/base32/src/base32.rs +++ b/src/uu/base32/src/base32.rs @@ -7,7 +7,7 @@ use std::io::{stdin, Read}; -use clap::App; +use clap::Command; use uucore::{encoding::Format, error::UResult}; pub mod base_common; @@ -44,6 +44,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { ) } -pub fn uu_app<'a>() -> App<'a> { +pub fn uu_app<'a>() -> Command<'a> { base_common::base_app(ABOUT, USAGE) } diff --git a/src/uu/base32/src/base_common.rs b/src/uu/base32/src/base_common.rs index 1d4d8a19d..100c85b1f 100644 --- a/src/uu/base32/src/base_common.rs +++ b/src/uu/base32/src/base_common.rs @@ -18,7 +18,7 @@ use std::fs::File; use std::io::{BufReader, Stdin}; use std::path::Path; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; pub static BASE_CMD_PARSE_ERROR: i32 = 1; @@ -86,19 +86,19 @@ impl Config { } pub fn parse_base_cmd_args(args: impl uucore::Args, about: &str, usage: &str) -> UResult { - let app = base_app(about, usage); + let command = base_app(about, usage); let arg_list = args .collect_str(InvalidEncodingHandling::ConvertLossy) .accept_any(); - Config::from(&app.get_matches_from(arg_list)) + Config::from(&command.get_matches_from(arg_list)) } -pub fn base_app<'a>(about: &'a str, usage: &'a str) -> App<'a> { - App::new(uucore::util_name()) +pub fn base_app<'a>(about: &'a str, usage: &'a str) -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(about) .override_usage(format_usage(usage)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) // Format arguments. .arg( Arg::new(options::DECODE) diff --git a/src/uu/basename/src/basename.rs b/src/uu/basename/src/basename.rs index bf13fde7e..7b0a0a486 100644 --- a/src/uu/basename/src/basename.rs +++ b/src/uu/basename/src/basename.rs @@ -7,7 +7,7 @@ // spell-checker:ignore (ToDO) fullname -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::path::{is_separator, PathBuf}; use uucore::display::Quotable; use uucore::error::{UResult, UUsageError}; @@ -87,12 +87,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::MULTIPLE) .short('a') diff --git a/src/uu/basenc/src/basenc.rs b/src/uu/basenc/src/basenc.rs index 9e48cf80c..d47fe123a 100644 --- a/src/uu/basenc/src/basenc.rs +++ b/src/uu/basenc/src/basenc.rs @@ -8,7 +8,7 @@ //spell-checker:ignore (args) lsbf msbf -use clap::{App, Arg}; +use clap::{Arg, Command}; use uu_base32::base_common::{self, Config, BASE_CMD_PARSE_ERROR}; use uucore::{ @@ -40,12 +40,12 @@ const ENCODINGS: &[(&str, Format)] = &[ const USAGE: &str = "{} [OPTION]... [FILE]"; -pub fn uu_app<'a>() -> App<'a> { - let mut app = base_common::base_app(ABOUT, USAGE); +pub fn uu_app<'a>() -> Command<'a> { + let mut command = base_common::base_app(ABOUT, USAGE); for encoding in ENCODINGS { - app = app.arg(Arg::new(encoding.0).long(encoding.0)); + command = command.arg(Arg::new(encoding.0).long(encoding.0)); } - app + command } fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> { diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index 0a1ba2559..edba1b8d0 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -14,7 +14,7 @@ extern crate unix_socket; // last synced with: cat (GNU coreutils) 8.13 -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs::{metadata, File}; use std::io::{self, Read, Write}; use thiserror::Error; @@ -239,13 +239,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { cat_files(&files, &options) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) .version(crate_version!()) .override_usage(format_usage(USAGE)) .about(SUMMARY) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::FILE) .hide(true) diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index d033b62c1..8f5e0f26b 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -6,7 +6,7 @@ use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::format_usage; use uucore::{display::Quotable, show_error, show_warning}; -use clap::{App, AppSettings, Arg}; +use clap::{Arg, Command}; use selinux::{OpaqueSecurityContext, SecurityContext}; use std::borrow::Cow; @@ -65,7 +65,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(r) => r, Err(r) => { if let Error::CommandLine(r) = &r { - match r.kind { + match r.kind() { clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => { println!("{}", r); return Ok(()); @@ -154,12 +154,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Err(libc::EXIT_FAILURE.into()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(VERSION) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::dereference::DEREFERENCE) .long(options::dereference::DEREFERENCE) @@ -303,7 +303,7 @@ struct Options { files: Vec, } -fn parse_command_line(config: clap::App, args: impl uucore::Args) -> Result { +fn parse_command_line(config: clap::Command, args: impl uucore::Args) -> Result { let matches = config.try_get_matches_from(args)?; let verbose = matches.is_present(options::VERBOSE); diff --git a/src/uu/chgrp/src/chgrp.rs b/src/uu/chgrp/src/chgrp.rs index affaf86a3..ce1cb5f37 100644 --- a/src/uu/chgrp/src/chgrp.rs +++ b/src/uu/chgrp/src/chgrp.rs @@ -13,7 +13,7 @@ use uucore::error::{FromIo, UResult, USimpleError}; use uucore::format_usage; use uucore::perms::{chown_base, options, IfFrom}; -use clap::{App, AppSettings, Arg, ArgMatches}; +use clap::{Arg, ArgMatches, Command}; use std::fs; use std::os::unix::fs::MetadataExt; @@ -54,12 +54,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { chown_base(uu_app(), args, options::ARG_GROUP, parse_gid_and_uid, true) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(VERSION) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::verbosity::CHANGES) .short('c') diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index c2b51ae5e..25a37c372 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -7,7 +7,7 @@ // spell-checker:ignore (ToDO) Chmoder cmode fmode fperm fref ugoa RFILE RFILE's -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs; use std::os::unix::fs::{MetadataExt, PermissionsExt}; use std::path::Path; @@ -112,12 +112,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { chmoder.chmod(&files) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::CHANGES) .long(options::CHANGES) diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs index 27a989847..c1d7d1420 100644 --- a/src/uu/chown/src/chown.rs +++ b/src/uu/chown/src/chown.rs @@ -14,7 +14,7 @@ use uucore::perms::{chown_base, options, IfFrom}; use uucore::error::{FromIo, UResult, USimpleError}; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::fs; use std::os::unix::fs::MetadataExt; @@ -63,12 +63,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { ) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::verbosity::CHANGES) .short('c') diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index d18264566..713336104 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -10,11 +10,11 @@ mod error; use crate::error::ChrootError; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::ffi::CString; use std::io::Error; use std::path::Path; -use std::process::Command; +use std::process; use uucore::error::{set_exit_code, UResult}; use uucore::libc::{self, chroot, setgid, setgroups, setuid}; use uucore::{entries, format_usage, InvalidEncodingHandling}; @@ -77,7 +77,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // NOTE: Tests can only trigger code beyond this point if they're invoked with root permissions set_context(newroot, &matches)?; - let pstatus = match Command::new(chroot_command).args(chroot_args).status() { + let pstatus = match process::Command::new(chroot_command) + .args(chroot_args) + .status() + { Ok(status) => status, Err(e) => return Err(ChrootError::CommandFailed(command[0].to_string(), e).into()), }; @@ -91,12 +94,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::NEWROOT) .hide(true) diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index 7f7ba9ed3..e901e0820 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -6,7 +6,7 @@ // file that was distributed with this source code. // spell-checker:ignore (ToDO) fname -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs::File; use std::io::{self, stdin, BufReader, Read}; use std::path::Path; @@ -140,13 +140,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) .version(crate_version!()) .about(SUMMARY) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::FILE) .hide(true) diff --git a/src/uu/comm/src/comm.rs b/src/uu/comm/src/comm.rs index 8064dd216..2207493d3 100644 --- a/src/uu/comm/src/comm.rs +++ b/src/uu/comm/src/comm.rs @@ -15,7 +15,7 @@ use uucore::error::FromIo; use uucore::error::UResult; use uucore::{format_usage, InvalidEncodingHandling}; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; static ABOUT: &str = "compare two sorted files line by line"; static LONG_HELP: &str = ""; @@ -143,13 +143,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::COLUMN_1) .short('1') diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index a4a512d6b..1152e8def 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -28,7 +28,7 @@ use winapi::um::fileapi::GetFileInformationByHandle; use std::borrow::Cow; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use filetime::FileTime; #[cfg(unix)] use libc::mkfifo; @@ -296,7 +296,7 @@ static DEFAULT_ATTRIBUTES: &[Attribute] = &[ Attribute::Timestamps, ]; -pub fn uu_app<'a>() -> App<'a> { +pub fn uu_app<'a>() -> Command<'a> { const MODE_ARGS: &[&str] = &[ options::LINK, options::REFLINK, @@ -304,11 +304,11 @@ pub fn uu_app<'a>() -> App<'a> { options::ATTRIBUTES_ONLY, options::COPY_CONTENTS, ]; - App::new(uucore::util_name()) + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg(Arg::new(options::TARGET_DIRECTORY) .short('t') .conflicts_with(options::NO_TARGET_DIRECTORY) @@ -389,7 +389,7 @@ pub fn uu_app<'a>() -> App<'a> { .long(options::PRESERVE) .takes_value(true) .multiple_occurrences(true) - .use_delimiter(true) + .use_value_delimiter(true) .possible_values(PRESERVABLE_ATTRIBUTES) .min_values(0) .value_name("ATTR_LIST") diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs index 7793a8637..a0b739935 100644 --- a/src/uu/csplit/src/csplit.rs +++ b/src/uu/csplit/src/csplit.rs @@ -12,7 +12,7 @@ use std::{ io::{BufRead, BufWriter, Write}, }; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use regex::Regex; use uucore::display::Quotable; use uucore::error::{FromIo, UResult}; @@ -746,12 +746,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::SUFFIX_FORMAT) .short('b') diff --git a/src/uu/cut/src/cut.rs b/src/uu/cut/src/cut.rs index ce82a2737..2264f4f26 100644 --- a/src/uu/cut/src/cut.rs +++ b/src/uu/cut/src/cut.rs @@ -11,7 +11,7 @@ extern crate uucore; use bstr::io::BufReadExt; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs::File; use std::io::{stdin, stdout, BufReader, BufWriter, Read, Write}; use std::path::Path; @@ -533,14 +533,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) .version(crate_version!()) .override_usage(format_usage(USAGE)) .about(SUMMARY) .after_help(LONG_HELP) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::BYTES) .short('b') diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index 18e06aef4..8946768d5 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -11,7 +11,7 @@ use chrono::{DateTime, FixedOffset, Local, Offset, Utc}; #[cfg(windows)] use chrono::{Datelike, Timelike}; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; #[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))] use libc::{clock_settime, timespec, CLOCK_REALTIME}; use std::fs::File; @@ -254,12 +254,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_DATE) .short('d') diff --git a/src/uu/dd/src/dd.rs b/src/uu/dd/src/dd.rs index d8bc3acd3..10a0ff9c2 100644 --- a/src/uu/dd/src/dd.rs +++ b/src/uu/dd/src/dd.rs @@ -34,7 +34,7 @@ use std::sync::mpsc; use std::thread; use std::time; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use gcd::Gcd; use uucore::display::Quotable; use uucore::error::{FromIo, UResult}; @@ -730,11 +730,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::INFILE) .long(options::INFILE) @@ -846,8 +846,8 @@ Printing performance stats is also triggered by the INFO signal (where supported .long(options::CONV) .takes_value(true) .multiple_occurrences(true) - .use_delimiter(true) - .require_delimiter(true) + .use_value_delimiter(true) + .require_value_delimiter(true) .multiple_values(true) .require_equals(true) .value_name("CONV") @@ -887,8 +887,8 @@ Conversion Flags: .long(options::IFLAG) .takes_value(true) .multiple_occurrences(true) - .use_delimiter(true) - .require_delimiter(true) + .use_value_delimiter(true) + .require_value_delimiter(true) .multiple_values(true) .require_equals(true) .value_name("FLAG") @@ -917,8 +917,8 @@ General-Flags .long(options::OFLAG) .takes_value(true) .multiple_occurrences(true) - .use_delimiter(true) - .require_delimiter(true) + .use_value_delimiter(true) + .require_value_delimiter(true) .multiple_values(true) .require_equals(true) .value_name("FLAG") diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 338648e10..466d027bc 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -15,7 +15,7 @@ use uucore::error::{UResult, USimpleError}; use uucore::format_usage; use uucore::fsext::{read_fs_list, MountInfo}; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::fmt; use std::path::Path; @@ -316,12 +316,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_ALL) .short('a') @@ -385,7 +385,7 @@ pub fn uu_app<'a>() -> App<'a> { Arg::new(OPT_OUTPUT) .long("output") .takes_value(true) - .use_delimiter(true) + .use_value_delimiter(true) .possible_values(OUTPUT_FIELD_LIST) .default_missing_values(&OUTPUT_FIELD_LIST) .default_values(&["source", "size", "used", "avail", "pcent", "target"]) @@ -428,7 +428,7 @@ pub fn uu_app<'a>() -> App<'a> { .long("exclude-type") .allow_invalid_utf8(true) .takes_value(true) - .use_delimiter(true) + .use_value_delimiter(true) .multiple_occurrences(true) .help("limit listing to file systems not of type TYPE"), ) diff --git a/src/uu/dircolors/src/dircolors.rs b/src/uu/dircolors/src/dircolors.rs index dcc832ece..c76dbc0c1 100644 --- a/src/uu/dircolors/src/dircolors.rs +++ b/src/uu/dircolors/src/dircolors.rs @@ -13,7 +13,7 @@ use std::env; use std::fs::File; use std::io::{BufRead, BufReader}; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use uucore::display::Quotable; use uucore::error::{UResult, USimpleError, UUsageError}; @@ -154,13 +154,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) .after_help(LONG_HELP) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::BOURNE_SHELL) .long("sh") diff --git a/src/uu/dirname/src/dirname.rs b/src/uu/dirname/src/dirname.rs index ad370aacf..030c3981c 100644 --- a/src/uu/dirname/src/dirname.rs +++ b/src/uu/dirname/src/dirname.rs @@ -5,7 +5,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::path::Path; use uucore::display::print_verbatim; use uucore::error::{UResult, UUsageError}; @@ -76,12 +76,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .about(ABOUT) .version(crate_version!()) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::ZERO) .long(options::ZERO) diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 0bb1abf4a..8d97b8b47 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -10,7 +10,7 @@ extern crate uucore; use chrono::prelude::DateTime; use chrono::Local; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::collections::HashSet; use std::env; use std::fs; @@ -617,13 +617,13 @@ fn parse_depth(max_depth_str: Option<&str>, summarize: bool) -> UResult() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) .after_help(LONG_HELP) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::ALL) .short('a') diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index 54a606c31..d2de30cb1 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -6,7 +6,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::io::{self, Write}; use std::iter::Peekable; use std::str::Chars; @@ -126,15 +126,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .map_err_context(|| "could not write to stdout".to_string()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) // TrailingVarArg specifies the final positional argument is a VarArg // and it doesn't attempts the parse any further args. // Final argument must have multiple(true) or the usage string equivalent. - .setting(AppSettings::TrailingVarArg) - .setting(AppSettings::AllowHyphenValues) - .setting(AppSettings::InferLongArgs) + .trailing_var_arg(true) + .allow_hyphen_values(true) + .infer_long_args(true) .version(crate_version!()) .about(SUMMARY) .after_help(AFTER_HELP) diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index 136100413..b78b5f224 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -16,13 +16,13 @@ extern crate clap; #[macro_use] extern crate uucore; -use clap::{App, AppSettings, Arg}; +use clap::{Arg, Command}; use ini::Ini; use std::borrow::Cow; use std::env; use std::io::{self, Write}; use std::iter::Iterator; -use std::process::Command; +use std::process; use uucore::display::Quotable; use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::format_usage; @@ -121,15 +121,15 @@ fn build_command<'a, 'b>(args: &'a mut Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b (progname, &args[..]) } -pub fn uu_app<'a>() -> App<'a> { - App::new(crate_name!()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(crate_name!()) .version(crate_version!()) .author(crate_authors!()) .about(crate_description!()) .override_usage(format_usage(USAGE)) .after_help(AFTER_HELP) - .setting(AppSettings::AllowExternalSubcommands) - .setting(AppSettings::InferLongArgs) + .allow_external_subcommands(true) + .infer_long_args(true) .arg(Arg::new("ignore-environment") .short('i') .long("ignore-environment") @@ -307,7 +307,7 @@ fn run_env(args: impl uucore::Args) -> UResult<()> { * standard library contains many checks and fail-safes to ensure the process ends up being * created. This is much simpler than dealing with the hassles of calling execvp directly. */ - match Command::new(&*prog).args(args).status() { + match process::Command::new(&*prog).args(args).status() { Ok(exit) if !exit.success() => return Err(exit.code().unwrap().into()), Err(ref err) if err.kind() == io::ErrorKind::NotFound => return Err(127.into()), Err(_) => return Err(126.into()), diff --git a/src/uu/expand/src/expand.rs b/src/uu/expand/src/expand.rs index c2bf98093..b9d9309cd 100644 --- a/src/uu/expand/src/expand.rs +++ b/src/uu/expand/src/expand.rs @@ -12,7 +12,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::fs::File; use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write}; use std::str::from_utf8; @@ -176,13 +176,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { expand(&Options::new(&matches)).map_err_context(|| "failed to write output".to_string()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::INITIAL) .long(options::INITIAL) diff --git a/src/uu/expr/src/expr.rs b/src/uu/expr/src/expr.rs index 188537fbc..f202b091c 100644 --- a/src/uu/expr/src/expr.rs +++ b/src/uu/expr/src/expr.rs @@ -5,7 +5,7 @@ //* For the full copyright and license information, please view the LICENSE //* file that was distributed with this source code. -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use uucore::error::{UResult, USimpleError}; use uucore::InvalidEncodingHandling; @@ -19,12 +19,12 @@ static USAGE: &str = r#" expr [EXPRESSION] expr [OPTIONS]"#; -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(USAGE) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(VERSION) .long(VERSION) diff --git a/src/uu/factor/src/cli.rs b/src/uu/factor/src/cli.rs index 90f2fd3c8..f78e410ba 100644 --- a/src/uu/factor/src/cli.rs +++ b/src/uu/factor/src/cli.rs @@ -14,7 +14,7 @@ use std::fmt::Write as FmtWrite; use std::io::{self, stdin, stdout, BufRead, Write}; mod factor; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; pub use factor::*; use uucore::display::Quotable; use uucore::error::UResult; @@ -77,10 +77,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg(Arg::new(options::NUMBER).multiple_occurrences(true)) } diff --git a/src/uu/false/src/false.rs b/src/uu/false/src/false.rs index c6661dc35..687235f70 100644 --- a/src/uu/false/src/false.rs +++ b/src/uu/false/src/false.rs @@ -4,7 +4,7 @@ // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -use clap::{App, AppSettings, Arg}; +use clap::{Arg, Command}; use std::io::Write; use uucore::error::{set_exit_code, UResult}; @@ -18,7 +18,7 @@ the program will also return `1`. #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let mut app = uu_app(); + let mut command = uu_app(); // Mirror GNU options, always return `1`. In particular even the 'successful' cases of no-op, // and the interrupted display of help and version should return `1`. Also, we return Ok in all @@ -26,11 +26,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // and unwind through the standard library allocation handling machinery. set_exit_code(1); - if let Ok(matches) = app.try_get_matches_from_mut(args) { + if let Ok(matches) = command.try_get_matches_from_mut(args) { let error = if matches.index_of("help").is_some() { - app.print_long_help() + command.print_long_help() } else if matches.index_of("version").is_some() { - writeln!(std::io::stdout(), "{}", app.render_version()) + writeln!(std::io::stdout(), "{}", command.render_version()) } else { Ok(()) }; @@ -45,12 +45,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(clap::crate_version!()) .about(ABOUT) // We provide our own help and version options, to ensure maximum compatibility with GNU. - .setting(AppSettings::DisableHelpFlag | AppSettings::DisableVersionFlag) + .disable_help_flag(true) + .disable_version_flag(true) .arg( Arg::new("help") .long("help") diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index e53617dac..3cb851674 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::cmp; use std::fs::File; use std::io::{stdin, stdout, Write}; @@ -218,12 +218,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_CROWN_MARGIN) .short('c') diff --git a/src/uu/fold/src/fold.rs b/src/uu/fold/src/fold.rs index d217f0bea..d24d31be9 100644 --- a/src/uu/fold/src/fold.rs +++ b/src/uu/fold/src/fold.rs @@ -7,7 +7,7 @@ // spell-checker:ignore (ToDOs) ncount routput -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs::File; use std::io::{stdin, BufRead, BufReader, Read}; use std::path::Path; @@ -63,13 +63,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { fold(&files, bytes, spaces, width) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) .version(crate_version!()) .override_usage(format_usage(USAGE)) .about(SUMMARY) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::BYTES) .long(options::BYTES) diff --git a/src/uu/groups/src/groups.rs b/src/uu/groups/src/groups.rs index d4015fb50..e1bf99fbc 100644 --- a/src/uu/groups/src/groups.rs +++ b/src/uu/groups/src/groups.rs @@ -26,7 +26,7 @@ use uucore::{ format_usage, }; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; mod options { pub const USERS: &str = "USERNAME"; @@ -102,12 +102,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::USERS) .multiple_occurrences(true) diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index d92336702..fbfe1c1f2 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -20,7 +20,7 @@ mod digest; use self::digest::Digest; use self::digest::DigestWriter; -use clap::{App, AppSettings, Arg, ArgMatches}; +use clap::{Arg, ArgMatches, Command}; use hex::encode; use md5::Md5; use regex::Regex; @@ -297,13 +297,13 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { // Default binary in Windows, text mode otherwise let binary_flag_default = cfg!(windows); - let app = uu_app(&binary_name); + let command = uu_app(&binary_name); // FIXME: this should use try_get_matches_from() and crash!(), but at the moment that just // causes "error: " to be printed twice (once from crash!() and once from clap). With // the current setup, the name of the utility is not printed, but I think this is at // least somewhat better from a user's perspective. - let matches = app.get_matches_from(args); + let matches = command.get_matches_from(args); let (name, algo, bits) = detect_algo(&binary_name, &matches); @@ -340,7 +340,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app_common<'a>() -> App<'a> { +pub fn uu_app_common<'a>() -> Command<'a> { #[cfg(windows)] const BINARY_HELP: &str = "read in binary mode (default)"; #[cfg(not(windows))] @@ -349,10 +349,10 @@ pub fn uu_app_common<'a>() -> App<'a> { const TEXT_HELP: &str = "read in text mode"; #[cfg(not(windows))] const TEXT_HELP: &str = "read in text mode (default)"; - App::new(uucore::util_name()) + Command::new(uucore::util_name()) .version(crate_version!()) .about("Compute and check message digests.") - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new("binary") .short('b') @@ -419,8 +419,8 @@ pub fn uu_app_common<'a>() -> App<'a> { ) } -pub fn uu_app_custom<'a>() -> App<'a> { - let mut app = uu_app_common(); +pub fn uu_app_custom<'a>() -> Command<'a> { + let mut command = uu_app_common(); let algorithms = &[ ("md5", "work with MD5"), ("sha1", "work with SHA1"), @@ -446,14 +446,14 @@ pub fn uu_app_custom<'a>() -> App<'a> { ]; for (name, desc) in algorithms { - app = app.arg(Arg::new(*name).long(name).help(*desc)); + command = command.arg(Arg::new(*name).long(name).help(*desc)); } - app + command } // hashsum is handled differently in build.rs, therefore this is not the same // as in other utilities. -fn uu_app<'a>(binary_name: &str) -> App<'a> { +fn uu_app<'a>(binary_name: &str) -> Command<'a> { if !is_custom_binary(binary_name) { uu_app_custom() } else { diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index 3bde78ec7..14780aa3c 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -5,7 +5,7 @@ // spell-checker:ignore (vars) zlines BUFWRITER seekable -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::convert::{TryFrom, TryInto}; use std::ffi::OsString; use std::io::{self, BufWriter, ErrorKind, Read, Seek, SeekFrom, Write}; @@ -41,12 +41,12 @@ mod take; use take::take_all_but; use take::take_lines; -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::BYTES_NAME) .short('c') diff --git a/src/uu/hostid/src/hostid.rs b/src/uu/hostid/src/hostid.rs index a82bb5e69..b60446e9f 100644 --- a/src/uu/hostid/src/hostid.rs +++ b/src/uu/hostid/src/hostid.rs @@ -7,7 +7,7 @@ // spell-checker:ignore (ToDO) gethostid -use clap::{crate_version, App, AppSettings}; +use clap::{crate_version, Command}; use libc::c_long; use uucore::{error::UResult, format_usage}; @@ -26,12 +26,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(SUMMARY) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) } fn hostid() { diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs index b45b4b1d8..757caed02 100644 --- a/src/uu/hostname/src/hostname.rs +++ b/src/uu/hostname/src/hostname.rs @@ -11,7 +11,7 @@ use std::collections::hash_set::HashSet; use std::net::ToSocketAddrs; use std::str; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use uucore::{ error::{FromIo, UResult}, @@ -71,12 +71,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_DOMAIN) .short('d') diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index b1da51173..3bb9ce8c9 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -39,7 +39,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::ffi::CStr; use uucore::display::Quotable; use uucore::entries::{self, Group, Locate, Passwd}; @@ -341,12 +341,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::OPT_AUDIT) .short('A') diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index 9b72627fa..28d1aa702 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -12,7 +12,7 @@ mod mode; #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use file_diff::diff; use filetime::{set_file_times, FileTime}; use uucore::backup_control::{self, BackupMode}; @@ -30,7 +30,7 @@ use std::fs; use std::fs::File; use std::os::unix::fs::MetadataExt; use std::path::{Path, PathBuf}; -use std::process::Command; +use std::process; const DEFAULT_MODE: u32 = 0o755; const DEFAULT_STRIP_PROGRAM: &str = "strip"; @@ -188,12 +188,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( backup_control::arguments::backup() ) @@ -585,7 +585,7 @@ fn copy(from: &Path, to: &Path, b: &Behavior) -> UResult<()> { } if b.strip && cfg!(not(windows)) { - match Command::new(&b.strip_program).arg(to).output() { + match process::Command::new(&b.strip_program).arg(to).output() { Ok(o) => { if !o.status.success() { return Err(InstallError::StripProgramFailed( diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index e5abefba4..1d306415b 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use memchr::{memchr3_iter, memchr_iter}; use std::cmp::Ordering; use std::convert::From; @@ -697,8 +697,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(NAME) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(NAME) .version(crate_version!()) .about( "For each pair of input lines with identical join fields, write a line to @@ -706,7 +706,7 @@ standard output. The default join field is the first, delimited by blanks. When FILE1 or FILE2 (not both) is -, read standard input.", ) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new("a") .short('a') diff --git a/src/uu/kill/src/kill.rs b/src/uu/kill/src/kill.rs index 2d0490921..df868e418 100644 --- a/src/uu/kill/src/kill.rs +++ b/src/uu/kill/src/kill.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use libc::{c_int, pid_t}; use std::io::Error; use uucore::display::Quotable; @@ -78,12 +78,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::LIST) .short('l') diff --git a/src/uu/link/src/link.rs b/src/uu/link/src/link.rs index 9d515ee8a..3c959af33 100644 --- a/src/uu/link/src/link.rs +++ b/src/uu/link/src/link.rs @@ -4,7 +4,7 @@ // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs::hard_link; use std::path::Path; use uucore::display::Quotable; @@ -33,12 +33,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .map_err_context(|| format!("cannot create link {} to {}", new.quote(), old.quote())) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::FILES) .hide(true) diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index ec4868876..2fc478a23 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use uucore::display::Quotable; use uucore::error::{UError, UResult}; use uucore::format_usage; @@ -173,12 +173,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { exec(&paths[..], &settings) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg(backup_control::arguments::backup()) .arg(backup_control::arguments::backup_no_args()) // TODO: opts.arg( diff --git a/src/uu/logname/src/logname.rs b/src/uu/logname/src/logname.rs index 64ad5e9bc..31246b5c7 100644 --- a/src/uu/logname/src/logname.rs +++ b/src/uu/logname/src/logname.rs @@ -12,7 +12,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings}; +use clap::{crate_version, Command}; use std::ffi::CStr; use uucore::error::UResult; use uucore::InvalidEncodingHandling; @@ -51,10 +51,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .override_usage(uucore::execution_phrase()) .about(SUMMARY) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) } diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 9353d1f6b..a7dbc7b42 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -15,7 +15,7 @@ extern crate lazy_static; mod quoting_style; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use glob::Pattern; use lscolors::LsColors; use number_prefix::NumberPrefix; @@ -782,9 +782,9 @@ impl Config { #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let app = uu_app(); + let command = uu_app(); - let matches = app.get_matches_from(args); + let matches = command.get_matches_from(args); let config = Config::from(&matches)?; @@ -796,8 +796,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { list(locs, &config) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .override_usage(format_usage(USAGE)) .about( @@ -805,7 +805,7 @@ pub fn uu_app<'a>() -> App<'a> { the command line, expect that it will ignore files and directories \ whose names start with '.'.", ) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) // Format arguments .arg( Arg::new(options::FORMAT) diff --git a/src/uu/mkdir/src/mkdir.rs b/src/uu/mkdir/src/mkdir.rs index 14b1ebaf5..ed487bb58 100644 --- a/src/uu/mkdir/src/mkdir.rs +++ b/src/uu/mkdir/src/mkdir.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches, OsValues}; +use clap::{crate_version, Arg, ArgMatches, Command, OsValues}; use std::path::Path; use uucore::display::Quotable; #[cfg(not(windows))] @@ -104,12 +104,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::MODE) .short('m') diff --git a/src/uu/mkfifo/src/mkfifo.rs b/src/uu/mkfifo/src/mkfifo.rs index 2ac316f9d..756fd75cf 100644 --- a/src/uu/mkfifo/src/mkfifo.rs +++ b/src/uu/mkfifo/src/mkfifo.rs @@ -8,7 +8,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use libc::mkfifo; use std::ffi::CString; use uucore::error::{UResult, USimpleError}; @@ -70,13 +70,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) .version(crate_version!()) .override_usage(format_usage(USAGE)) .about(SUMMARY) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::MODE) .short('m') diff --git a/src/uu/mknod/src/mknod.rs b/src/uu/mknod/src/mknod.rs index a27a48056..0e7c4be45 100644 --- a/src/uu/mknod/src/mknod.rs +++ b/src/uu/mknod/src/mknod.rs @@ -9,7 +9,7 @@ use std::ffi::CString; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use libc::{dev_t, mode_t}; use libc::{S_IFBLK, S_IFCHR, S_IFIFO, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR}; @@ -143,13 +143,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .override_usage(format_usage(USAGE)) .after_help(LONG_HELP) .about(ABOUT) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new("mode") .short('m') diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index 54d3ac651..54283b9af 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -8,7 +8,7 @@ // spell-checker:ignore (paths) GPGHome -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use uucore::display::{println_verbatim, Quotable}; use uucore::error::{FromIo, UError, UResult}; use uucore::format_usage; @@ -131,12 +131,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_DIRECTORY) .short('d') diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index db6ad249b..ab94bd435 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -17,7 +17,7 @@ use std::{ #[cfg(all(unix, not(target_os = "fuchsia")))] extern crate nix; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use crossterm::{ event::{self, Event, KeyCode, KeyEvent, KeyModifiers}, execute, queue, @@ -96,11 +96,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .about("A file perusal filter for CRT viewing.") .version(crate_version!()) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::SILENT) .short('d') diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index c02f70dbd..60cff5dfb 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -13,7 +13,7 @@ mod error; #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::env; use std::ffi::OsString; use std::fs; @@ -112,12 +112,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { exec(&files[..], &behavior) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( backup_control::arguments::backup() ) diff --git a/src/uu/nice/src/nice.rs b/src/uu/nice/src/nice.rs index 94ccbe61e..b75dd979e 100644 --- a/src/uu/nice/src/nice.rs +++ b/src/uu/nice/src/nice.rs @@ -15,7 +15,7 @@ use std::ffi::CString; use std::io::Error; use std::ptr; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use uucore::{ error::{set_exit_code, UResult, USimpleError, UUsageError}, format_usage, @@ -102,12 +102,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::TrailingVarArg) - .setting(AppSettings::InferLongArgs) + .trailing_var_arg(true) + .infer_long_args(true) .version(crate_version!()) .arg( Arg::new(options::ADJUSTMENT) diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index c1661178f..09ad9a816 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -8,7 +8,7 @@ // spell-checker:ignore (ToDO) corasick memchr -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs::File; use std::io::{stdin, BufRead, BufReader, Read}; use std::iter::repeat; @@ -139,12 +139,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) .version(crate_version!()) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::FILE) .hide(true) diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index c7c7350cc..c2593f8ea 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use libc::{c_char, dup2, execvp, signal}; use libc::{SIGHUP, SIG_IGN}; use std::env; @@ -116,8 +116,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) @@ -128,8 +128,8 @@ pub fn uu_app<'a>() -> App<'a> { .required(true) .multiple_occurrences(true), ) - .setting(AppSettings::TrailingVarArg) - .setting(AppSettings::InferLongArgs) + .trailing_var_arg(true) + .infer_long_args(true) } fn replace_fds() -> UResult<()> { diff --git a/src/uu/nproc/src/nproc.rs b/src/uu/nproc/src/nproc.rs index f10b41e40..fdebea65a 100644 --- a/src/uu/nproc/src/nproc.rs +++ b/src/uu/nproc/src/nproc.rs @@ -7,7 +7,7 @@ // spell-checker:ignore (ToDO) NPROCESSORS nprocs numstr threadstr sysconf -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::env; use uucore::display::Quotable; use uucore::error::{UResult, USimpleError}; @@ -68,12 +68,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_ALL) .long(OPT_ALL) diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index 516d7a4df..1b3ab3950 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -11,7 +11,7 @@ use crate::errors::*; use crate::format::format_and_print; use crate::options::*; use crate::units::{Result, Unit}; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::io::{BufRead, Write}; use uucore::display::Quotable; use uucore::error::UResult; @@ -186,14 +186,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) .override_usage(format_usage(USAGE)) - .setting(AppSettings::AllowNegativeNumbers) - .setting(AppSettings::InferLongArgs) + .allow_negative_numbers(true) + .infer_long_args(true) .arg( Arg::new(options::DELIMITER) .short('d') diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index 3bbe3ab5d..eeca0171a 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -5,7 +5,7 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -// spell-checker:ignore (clap) DontDelimitTrailingValues +// spell-checker:ignore (clap) dont // spell-checker:ignore (ToDO) formatteriteminfo inputdecoder inputoffset mockstream nrofbytes partialreader odfunc multifile exitcode #[macro_use] @@ -43,7 +43,7 @@ use crate::parse_nrofbytes::parse_number_of_bytes; use crate::partialreader::*; use crate::peekreader::*; use crate::prn_char::format_ascii_dump; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, AppSettings, Arg, ArgMatches, Command}; use uucore::display::Quotable; use uucore::error::{UResult, USimpleError}; use uucore::format_usage; @@ -289,18 +289,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { odfunc(&mut input_offset, &mut input_decoder, &output_info) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) .after_help(LONG_HELP) - .setting( - AppSettings::TrailingVarArg | - AppSettings::DontDelimitTrailingValues | - AppSettings::DeriveDisplayOrder | - AppSettings::InferLongArgs - ) + .trailing_var_arg(true) + .dont_delimit_trailing_values(true) + .infer_long_args(true) + .setting(AppSettings::DeriveDisplayOrder) .arg( Arg::new(options::ADDRESS_RADIX) .short('A') diff --git a/src/uu/paste/src/paste.rs b/src/uu/paste/src/paste.rs index dc93ae625..2826a19e3 100644 --- a/src/uu/paste/src/paste.rs +++ b/src/uu/paste/src/paste.rs @@ -7,7 +7,7 @@ // spell-checker:ignore (ToDO) delim -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs::File; use std::io::{stdin, stdout, BufRead, BufReader, Read, Write}; use std::path::Path; @@ -47,11 +47,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { paste(files, serial, delimiters) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::SERIAL) .long(options::SERIAL) diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index 2d72d4a5a..6260590aa 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -8,7 +8,7 @@ // * that was distributed with this source code. // spell-checker:ignore (ToDO) lstat -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs; use std::io::{ErrorKind, Write}; use uucore::display::Quotable; @@ -84,12 +84,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::POSIX) .short('p') diff --git a/src/uu/pinky/src/pinky.rs b/src/uu/pinky/src/pinky.rs index 02ad09d20..b5ad2c5c9 100644 --- a/src/uu/pinky/src/pinky.rs +++ b/src/uu/pinky/src/pinky.rs @@ -18,7 +18,7 @@ use std::io::BufReader; use std::fs::File; use std::os::unix::fs::MetadataExt; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::path::PathBuf; use uucore::{format_usage, InvalidEncodingHandling}; @@ -123,12 +123,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::LONG_FORMAT) .short('l') diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 79baf72c9..e18d29730 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -11,7 +11,7 @@ extern crate quick_error; use chrono::offset::Local; use chrono::DateTime; -use clap::{App, AppSettings, Arg, ArgMatches}; +use clap::{AppSettings, Arg, ArgMatches, Command}; use itertools::Itertools; use quick_error::ResultExt; use regex::Regex; @@ -192,13 +192,13 @@ quick_error! { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(VERSION) .about(ABOUT) .after_help(AFTER_HELP) - .setting(AppSettings::InferLongArgs) - .setting(AppSettings::AllArgsOverrideSelf) + .infer_long_args(true) + .args_override_self(true) .setting(AppSettings::NoAutoHelp) .setting(AppSettings::NoAutoVersion) .arg( @@ -383,8 +383,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let opt_args = recreate_arguments(&args); - let mut app = uu_app(); - let matches = match app.try_get_matches_from_mut(opt_args) { + let mut command = uu_app(); + let matches = match command.try_get_matches_from_mut(opt_args) { Ok(m) => m, Err(e) => { e.print()?; @@ -394,12 +394,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { }; if matches.is_present(options::VERSION) { - println!("{}", app.render_long_version()); + println!("{}", command.render_long_version()); return Ok(()); } if matches.is_present(options::HELP) { - app.print_long_help()?; + command.print_long_help()?; return Ok(()); } diff --git a/src/uu/printenv/src/printenv.rs b/src/uu/printenv/src/printenv.rs index cb24299cc..c5832c4df 100644 --- a/src/uu/printenv/src/printenv.rs +++ b/src/uu/printenv/src/printenv.rs @@ -7,7 +7,7 @@ /* last synced with: printenv (GNU coreutils) 8.13 */ -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::env; use uucore::{error::UResult, format_usage}; @@ -56,12 +56,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_NULL) .short('0') diff --git a/src/uu/printf/src/printf.rs b/src/uu/printf/src/printf.rs index 2dbc7f996..662db1ed5 100644 --- a/src/uu/printf/src/printf.rs +++ b/src/uu/printf/src/printf.rs @@ -2,7 +2,7 @@ // spell-checker:ignore (change!) each's // spell-checker:ignore (ToDO) LONGHELP FORMATSTRING templating parameterizing formatstr -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use uucore::error::{UResult, UUsageError}; use uucore::InvalidEncodingHandling; use uucore::{format_usage, memo}; @@ -288,9 +288,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) - .setting(AppSettings::AllowHyphenValues) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) + .allow_hyphen_values(true) .version(crate_version!()) .about(ABOUT) .after_help(AFTER_HELP) diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index 20a2b13f2..9c3aee133 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -7,7 +7,7 @@ // spell-checker:ignore (ToDOs) corasick memchr Roff trunc oset iset -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use regex::Regex; use std::cmp; use std::collections::{BTreeSet, HashMap, HashSet}; @@ -702,13 +702,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { write_traditional_output(&config, &file_map, &word_set, &output_file) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) .about(ABOUT) .version(crate_version!()) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::FILE) .hide(true) diff --git a/src/uu/pwd/src/pwd.rs b/src/uu/pwd/src/pwd.rs index 28487545c..67462ac16 100644 --- a/src/uu/pwd/src/pwd.rs +++ b/src/uu/pwd/src/pwd.rs @@ -5,7 +5,7 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::env; use std::io; use std::path::PathBuf; @@ -148,12 +148,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_LOGICAL) .short('L') diff --git a/src/uu/readlink/src/readlink.rs b/src/uu/readlink/src/readlink.rs index adbae7a27..ba1e368f2 100644 --- a/src/uu/readlink/src/readlink.rs +++ b/src/uu/readlink/src/readlink.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs; use std::io::{stdout, Write}; use std::path::{Path, PathBuf}; @@ -95,12 +95,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_help(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_CANONICALIZE) .short('f') diff --git a/src/uu/realpath/src/realpath.rs b/src/uu/realpath/src/realpath.rs index 4a42930f3..bea89c19e 100644 --- a/src/uu/realpath/src/realpath.rs +++ b/src/uu/realpath/src/realpath.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::{ io::{stdout, Write}, path::{Path, PathBuf}, @@ -70,12 +70,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_QUIET) .short('q') diff --git a/src/uu/relpath/src/relpath.rs b/src/uu/relpath/src/relpath.rs index a7da7a956..2e45ce927 100644 --- a/src/uu/relpath/src/relpath.rs +++ b/src/uu/relpath/src/relpath.rs @@ -7,7 +7,7 @@ // spell-checker:ignore (ToDO) subpath absto absfrom absbase -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::env; use std::path::{Path, PathBuf}; use uucore::display::println_verbatim; @@ -78,12 +78,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { println_verbatim(result).map_err_context(String::new) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg(Arg::new(options::DIR).short('d').takes_value(true).help( "If any of FROM and TO is not subpath of DIR, output absolute path instead of relative", )) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 9179c6d9f..a1924b41d 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use remove_dir_all::remove_dir_all; use std::collections::VecDeque; use std::fs; @@ -139,12 +139,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_FORCE) .short('f') diff --git a/src/uu/rmdir/src/rmdir.rs b/src/uu/rmdir/src/rmdir.rs index bdb6ab60d..127b8fcf9 100644 --- a/src/uu/rmdir/src/rmdir.rs +++ b/src/uu/rmdir/src/rmdir.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs::{read_dir, remove_dir}; use std::io; use std::path::Path; @@ -170,12 +170,12 @@ struct Opts { verbose: bool, } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_IGNORE_FAIL_NON_EMPTY) .long(OPT_IGNORE_FAIL_NON_EMPTY) diff --git a/src/uu/runcon/src/runcon.rs b/src/uu/runcon/src/runcon.rs index 55186d218..8c20319be 100644 --- a/src/uu/runcon/src/runcon.rs +++ b/src/uu/runcon/src/runcon.rs @@ -2,7 +2,7 @@ use uucore::error::{UResult, UUsageError}; -use clap::{App, AppSettings, Arg}; +use clap::{Arg, Command}; use selinux::{OpaqueSecurityContext, SecurityClass, SecurityContext}; use uucore::format_usage; @@ -48,7 +48,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(r) => r, Err(r) => { if let Error::CommandLine(ref r) = r { - match r.kind { + match r.kind() { clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => { println!("{}", r); return Ok(()); @@ -103,13 +103,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(VERSION) .about(ABOUT) .after_help(DESCRIPTION) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::COMPUTE) .short('c') @@ -162,7 +162,7 @@ pub fn uu_app<'a>() -> App<'a> { // // This is not how POSIX does things, but this is how the GNU implementation // parses its command line. - .setting(clap::AppSettings::TrailingVarArg) + .trailing_var_arg(true) } #[derive(Debug)] @@ -205,7 +205,7 @@ struct Options { arguments: Vec, } -fn parse_command_line(config: App, args: impl uucore::Args) -> Result { +fn parse_command_line(config: Command, args: impl uucore::Args) -> Result { let matches = config.try_get_matches_from(args)?; let compute_transition_context = matches.is_present(options::COMPUTE); diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index 788583a72..851857ea1 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -7,7 +7,7 @@ use std::io::{stdout, ErrorKind, Write}; use std::process::exit; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use num_traits::Zero; use uucore::error::FromIo; @@ -141,11 +141,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) - .setting(AppSettings::TrailingVarArg) - .setting(AppSettings::AllowNegativeNumbers) - .setting(AppSettings::InferLongArgs) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) + .trailing_var_arg(true) + .allow_negative_numbers(true) + .infer_long_args(true) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 5c545e8e7..05c8d1805 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -8,7 +8,7 @@ // spell-checker:ignore (words) writeback wipesync -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use rand::prelude::SliceRandom; use rand::Rng; use std::cell::{Cell, RefCell}; @@ -314,13 +314,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(AFTER_HELP) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::FORCE) .long(options::FORCE) diff --git a/src/uu/shuf/src/shuf.rs b/src/uu/shuf/src/shuf.rs index c331d7867..6a3e325c7 100644 --- a/src/uu/shuf/src/shuf.rs +++ b/src/uu/shuf/src/shuf.rs @@ -7,7 +7,7 @@ // spell-checker:ignore (ToDO) cmdline evec seps rvec fdata -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use rand::prelude::SliceRandom; use rand::RngCore; use std::fs::File; @@ -119,13 +119,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) .about(ABOUT) .version(crate_version!()) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::ECHO) .short('e') @@ -134,7 +134,7 @@ pub fn uu_app<'a>() -> App<'a> { .value_name("ARG") .help("treat each ARG as an input line") .multiple_occurrences(true) - .use_delimiter(false) + .use_value_delimiter(false) .min_values(0) .conflicts_with(options::INPUT_RANGE), ) diff --git a/src/uu/sleep/src/sleep.rs b/src/uu/sleep/src/sleep.rs index 0c8de143e..2ac6275a6 100644 --- a/src/uu/sleep/src/sleep.rs +++ b/src/uu/sleep/src/sleep.rs @@ -13,7 +13,7 @@ use uucore::{ format_usage, }; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; static ABOUT: &str = "Pause for NUMBER seconds."; const USAGE: &str = "\ @@ -41,13 +41,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::NUMBER) .help("pause for NUMBER seconds") diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 1c118b15a..70cebad4f 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -25,7 +25,7 @@ mod numeric_str_cmp; mod tmp_dir; use chunks::LineData; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use custom_str_cmp::custom_str_cmp; use ext_sort::ext_sort; use fnv::FnvHasher; @@ -1268,12 +1268,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { exec(&mut files, &settings, output, &mut tmp_dir) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::modes::SORT) .long(options::modes::SORT) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index fb8c44dcb..6cb7c629a 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -13,7 +13,7 @@ mod platform; use crate::filenames::FilenameIterator; use crate::filenames::SuffixType; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::convert::TryInto; use std::env; use std::fmt; @@ -62,13 +62,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about("Create output files containing consecutive or interleaved sections of input") .after_help(AFTER_HELP) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) // strategy (mutually exclusive) .arg( Arg::new(OPT_BYTES) diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 569c94d96..7d1073020 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -16,7 +16,7 @@ use uucore::fsext::{ use uucore::libc::mode_t; use uucore::{entries, format_usage}; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::borrow::Cow; use std::convert::AsRef; use std::os::unix::fs::{FileTypeExt, MetadataExt}; @@ -967,12 +967,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::DEREFERENCE) .short('L') diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index 8bd28b626..2eedb038b 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -10,13 +10,13 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::convert::{TryFrom, TryInto}; use std::fs::File; use std::io::{self, Write}; use std::os::unix::process::ExitStatusExt; use std::path::PathBuf; -use std::process::Command; +use std::process; use tempfile::tempdir; use tempfile::TempDir; use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; @@ -131,7 +131,7 @@ fn check_option(matches: &ArgMatches, name: &str) -> Result { command.env(buffer_name, m.to_string()); @@ -164,7 +164,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let options = ProgramOptions::try_from(&matches).map_err(|e| UUsageError::new(125, e.0))?; let mut command_values = matches.values_of::<&str>(options::COMMAND).unwrap(); - let mut command = Command::new(command_values.next().unwrap()); + let mut command = process::Command::new(command_values.next().unwrap()); let command_params: Vec<&str> = command_values.collect(); let mut tmp_dir = tempdir().unwrap(); @@ -194,14 +194,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .after_help(LONG_HELP) .override_usage(format_usage(USAGE)) - .setting(AppSettings::TrailingVarArg) - .setting(AppSettings::InferLongArgs) + .trailing_var_arg(true) + .infer_long_args(true) .arg( Arg::new(options::INPUT) .long(options::INPUT) diff --git a/src/uu/sum/src/sum.rs b/src/uu/sum/src/sum.rs index 4dacf61cb..501635910 100644 --- a/src/uu/sum/src/sum.rs +++ b/src/uu/sum/src/sum.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs::File; use std::io::{stdin, Read}; use std::path::Path; @@ -140,13 +140,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) .version(crate_version!()) .override_usage(format_usage(USAGE)) .about(SUMMARY) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::FILE) .multiple_occurrences(true) diff --git a/src/uu/sync/src/sync.rs b/src/uu/sync/src/sync.rs index 773e49479..f9c18d500 100644 --- a/src/uu/sync/src/sync.rs +++ b/src/uu/sync/src/sync.rs @@ -9,7 +9,7 @@ extern crate libc; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::path::Path; use uucore::display::Quotable; use uucore::error::{UResult, USimpleError}; @@ -190,12 +190,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::FILE_SYSTEM) .short('f') diff --git a/src/uu/tac/src/tac.rs b/src/uu/tac/src/tac.rs index 925968f74..3151b97e2 100644 --- a/src/uu/tac/src/tac.rs +++ b/src/uu/tac/src/tac.rs @@ -8,7 +8,7 @@ // spell-checker:ignore (ToDO) sbytes slen dlen memmem memmap Mmap mmap SIGBUS mod error; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use memchr::memmem; use memmap2::Mmap; use std::io::{stdin, stdout, BufWriter, Read, Write}; @@ -60,13 +60,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { tac(&files, before, regex, separator) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) .version(crate_version!()) .override_usage(format_usage(USAGE)) .about(SUMMARY) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::BEFORE) .short('b') diff --git a/src/uu/tail/src/tail.rs b/src/uu/tail/src/tail.rs index 27153117c..bbbc9810d 100644 --- a/src/uu/tail/src/tail.rs +++ b/src/uu/tail/src/tail.rs @@ -20,7 +20,7 @@ mod parse; mod platform; use chunks::ReverseChunks; -use clap::{App, AppSettings, Arg}; +use clap::{Arg, Command}; use std::collections::VecDeque; use std::convert::TryInto; use std::ffi::OsString; @@ -275,12 +275,12 @@ fn arg_iterate<'a>( } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::BYTES) .short('c') diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index a1ba6b201..d9c2e78f1 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -8,7 +8,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use retain_mut::RetainMut; use std::fs::OpenOptions; use std::io::{copy, sink, stdin, stdout, Error, ErrorKind, Read, Result, Write}; @@ -55,13 +55,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) .after_help("If a FILE is -, it refers to a file named - .") - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::APPEND) .long(options::APPEND) diff --git a/src/uu/test/src/test.rs b/src/uu/test/src/test.rs index f91aaf8ea..e53ba4db1 100644 --- a/src/uu/test/src/test.rs +++ b/src/uu/test/src/test.rs @@ -10,7 +10,7 @@ mod parser; -use clap::{crate_version, App}; +use clap::{crate_version, Command}; use parser::{parse, Operator, Symbol, UnaryOperator}; use std::ffi::{OsStr, OsString}; use uucore::display::Quotable; @@ -90,8 +90,8 @@ for details about the options it supports."; const ABOUT: &str = "Check file types and compare values."; -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) @@ -108,7 +108,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { // If invoked as [ we should recognize --help and --version (but not -h or -v) if args.len() == 1 && (args[0] == "--help" || args[0] == "--version") { // Let clap pretty-print help and version - App::new(binary_name) + Command::new(binary_name) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index 3da0bcd2a..192892d4f 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -14,9 +14,9 @@ extern crate uucore; extern crate clap; use crate::status::ExitStatus; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::io::ErrorKind; -use std::process::{Child, Command, Stdio}; +use std::process::{self, Child, Stdio}; use std::time::Duration; use uucore::display::Quotable; use uucore::error::{UResult, USimpleError}; @@ -103,9 +103,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .collect_str(InvalidEncodingHandling::ConvertLossy) .accept_any(); - let app = uu_app(); + let command = uu_app(); - let matches = app.get_matches_from(args); + let matches = command.get_matches_from(args); let config = Config::from(&matches)?; timeout( @@ -119,8 +119,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { ) } -pub fn uu_app<'a>() -> App<'a> { - App::new("timeout") +pub fn uu_app<'a>() -> Command<'a> { + Command::new("timeout") .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) @@ -162,8 +162,8 @@ pub fn uu_app<'a>() -> App<'a> { .required(true) .multiple_occurrences(true) ) - .setting(AppSettings::TrailingVarArg) - .setting(AppSettings::InferLongArgs) + .trailing_var_arg(true) + .infer_long_args(true) } /// Remove pre-existing SIGCHLD handlers that would make waiting for the child's exit code fail. @@ -245,7 +245,7 @@ fn timeout( if !foreground { unsafe { libc::setpgid(0, 0) }; } - let mut process = Command::new(&cmd[0]) + let mut process = process::Command::new(&cmd[0]) .args(&cmd[1..]) .stdin(Stdio::inherit()) .stdout(Stdio::inherit()) diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index 2b56cdb95..220a8476e 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -13,7 +13,7 @@ pub extern crate filetime; #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg, ArgGroup}; +use clap::{crate_version, Arg, ArgGroup, Command}; use filetime::*; use std::fs::{self, File}; use std::path::{Path, PathBuf}; @@ -149,12 +149,12 @@ Try 'touch --help' for more information."##, Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::ACCESS) .short('a') diff --git a/src/uu/tr/src/tr.rs b/src/uu/tr/src/tr.rs index a92a7308a..dd8edc518 100644 --- a/src/uu/tr/src/tr.rs +++ b/src/uu/tr/src/tr.rs @@ -11,7 +11,7 @@ mod convert; mod operation; mod unicode_table; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use nom::AsBytes; use operation::{translate_input, Sequence, SqueezeOperation, TranslateOperation}; use std::io::{stdin, stdout, BufReader, BufWriter}; @@ -137,13 +137,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) + .infer_long_args(true) .arg( Arg::new(options::COMPLEMENT) .visible_short_alias('C') diff --git a/src/uu/true/src/true.rs b/src/uu/true/src/true.rs index 4a8452db6..57c3d2af5 100644 --- a/src/uu/true/src/true.rs +++ b/src/uu/true/src/true.rs @@ -4,7 +4,7 @@ // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -use clap::{App, AppSettings, Arg}; +use clap::{Arg, Command}; use std::io::Write; use uucore::error::{set_exit_code, UResult}; @@ -18,13 +18,13 @@ operation causes the program to return `1` instead. #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let mut app = uu_app(); + let mut command = uu_app(); - if let Ok(matches) = app.try_get_matches_from_mut(args) { + if let Ok(matches) = command.try_get_matches_from_mut(args) { let error = if matches.index_of("help").is_some() { - app.print_long_help() + command.print_long_help() } else if matches.index_of("version").is_some() { - writeln!(std::io::stdout(), "{}", app.render_version()) + writeln!(std::io::stdout(), "{}", command.render_version()) } else { Ok(()) }; @@ -42,12 +42,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(clap::crate_version!()) .about(ABOUT) // We provide our own help and version options, to ensure maximum compatibility with GNU. - .setting(AppSettings::DisableHelpFlag | AppSettings::DisableVersionFlag) + .disable_help_flag(true) + .disable_version_flag(true) .arg( Arg::new("help") .long("help") diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index b88040fb8..6c9d8197b 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -6,7 +6,7 @@ // * file that was distributed with this source code. // spell-checker:ignore (ToDO) RFILE refsize rfilename fsize tsize -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs::{metadata, OpenOptions}; use std::io::ErrorKind; #[cfg(unix)] @@ -115,7 +115,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .try_get_matches_from(args) .map_err(|e| { e.print().expect("Error writing clap::Error"); - match e.kind { + match e.kind() { clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => 0, _ => 1, } @@ -137,12 +137,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::IO_BLOCKS) .short('o') diff --git a/src/uu/tsort/src/tsort.rs b/src/uu/tsort/src/tsort.rs index 61cb95256..aecd492fe 100644 --- a/src/uu/tsort/src/tsort.rs +++ b/src/uu/tsort/src/tsort.rs @@ -5,7 +5,7 @@ // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::collections::{HashMap, HashSet}; use std::fs::File; use std::io::{stdin, BufRead, BufReader, Read}; @@ -93,12 +93,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .override_usage(format_usage(USAGE)) .about(SUMMARY) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg(Arg::new(options::FILE).default_value("-").hide(true)) } diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index e3d13b67d..b13b61784 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -9,7 +9,7 @@ // spell-checker:ignore (ToDO) ttyname filedesc -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::ffi::CStr; use std::io::Write; use uucore::error::{UResult, UUsageError}; @@ -66,12 +66,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::SILENT) .long(options::SILENT) diff --git a/src/uu/uname/src/uname.rs b/src/uu/uname/src/uname.rs index c5c2b8801..bff033047 100644 --- a/src/uu/uname/src/uname.rs +++ b/src/uu/uname/src/uname.rs @@ -10,7 +10,7 @@ // spell-checker:ignore (ToDO) nodename kernelname kernelrelease kernelversion sysname hwplatform mnrsv -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use platform_info::*; use uucore::{ error::{FromIo, UResult}, @@ -121,12 +121,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg(Arg::new(options::ALL) .short('a') .long(options::ALL) diff --git a/src/uu/unexpand/src/unexpand.rs b/src/uu/unexpand/src/unexpand.rs index 55bd51ad1..910ff91d3 100644 --- a/src/uu/unexpand/src/unexpand.rs +++ b/src/uu/unexpand/src/unexpand.rs @@ -11,7 +11,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::fs::File; use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Stdout, Write}; use std::str::from_utf8; @@ -102,13 +102,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { unexpand(&Options::new(&matches)).map_err_context(String::new) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .name(NAME) .version(crate_version!()) .override_usage(format_usage(USAGE)) .about(SUMMARY) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg(Arg::new(options::FILE).hide(true).multiple_occurrences(true)) .arg( Arg::new(options::ALL) diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index a22db42a9..020de0230 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -5,7 +5,7 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::fs::File; use std::io::{self, stdin, stdout, BufRead, BufReader, BufWriter, Read, Write}; use std::path::Path; @@ -290,12 +290,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { ) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::ALL_REPEATED) .short('D') diff --git a/src/uu/unlink/src/unlink.rs b/src/uu/unlink/src/unlink.rs index 65544612b..fc72b4623 100644 --- a/src/uu/unlink/src/unlink.rs +++ b/src/uu/unlink/src/unlink.rs @@ -10,7 +10,7 @@ use std::fs::remove_file; use std::path::Path; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use uucore::display::Quotable; use uucore::error::{FromIo, UResult}; @@ -27,11 +27,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { remove_file(path).map_err_context(|| format!("cannot unlink {}", path.quote())) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(OPT_PATH) .required(true) diff --git a/src/uu/uptime/src/uptime.rs b/src/uu/uptime/src/uptime.rs index ac9ba6d15..a93344dbc 100644 --- a/src/uu/uptime/src/uptime.rs +++ b/src/uu/uptime/src/uptime.rs @@ -9,7 +9,7 @@ // spell-checker:ignore (ToDO) getloadavg upsecs updays nusers loadavg boottime uphours upmins use chrono::{Local, TimeZone, Utc}; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use uucore::format_usage; // import crate time from utmpx @@ -59,12 +59,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::SINCE) .short('s') diff --git a/src/uu/users/src/users.rs b/src/uu/users/src/users.rs index 761080139..79fac3b68 100644 --- a/src/uu/users/src/users.rs +++ b/src/uu/users/src/users.rs @@ -10,7 +10,7 @@ use std::path::Path; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use uucore::error::UResult; use uucore::format_usage; use uucore::utmpx::{self, Utmpx}; @@ -58,11 +58,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg(Arg::new(ARG_FILES).takes_value(true).max_values(1)) } diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index a07877e0e..61eda6828 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -18,7 +18,7 @@ use utf8::{BufReadDecoder, BufReadDecoderError}; use uucore::format_usage; use word_count::{TitledWordCount, WordCount}; -use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; +use clap::{crate_version, Arg, ArgMatches, Command}; use std::cmp::max; use std::error::Error; @@ -183,12 +183,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { wc(&inputs, &settings) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::BYTES) .short('c') diff --git a/src/uu/who/src/who.rs b/src/uu/who/src/who.rs index 8c0a66c36..98ef06f47 100644 --- a/src/uu/who/src/who.rs +++ b/src/uu/who/src/who.rs @@ -12,7 +12,7 @@ use uucore::error::{FromIo, UResult}; use uucore::libc::{ttyname, STDIN_FILENO, S_IWGRP}; use uucore::utmpx::{self, time, Utmpx}; -use clap::{crate_version, App, AppSettings, Arg}; +use clap::{crate_version, Arg, Command}; use std::borrow::Cow; use std::ffi::CStr; use std::os::unix::fs::MetadataExt; @@ -151,12 +151,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { who.exec() } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) .arg( Arg::new(options::ALL) .long(options::ALL) diff --git a/src/uu/whoami/src/whoami.rs b/src/uu/whoami/src/whoami.rs index f55e026da..770802764 100644 --- a/src/uu/whoami/src/whoami.rs +++ b/src/uu/whoami/src/whoami.rs @@ -10,7 +10,7 @@ #[macro_use] extern crate clap; -use clap::{App, AppSettings}; +use clap::Command; use uucore::display::println_verbatim; use uucore::error::{FromIo, UResult}; @@ -27,9 +27,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> App<'a> { - App::new(uucore::util_name()) +pub fn uu_app<'a>() -> Command<'a> { + Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) } diff --git a/src/uu/yes/src/yes.rs b/src/uu/yes/src/yes.rs index b237fb857..879f60579 100644 --- a/src/uu/yes/src/yes.rs +++ b/src/uu/yes/src/yes.rs @@ -13,7 +13,7 @@ use std::io::{self, Write}; #[macro_use] extern crate clap; -use clap::{App, AppSettings, Arg}; +use clap::{Arg, Command}; use uucore::error::{UResult, USimpleError}; use uucore::format_usage; @@ -49,11 +49,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> App<'a> { - app_from_crate!() +pub fn uu_app<'a>() -> Command<'a> { + command!() .override_usage(format_usage(USAGE)) .arg(Arg::new("STRING").index(1).multiple_occurrences(true)) - .setting(AppSettings::InferLongArgs) + .infer_long_args(true) } fn prepare_buffer<'a>(input: &'a str, buffer: &'a mut [u8; BUF_SIZE]) -> &'a [u8] { diff --git a/src/uucore/src/lib/features/perms.rs b/src/uucore/src/lib/features/perms.rs index 942c67e29..970b2fca9 100644 --- a/src/uucore/src/lib/features/perms.rs +++ b/src/uucore/src/lib/features/perms.rs @@ -12,9 +12,9 @@ use crate::error::USimpleError; pub use crate::features::entries; use crate::fs::resolve_relative_path; use crate::show_error; -use clap::App; use clap::Arg; use clap::ArgMatches; +use clap::Command; use libc::{self, gid_t, uid_t}; use walkdir::WalkDir; @@ -414,13 +414,13 @@ type GidUidFilterParser = fn(&ArgMatches) -> UResult<(Option, Option, /// Base implementation for `chgrp` and `chown`. /// -/// An argument called `add_arg_if_not_reference` will be added to `app` if +/// An argument called `add_arg_if_not_reference` will be added to `command` if /// `args` does not contain the `--reference` option. /// `parse_gid_uid_and_filter` will be called to obtain the target gid and uid, and the filter, /// from `ArgMatches`. /// `groups_only` determines whether verbose output will only mention the group. pub fn chown_base<'a>( - mut app: App<'a>, + mut command: Command<'a>, args: impl crate::Args, add_arg_if_not_reference: &'a str, parse_gid_uid_and_filter: GidUidFilterParser, @@ -444,7 +444,7 @@ pub fn chown_base<'a>( if help || !reference { // add both positional arguments // arg_group is only required if - app = app.arg( + command = command.arg( Arg::new(add_arg_if_not_reference) .value_name(add_arg_if_not_reference) .required(true) @@ -452,7 +452,7 @@ pub fn chown_base<'a>( .multiple_occurrences(false), ); } - app = app.arg( + command = command.arg( Arg::new(options::ARG_FILES) .value_name(options::ARG_FILES) .multiple_occurrences(true) @@ -460,7 +460,7 @@ pub fn chown_base<'a>( .required(true) .min_values(1), ); - let matches = app.get_matches_from(args); + let matches = command.get_matches_from(args); let files: Vec = matches .values_of(options::ARG_FILES) diff --git a/src/uucore/src/lib/mods/backup_control.rs b/src/uucore/src/lib/mods/backup_control.rs index a2753b964..f2da374b6 100644 --- a/src/uucore/src/lib/mods/backup_control.rs +++ b/src/uucore/src/lib/mods/backup_control.rs @@ -34,16 +34,16 @@ //! #[macro_use] //! extern crate uucore; //! -//! use clap::{App, Arg, ArgMatches}; +//! use clap::{Command, Arg, ArgMatches}; //! use std::path::{Path, PathBuf}; //! use uucore::backup_control::{self, BackupMode}; //! use uucore::error::{UError, UResult}; //! //! fn main() { -//! let usage = String::from("app [OPTION]... ARG"); +//! let usage = String::from("command [OPTION]... ARG"); //! let long_usage = String::from("And here's a detailed explanation"); //! -//! let matches = App::new("app") +//! let matches = Command::new("command") //! .arg(backup_control::arguments::backup()) //! .arg(backup_control::arguments::backup_no_args()) //! .arg(backup_control::arguments::suffix()) @@ -54,7 +54,7 @@ //! backup_control::BACKUP_CONTROL_LONG_HELP //! )) //! .get_matches_from(vec![ -//! "app", "--backup=t", "--suffix=bak~" +//! "command", "--backup=t", "--suffix=bak~" //! ]); //! //! let backup_mode = match backup_control::determine_backup_mode(&matches) { @@ -290,14 +290,14 @@ pub fn determine_backup_suffix(matches: &ArgMatches) -> String { /// #[macro_use] /// extern crate uucore; /// use uucore::backup_control::{self, BackupMode}; -/// use clap::{App, Arg, ArgMatches}; +/// use clap::{Command, Arg, ArgMatches}; /// /// fn main() { -/// let matches = App::new("app") +/// let matches = Command::new("command") /// .arg(backup_control::arguments::backup()) /// .arg(backup_control::arguments::backup_no_args()) /// .get_matches_from(vec![ -/// "app", "-b", "--backup=t" +/// "command", "-b", "--backup=t" /// ]); /// /// let backup_mode = backup_control::determine_backup_mode(&matches).unwrap(); @@ -313,14 +313,14 @@ pub fn determine_backup_suffix(matches: &ArgMatches) -> String { /// #[macro_use] /// extern crate uucore; /// use uucore::backup_control::{self, BackupMode, BackupError}; -/// use clap::{App, Arg, ArgMatches}; +/// use clap::{Command, Arg, ArgMatches}; /// /// fn main() { -/// let matches = App::new("app") +/// let matches = Command::new("command") /// .arg(backup_control::arguments::backup()) /// .arg(backup_control::arguments::backup_no_args()) /// .get_matches_from(vec![ -/// "app", "-b", "--backup=n" +/// "command", "-b", "--backup=n" /// ]); /// /// let backup_mode = backup_control::determine_backup_mode(&matches); @@ -446,7 +446,7 @@ mod tests { use super::*; use std::env; // Required to instantiate mutex in shared context - use clap::App; + use clap::Command; use lazy_static::lazy_static; use std::sync::Mutex; @@ -463,8 +463,8 @@ mod tests { // Environment variable for "VERSION_CONTROL" static ENV_VERSION_CONTROL: &str = "VERSION_CONTROL"; - fn make_app() -> clap::App<'static> { - App::new("app") + fn make_app() -> clap::Command<'static> { + Command::new("command") .arg(arguments::backup()) .arg(arguments::backup_no_args()) .arg(arguments::suffix()) @@ -474,7 +474,7 @@ mod tests { #[test] fn test_backup_mode_short_only() { let _dummy = TEST_MUTEX.lock().unwrap(); - let matches = make_app().get_matches_from(vec!["app", "-b"]); + let matches = make_app().get_matches_from(vec!["command", "-b"]); let result = determine_backup_mode(&matches).unwrap(); @@ -485,7 +485,7 @@ mod tests { #[test] fn test_backup_mode_long_preferred_over_short() { let _dummy = TEST_MUTEX.lock().unwrap(); - let matches = make_app().get_matches_from(vec!["app", "-b", "--backup=none"]); + let matches = make_app().get_matches_from(vec!["command", "-b", "--backup=none"]); let result = determine_backup_mode(&matches).unwrap(); @@ -496,7 +496,7 @@ mod tests { #[test] fn test_backup_mode_long_without_args_no_env() { let _dummy = TEST_MUTEX.lock().unwrap(); - let matches = make_app().get_matches_from(vec!["app", "--backup"]); + let matches = make_app().get_matches_from(vec!["command", "--backup"]); let result = determine_backup_mode(&matches).unwrap(); @@ -507,7 +507,7 @@ mod tests { #[test] fn test_backup_mode_long_with_args() { let _dummy = TEST_MUTEX.lock().unwrap(); - let matches = make_app().get_matches_from(vec!["app", "--backup=simple"]); + let matches = make_app().get_matches_from(vec!["command", "--backup=simple"]); let result = determine_backup_mode(&matches).unwrap(); @@ -518,7 +518,7 @@ mod tests { #[test] fn test_backup_mode_long_with_args_invalid() { let _dummy = TEST_MUTEX.lock().unwrap(); - let matches = make_app().get_matches_from(vec!["app", "--backup=foobar"]); + let matches = make_app().get_matches_from(vec!["command", "--backup=foobar"]); let result = determine_backup_mode(&matches); @@ -531,7 +531,7 @@ mod tests { #[test] fn test_backup_mode_long_with_args_ambiguous() { let _dummy = TEST_MUTEX.lock().unwrap(); - let matches = make_app().get_matches_from(vec!["app", "--backup=n"]); + let matches = make_app().get_matches_from(vec!["command", "--backup=n"]); let result = determine_backup_mode(&matches); @@ -544,7 +544,7 @@ mod tests { #[test] fn test_backup_mode_long_with_arg_shortened() { let _dummy = TEST_MUTEX.lock().unwrap(); - let matches = make_app().get_matches_from(vec!["app", "--backup=si"]); + let matches = make_app().get_matches_from(vec!["command", "--backup=si"]); let result = determine_backup_mode(&matches).unwrap(); @@ -556,7 +556,7 @@ mod tests { fn test_backup_mode_short_only_ignore_env() { let _dummy = TEST_MUTEX.lock().unwrap(); env::set_var(ENV_VERSION_CONTROL, "none"); - let matches = make_app().get_matches_from(vec!["app", "-b"]); + let matches = make_app().get_matches_from(vec!["command", "-b"]); let result = determine_backup_mode(&matches).unwrap(); @@ -569,7 +569,7 @@ mod tests { fn test_backup_mode_long_without_args_with_env() { let _dummy = TEST_MUTEX.lock().unwrap(); env::set_var(ENV_VERSION_CONTROL, "none"); - let matches = make_app().get_matches_from(vec!["app", "--backup"]); + let matches = make_app().get_matches_from(vec!["command", "--backup"]); let result = determine_backup_mode(&matches).unwrap(); @@ -582,7 +582,7 @@ mod tests { fn test_backup_mode_long_with_env_var_invalid() { let _dummy = TEST_MUTEX.lock().unwrap(); env::set_var(ENV_VERSION_CONTROL, "foobar"); - let matches = make_app().get_matches_from(vec!["app", "--backup"]); + let matches = make_app().get_matches_from(vec!["command", "--backup"]); let result = determine_backup_mode(&matches); @@ -597,7 +597,7 @@ mod tests { fn test_backup_mode_long_with_env_var_ambiguous() { let _dummy = TEST_MUTEX.lock().unwrap(); env::set_var(ENV_VERSION_CONTROL, "n"); - let matches = make_app().get_matches_from(vec!["app", "--backup"]); + let matches = make_app().get_matches_from(vec!["command", "--backup"]); let result = determine_backup_mode(&matches); @@ -612,7 +612,7 @@ mod tests { fn test_backup_mode_long_with_env_var_shortened() { let _dummy = TEST_MUTEX.lock().unwrap(); env::set_var(ENV_VERSION_CONTROL, "si"); - let matches = make_app().get_matches_from(vec!["app", "--backup"]); + let matches = make_app().get_matches_from(vec!["command", "--backup"]); let result = determine_backup_mode(&matches).unwrap(); @@ -623,7 +623,7 @@ mod tests { #[test] fn test_suffix_takes_hyphen_value() { let _dummy = TEST_MUTEX.lock().unwrap(); - let matches = make_app().get_matches_from(vec!["app", "-b", "--suffix", "-v"]); + let matches = make_app().get_matches_from(vec!["command", "-b", "--suffix", "-v"]); let result = determine_backup_suffix(&matches); assert_eq!(result, "-v"); diff --git a/tests/by-util/test_link.rs b/tests/by-util/test_link.rs index 5a84364e9..6e98f1d64 100644 --- a/tests/by-util/test_link.rs +++ b/tests/by-util/test_link.rs @@ -45,7 +45,7 @@ fn test_link_one_argument() { let (_, mut ucmd) = at_and_ucmd!(); let file = "test_link_argument"; ucmd.args(&[file]).fails().stderr_contains( - "error: The argument '...' requires at least 2 values, but only 1 was provide", + "error: The argument '...' requires at least 2 values but only 1 was provided", ); } diff --git a/tests/by-util/test_mknod.rs b/tests/by-util/test_mknod.rs index f42ab0b90..3b22ef835 100644 --- a/tests/by-util/test_mknod.rs +++ b/tests/by-util/test_mknod.rs @@ -86,14 +86,14 @@ fn test_mknod_character_device_requires_major_and_minor() { .arg("1") .arg("c") .fails() - .stderr_contains(&"Invalid value for ''"); + .stderr_contains(&"Invalid value \"c\" for ''"); new_ucmd!() .arg("test_file") .arg("c") .arg("c") .arg("1") .fails() - .stderr_contains(&"Invalid value for ''"); + .stderr_contains(&"Invalid value \"c\" for ''"); } #[test] From a4737c0b50f471e613fc0c80a634f31538dafdfa Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Fri, 18 Mar 2022 19:40:26 +0100 Subject: [PATCH 06/38] fix unittests not running in CI --- .github/workflows/CICD.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index b2ae59bdf..a62e3d9f2 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -631,7 +631,7 @@ jobs: # target-specific options # * CARGO_FEATURES_OPTION CARGO_FEATURES_OPTION='' ; - if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi + if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi outputs CARGO_FEATURES_OPTION # * CARGO_USE_CROSS (truthy) CARGO_USE_CROSS='true' ; case '${{ matrix.job.use-cross }}' in ''|0|f|false|n|no) unset CARGO_USE_CROSS ;; esac; @@ -698,7 +698,7 @@ jobs: ## Dependent VARs setup outputs() { step_id="dep_vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo ::set-output name=${var}::${!var}; done; } # * determine sub-crate utility list - UTILITY_LIST="$(./util/show-utils.sh ${CARGO_FEATURES_OPTION})" + UTILITY_LIST="$(./util/show-utils.sh ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }})" echo UTILITY_LIST=${UTILITY_LIST} CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo "-puu_${u}"; done;)" outputs CARGO_UTILITY_LIST_OPTIONS @@ -981,7 +981,7 @@ jobs: ## Dependent VARs setup outputs() { step_id="dep_vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo ::set-output name=${var}::${!var}; done; } # * determine sub-crate utility list - UTILITY_LIST="$(./util/show-utils.sh ${CARGO_FEATURES_OPTION})" + UTILITY_LIST="$(./util/show-utils.sh ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }})" CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo "-puu_${u}"; done;)" outputs CARGO_UTILITY_LIST_OPTIONS - name: Test uucore From b77b3cba5525a9b0ac9308a16ed1e07425650db2 Mon Sep 17 00:00:00 2001 From: chordtoll Date: Sun, 13 Mar 2022 14:39:10 -0700 Subject: [PATCH 07/38] dd: implement iseek + oseek flags These are the first half of changes needed to pass the dd/bytes.sh tests: - Add iseek and oseek options (additive with skip and seek options) - Implement tests for the new flags, matching those from dd/bytes.sh --- src/uu/dd/src/datastructures.rs | 4 +- src/uu/dd/src/dd.rs | 40 ++++++++++++-- src/uu/dd/src/parseargs.rs | 38 ++++++++++++- src/uu/dd/src/parseargs/unit_tests.rs | 50 +++++++++++++++++- tests/by-util/test_dd.rs | 47 +++++++++++++++- tests/fixtures/dd/dd-bytes-alphabet-null.spec | Bin 0 -> 21 bytes tests/fixtures/dd/dd-bytes-null-trunc.spec | Bin 0 -> 8 bytes 7 files changed, 170 insertions(+), 9 deletions(-) create mode 100644 tests/fixtures/dd/dd-bytes-alphabet-null.spec create mode 100644 tests/fixtures/dd/dd-bytes-null-trunc.spec diff --git a/src/uu/dd/src/datastructures.rs b/src/uu/dd/src/datastructures.rs index 067058bbe..6529f6602 100644 --- a/src/uu/dd/src/datastructures.rs +++ b/src/uu/dd/src/datastructures.rs @@ -4,7 +4,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore ctable, outfile +// spell-checker:ignore ctable, outfile, iseek, oseek use std::error::Error; @@ -120,6 +120,8 @@ pub mod options { pub const COUNT: &str = "count"; pub const SKIP: &str = "skip"; pub const SEEK: &str = "seek"; + pub const ISEEK: &str = "iseek"; + pub const OSEEK: &str = "oseek"; pub const STATUS: &str = "status"; pub const CONV: &str = "conv"; pub const IFLAG: &str = "iflag"; diff --git a/src/uu/dd/src/dd.rs b/src/uu/dd/src/dd.rs index d8bc3acd3..dff712e92 100644 --- a/src/uu/dd/src/dd.rs +++ b/src/uu/dd/src/dd.rs @@ -5,7 +5,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rremain, rsofar, rstat, sigusr, wlen, wstat seekable +// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, iseek, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, oseek, outfile, parseargs, rlen, rmax, rremain, rsofar, rstat, sigusr, wlen, wstat seekable mod datastructures; use datastructures::*; @@ -61,6 +61,7 @@ impl Input { let cflags = parseargs::parse_conv_flag_input(matches)?; let iflags = parseargs::parse_iflags(matches)?; let skip = parseargs::parse_skip_amt(&ibs, &iflags, matches)?; + let iseek = parseargs::parse_iseek_amt(&ibs, &iflags, matches)?; let count = parseargs::parse_count(&iflags, matches)?; let mut i = Self { @@ -73,7 +74,9 @@ impl Input { iflags, }; - if let Some(amt) = skip { + // The --skip and --iseek flags are additive. On a stream, they discard bytes. + let amt = skip.unwrap_or(0) + iseek.unwrap_or(0); + if amt > 0 { if let Err(e) = i.read_skip(amt) { if let io::ErrorKind::UnexpectedEof = e.kind() { show_error!("'standard input': cannot skip to specified offset"); @@ -132,6 +135,7 @@ impl Input { let cflags = parseargs::parse_conv_flag_input(matches)?; let iflags = parseargs::parse_iflags(matches)?; let skip = parseargs::parse_skip_amt(&ibs, &iflags, matches)?; + let iseek = parseargs::parse_iseek_amt(&ibs, &iflags, matches)?; let count = parseargs::parse_count(&iflags, matches)?; if let Some(fname) = matches.value_of(options::INFILE) { @@ -148,7 +152,9 @@ impl Input { .map_err_context(|| "failed to open input file".to_string())? }; - if let Some(amt) = skip { + // The --skip and --iseek flags are additive. On a file, they seek. + let amt = skip.unwrap_or(0) + iseek.unwrap_or(0); + if amt > 0 { src.seek(io::SeekFrom::Start(amt)) .map_err_context(|| "failed to seek in input file".to_string())?; } @@ -293,11 +299,14 @@ impl OutputTrait for Output { let cflags = parseargs::parse_conv_flag_output(matches)?; let oflags = parseargs::parse_oflags(matches)?; let seek = parseargs::parse_seek_amt(&obs, &oflags, matches)?; + let oseek = parseargs::parse_oseek_amt(&obs, &oflags, matches)?; let mut dst = io::stdout(); + // The --seek and --oseek flags are additive. + let amt = seek.unwrap_or(0) + oseek.unwrap_or(0); // stdout is not seekable, so we just write null bytes. - if let Some(amt) = seek { + if amt > 0 { io::copy(&mut io::repeat(0u8).take(amt as u64), &mut dst) .map_err_context(|| String::from("write error"))?; } @@ -509,6 +518,7 @@ impl OutputTrait for Output { let cflags = parseargs::parse_conv_flag_output(matches)?; let oflags = parseargs::parse_oflags(matches)?; let seek = parseargs::parse_seek_amt(&obs, &oflags, matches)?; + let oseek = parseargs::parse_oseek_amt(&obs, &oflags, matches)?; if let Some(fname) = matches.value_of(options::OUTFILE) { let mut dst = open_dst(Path::new(&fname), &cflags, &oflags) @@ -522,7 +532,9 @@ impl OutputTrait for Output { // Instead, we suppress the error by calling // `Result::ok()`. This matches the behavior of GNU `dd` // when given the command-line argument `of=/dev/null`. - let i = seek.unwrap_or(0); + + // The --seek and --oseek flags are additive. + let i = seek.unwrap_or(0) + oseek.unwrap_or(0); if !cflags.notrunc { dst.set_len(i).ok(); } @@ -807,6 +819,24 @@ pub fn uu_app<'a>() -> App<'a> { .value_name("N") .help("(alternatively seek=N) seeks N obs-sized records into output before beginning copy/convert operations. See oflag=seek_bytes if seeking N bytes is preferred. Multiplier strings permitted.") ) + .arg( + Arg::new(options::ISEEK) + .long(options::ISEEK) + .overrides_with(options::ISEEK) + .takes_value(true) + .require_equals(true) + .value_name("N") + .help("(alternatively iseek=N) seeks N obs-sized records into input before beginning copy/convert operations. See iflag=seek_bytes if seeking N bytes is preferred. Multiplier strings permitted.") + ) + .arg( + Arg::new(options::OSEEK) + .long(options::OSEEK) + .overrides_with(options::OSEEK) + .takes_value(true) + .require_equals(true) + .value_name("N") + .help("(alternatively oseek=N) seeks N obs-sized records into output before beginning copy/convert operations. See oflag=seek_bytes if seeking N bytes is preferred. Multiplier strings permitted.") + ) .arg( Arg::new(options::COUNT) .long(options::COUNT) diff --git a/src/uu/dd/src/parseargs.rs b/src/uu/dd/src/parseargs.rs index d8639fca9..db2df4132 100644 --- a/src/uu/dd/src/parseargs.rs +++ b/src/uu/dd/src/parseargs.rs @@ -4,7 +4,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore ctty, ctable, iconvflags, oconvflags parseargs +// spell-checker:ignore ctty, ctable, iseek, oseek, iconvflags, oconvflags parseargs #[cfg(test)] mod unit_tests; @@ -776,6 +776,42 @@ pub fn parse_seek_amt( } } +/// Parse the amount of the input file to seek. +pub fn parse_iseek_amt( + ibs: &usize, + iflags: &IFlags, + matches: &Matches, +) -> Result, ParseError> { + if let Some(amt) = matches.value_of(options::ISEEK) { + let n = parse_bytes_with_opt_multiplier(amt)?; + if iflags.skip_bytes { + Ok(Some(n)) + } else { + Ok(Some(*ibs as u64 * n)) + } + } else { + Ok(None) + } +} + +/// Parse the amount of the input file to seek. +pub fn parse_oseek_amt( + obs: &usize, + oflags: &OFlags, + matches: &Matches, +) -> Result, ParseError> { + if let Some(amt) = matches.value_of(options::OSEEK) { + let n = parse_bytes_with_opt_multiplier(amt)?; + if oflags.seek_bytes { + Ok(Some(n)) + } else { + Ok(Some(*obs as u64 * n)) + } + } else { + Ok(None) + } +} + /// Parse the value of count=N and the type of N implied by iflags pub fn parse_count(iflags: &IFlags, matches: &Matches) -> Result, ParseError> { if let Some(amt) = matches.value_of(options::COUNT) { diff --git a/src/uu/dd/src/parseargs/unit_tests.rs b/src/uu/dd/src/parseargs/unit_tests.rs index 1e5b4b930..a29008c2c 100644 --- a/src/uu/dd/src/parseargs/unit_tests.rs +++ b/src/uu/dd/src/parseargs/unit_tests.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat +// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, iseek, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, oseek, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat use super::*; @@ -112,6 +112,8 @@ fn test_all_top_level_args_no_leading_dashes() { String::from("count=2"), String::from("skip=2"), String::from("seek=2"), + String::from("iseek=2"), + String::from("oseek=2"), String::from("status=progress"), String::from("conv=ascii,ucase"), String::from("iflag=count_bytes,skip_bytes"), @@ -150,6 +152,18 @@ fn test_all_top_level_args_no_leading_dashes() { .unwrap() .unwrap() ); + assert_eq!( + 200, + parse_iseek_amt(&100, &IFlags::default(), &matches) + .unwrap() + .unwrap() + ); + assert_eq!( + 200, + parse_oseek_amt(&100, &OFlags::default(), &matches) + .unwrap() + .unwrap() + ); assert_eq!( StatusLevel::Progress, parse_status_level(&matches).unwrap().unwrap() @@ -197,6 +211,8 @@ fn test_all_top_level_args_with_leading_dashes() { String::from("--count=2"), String::from("--skip=2"), String::from("--seek=2"), + String::from("--iseek=2"), + String::from("--oseek=2"), String::from("--status=progress"), String::from("--conv=ascii,ucase"), String::from("--iflag=count_bytes,skip_bytes"), @@ -235,6 +251,18 @@ fn test_all_top_level_args_with_leading_dashes() { .unwrap() .unwrap() ); + assert_eq!( + 200, + parse_iseek_amt(&100, &IFlags::default(), &matches) + .unwrap() + .unwrap() + ); + assert_eq!( + 200, + parse_oseek_amt(&100, &OFlags::default(), &matches) + .unwrap() + .unwrap() + ); assert_eq!( StatusLevel::Progress, parse_status_level(&matches).unwrap().unwrap() @@ -349,6 +377,10 @@ fn test_override_multiple_options() { String::from("--skip=2"), String::from("--seek=0"), String::from("--seek=2"), + String::from("--iseek=0"), + String::from("--iseek=2"), + String::from("--oseek=0"), + String::from("--oseek=2"), String::from("--status=none"), String::from("--status=noxfer"), String::from("--count=512"), @@ -394,6 +426,22 @@ fn test_override_multiple_options() { .unwrap() ); + // iseek + assert_eq!( + 200, + parse_iseek_amt(&100, &IFlags::default(), &matches) + .unwrap() + .unwrap() + ); + + // oseek + assert_eq!( + 200, + parse_oseek_amt(&100, &OFlags::default(), &matches) + .unwrap() + .unwrap() + ); + // count assert_eq!( CountType::Bytes(1024), diff --git a/tests/by-util/test_dd.rs b/tests/by-util/test_dd.rs index acf63bec7..62c420eb2 100644 --- a/tests/by-util/test_dd.rs +++ b/tests/by-util/test_dd.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, availible, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat abcdefghijklm abcdefghi nabcde nabcdefg abcdefg +// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, availible, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, iseek, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, oseek, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat abcdefghijklm abcdefghi nabcde nabcdefg abcdefg use crate::common::util::*; @@ -1139,3 +1139,48 @@ fn test_block_sync() { .stdout_is("012 abcde ") .stderr_is("2+1 records in\n0+1 records out\n1 truncated record\n"); } + +#[test] +fn test_bytes_count_bytes_iflag() { + new_ucmd!() + .args(&["conv=swab", "count=14", "iflag=count_bytes"]) + .pipe_in("0123456789abcdefghijklm") + .succeeds() + .stdout_is("1032547698badc"); +} + +#[test] +fn test_bytes_skip_bytes_iflag() { + new_ucmd!() + .args(&["skip=10", "iflag=skip_bytes"]) + .pipe_in("0123456789abcdefghijklm") + .succeeds() + .stdout_is("abcdefghijklm"); +} + +#[test] +fn test_bytes_skip_bytes_pipe_iflag() { + new_ucmd!() + .args(&["skip=10", "iflag=skip_bytes", "bs=2"]) + .pipe_in("0123456789abcdefghijklm") + .succeeds() + .stdout_is("abcdefghijklm"); +} + +#[test] +fn test_bytes_oseek_bytes_oflag() { + new_ucmd!() + .args(&["seek=8", "oflag=seek_bytes", "bs=2"]) + .pipe_in("abcdefghijklm") + .succeeds() + .stdout_is_fixture_bytes("dd-bytes-alphabet-null.spec"); +} + +#[test] +fn test_bytes_oseek_bytes_trunc_oflag() { + new_ucmd!() + .args(&["seek=8", "oflag=seek_bytes", "bs=2", "count=0"]) + .pipe_in("abcdefghijklm") + .succeeds() + .stdout_is_fixture_bytes("dd-bytes-null-trunc.spec"); +} diff --git a/tests/fixtures/dd/dd-bytes-alphabet-null.spec b/tests/fixtures/dd/dd-bytes-alphabet-null.spec new file mode 100644 index 0000000000000000000000000000000000000000..1ab5429c1ad8a3698557ee0b921bc4accc7daff6 GIT binary patch literal 21 WcmZR8g2bfcl+?8JjLfX;oLm4S`~^G! literal 0 HcmV?d00001 diff --git a/tests/fixtures/dd/dd-bytes-null-trunc.spec b/tests/fixtures/dd/dd-bytes-null-trunc.spec new file mode 100644 index 0000000000000000000000000000000000000000..1b1cb4d44c57c2d7a5122870fa6ac3e62ff7e94e GIT binary patch literal 8 JcmZR80ssIA00961 literal 0 HcmV?d00001 From 72ce815d874b9b9ef70c453404bdf37b51e4993f Mon Sep 17 00:00:00 2001 From: chordtoll Date: Thu, 17 Mar 2022 18:16:41 -0700 Subject: [PATCH 08/38] Add correct set of tests, fix typo in flags to test, write test to confirm additive flags --- tests/by-util/test_dd.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/by-util/test_dd.rs b/tests/by-util/test_dd.rs index 62c420eb2..f6287a940 100644 --- a/tests/by-util/test_dd.rs +++ b/tests/by-util/test_dd.rs @@ -1141,27 +1141,18 @@ fn test_block_sync() { } #[test] -fn test_bytes_count_bytes_iflag() { +fn test_bytes_iseek_bytes_iflag() { new_ucmd!() - .args(&["conv=swab", "count=14", "iflag=count_bytes"]) - .pipe_in("0123456789abcdefghijklm") - .succeeds() - .stdout_is("1032547698badc"); -} - -#[test] -fn test_bytes_skip_bytes_iflag() { - new_ucmd!() - .args(&["skip=10", "iflag=skip_bytes"]) + .args(&["iseek=10", "iflag=skip_bytes", "bs=2"]) .pipe_in("0123456789abcdefghijklm") .succeeds() .stdout_is("abcdefghijklm"); } #[test] -fn test_bytes_skip_bytes_pipe_iflag() { +fn test_bytes_iseek_skip_additive() { new_ucmd!() - .args(&["skip=10", "iflag=skip_bytes", "bs=2"]) + .args(&["iseek=5", "skip=5", "iflag=skip_bytes", "bs=2"]) .pipe_in("0123456789abcdefghijklm") .succeeds() .stdout_is("abcdefghijklm"); @@ -1170,7 +1161,7 @@ fn test_bytes_skip_bytes_pipe_iflag() { #[test] fn test_bytes_oseek_bytes_oflag() { new_ucmd!() - .args(&["seek=8", "oflag=seek_bytes", "bs=2"]) + .args(&["oseek=8", "oflag=seek_bytes", "bs=2"]) .pipe_in("abcdefghijklm") .succeeds() .stdout_is_fixture_bytes("dd-bytes-alphabet-null.spec"); @@ -1179,8 +1170,17 @@ fn test_bytes_oseek_bytes_oflag() { #[test] fn test_bytes_oseek_bytes_trunc_oflag() { new_ucmd!() - .args(&["seek=8", "oflag=seek_bytes", "bs=2", "count=0"]) + .args(&["oseek=8", "oflag=seek_bytes", "bs=2", "count=0"]) .pipe_in("abcdefghijklm") .succeeds() .stdout_is_fixture_bytes("dd-bytes-null-trunc.spec"); } + +#[test] +fn test_bytes_oseek_seek_additive() { + new_ucmd!() + .args(&["oseek=4", "seek=4", "oflag=seek_bytes", "bs=2"]) + .pipe_in("abcdefghijklm") + .succeeds() + .stdout_is_fixture_bytes("dd-bytes-alphabet-null.spec"); +} From a84202ee0070add568b6f2afcf9f97fd5d39f23d Mon Sep 17 00:00:00 2001 From: chordtoll Date: Thu, 17 Mar 2022 18:34:36 -0700 Subject: [PATCH 09/38] Combine 4 duplicate seek/skip parsing functions into one --- src/uu/dd/src/dd.rs | 20 +++++---- src/uu/dd/src/parseargs.rs | 64 +++------------------------ src/uu/dd/src/parseargs/unit_tests.rs | 24 +++++----- 3 files changed, 29 insertions(+), 79 deletions(-) diff --git a/src/uu/dd/src/dd.rs b/src/uu/dd/src/dd.rs index dff712e92..db0d3729b 100644 --- a/src/uu/dd/src/dd.rs +++ b/src/uu/dd/src/dd.rs @@ -60,8 +60,9 @@ impl Input { let print_level = parseargs::parse_status_level(matches)?; let cflags = parseargs::parse_conv_flag_input(matches)?; let iflags = parseargs::parse_iflags(matches)?; - let skip = parseargs::parse_skip_amt(&ibs, &iflags, matches)?; - let iseek = parseargs::parse_iseek_amt(&ibs, &iflags, matches)?; + let skip = parseargs::parse_seek_skip_amt(&ibs, iflags.skip_bytes, matches, options::SKIP)?; + let iseek = + parseargs::parse_seek_skip_amt(&ibs, iflags.skip_bytes, matches, options::ISEEK)?; let count = parseargs::parse_count(&iflags, matches)?; let mut i = Self { @@ -134,8 +135,9 @@ impl Input { let print_level = parseargs::parse_status_level(matches)?; let cflags = parseargs::parse_conv_flag_input(matches)?; let iflags = parseargs::parse_iflags(matches)?; - let skip = parseargs::parse_skip_amt(&ibs, &iflags, matches)?; - let iseek = parseargs::parse_iseek_amt(&ibs, &iflags, matches)?; + let skip = parseargs::parse_seek_skip_amt(&ibs, iflags.skip_bytes, matches, options::SKIP)?; + let iseek = + parseargs::parse_seek_skip_amt(&ibs, iflags.skip_bytes, matches, options::ISEEK)?; let count = parseargs::parse_count(&iflags, matches)?; if let Some(fname) = matches.value_of(options::INFILE) { @@ -298,8 +300,9 @@ impl OutputTrait for Output { let obs = parseargs::parse_obs(matches)?; let cflags = parseargs::parse_conv_flag_output(matches)?; let oflags = parseargs::parse_oflags(matches)?; - let seek = parseargs::parse_seek_amt(&obs, &oflags, matches)?; - let oseek = parseargs::parse_oseek_amt(&obs, &oflags, matches)?; + let seek = parseargs::parse_seek_skip_amt(&obs, oflags.seek_bytes, matches, options::SEEK)?; + let oseek = + parseargs::parse_seek_skip_amt(&obs, oflags.seek_bytes, matches, options::OSEEK)?; let mut dst = io::stdout(); @@ -517,8 +520,9 @@ impl OutputTrait for Output { let obs = parseargs::parse_obs(matches)?; let cflags = parseargs::parse_conv_flag_output(matches)?; let oflags = parseargs::parse_oflags(matches)?; - let seek = parseargs::parse_seek_amt(&obs, &oflags, matches)?; - let oseek = parseargs::parse_oseek_amt(&obs, &oflags, matches)?; + let seek = parseargs::parse_seek_skip_amt(&obs, oflags.seek_bytes, matches, options::SEEK)?; + let oseek = + parseargs::parse_seek_skip_amt(&obs, oflags.seek_bytes, matches, options::OSEEK)?; if let Some(fname) = matches.value_of(options::OUTFILE) { let mut dst = open_dst(Path::new(&fname), &cflags, &oflags) diff --git a/src/uu/dd/src/parseargs.rs b/src/uu/dd/src/parseargs.rs index db2df4132..75703b629 100644 --- a/src/uu/dd/src/parseargs.rs +++ b/src/uu/dd/src/parseargs.rs @@ -740,15 +740,15 @@ pub fn parse_oflags(matches: &Matches) -> Result { Ok(oflags) } -/// Parse the amount of the input file to skip. -pub fn parse_skip_amt( +pub fn parse_seek_skip_amt( ibs: &usize, - iflags: &IFlags, + bytes: bool, matches: &Matches, + option: &str, ) -> Result, ParseError> { - if let Some(amt) = matches.value_of(options::SKIP) { + if let Some(amt) = matches.value_of(option) { let n = parse_bytes_with_opt_multiplier(amt)?; - if iflags.skip_bytes { + if bytes { Ok(Some(n)) } else { Ok(Some(*ibs as u64 * n)) @@ -758,60 +758,6 @@ pub fn parse_skip_amt( } } -/// Parse the amount of the output file to seek. -pub fn parse_seek_amt( - obs: &usize, - oflags: &OFlags, - matches: &Matches, -) -> Result, ParseError> { - if let Some(amt) = matches.value_of(options::SEEK) { - let n = parse_bytes_with_opt_multiplier(amt)?; - if oflags.seek_bytes { - Ok(Some(n)) - } else { - Ok(Some(*obs as u64 * n)) - } - } else { - Ok(None) - } -} - -/// Parse the amount of the input file to seek. -pub fn parse_iseek_amt( - ibs: &usize, - iflags: &IFlags, - matches: &Matches, -) -> Result, ParseError> { - if let Some(amt) = matches.value_of(options::ISEEK) { - let n = parse_bytes_with_opt_multiplier(amt)?; - if iflags.skip_bytes { - Ok(Some(n)) - } else { - Ok(Some(*ibs as u64 * n)) - } - } else { - Ok(None) - } -} - -/// Parse the amount of the input file to seek. -pub fn parse_oseek_amt( - obs: &usize, - oflags: &OFlags, - matches: &Matches, -) -> Result, ParseError> { - if let Some(amt) = matches.value_of(options::OSEEK) { - let n = parse_bytes_with_opt_multiplier(amt)?; - if oflags.seek_bytes { - Ok(Some(n)) - } else { - Ok(Some(*obs as u64 * n)) - } - } else { - Ok(None) - } -} - /// Parse the value of count=N and the type of N implied by iflags pub fn parse_count(iflags: &IFlags, matches: &Matches) -> Result, ParseError> { if let Some(amt) = matches.value_of(options::COUNT) { diff --git a/src/uu/dd/src/parseargs/unit_tests.rs b/src/uu/dd/src/parseargs/unit_tests.rs index a29008c2c..5fae63c73 100644 --- a/src/uu/dd/src/parseargs/unit_tests.rs +++ b/src/uu/dd/src/parseargs/unit_tests.rs @@ -142,25 +142,25 @@ fn test_all_top_level_args_no_leading_dashes() { ); assert_eq!( 200, - parse_skip_amt(&100, &IFlags::default(), &matches) + parse_seek_skip_amt(&100, IFlags::default().skip_bytes, &matches, options::SKIP) .unwrap() .unwrap() ); assert_eq!( 200, - parse_seek_amt(&100, &OFlags::default(), &matches) + parse_seek_skip_amt(&100, OFlags::default().seek_bytes, &matches, options::SEEK) .unwrap() .unwrap() ); assert_eq!( 200, - parse_iseek_amt(&100, &IFlags::default(), &matches) + parse_seek_skip_amt(&100, IFlags::default().skip_bytes, &matches, options::ISEEK) .unwrap() .unwrap() ); assert_eq!( 200, - parse_oseek_amt(&100, &OFlags::default(), &matches) + parse_seek_skip_amt(&100, OFlags::default().seek_bytes, &matches, options::OSEEK) .unwrap() .unwrap() ); @@ -241,25 +241,25 @@ fn test_all_top_level_args_with_leading_dashes() { ); assert_eq!( 200, - parse_skip_amt(&100, &IFlags::default(), &matches) + parse_seek_skip_amt(&100, IFlags::default().skip_bytes, &matches, options::SKIP) .unwrap() .unwrap() ); assert_eq!( 200, - parse_seek_amt(&100, &OFlags::default(), &matches) + parse_seek_skip_amt(&100, OFlags::default().seek_bytes, &matches, options::SEEK) .unwrap() .unwrap() ); assert_eq!( 200, - parse_iseek_amt(&100, &IFlags::default(), &matches) + parse_seek_skip_amt(&100, IFlags::default().skip_bytes, &matches, options::ISEEK) .unwrap() .unwrap() ); assert_eq!( 200, - parse_oseek_amt(&100, &OFlags::default(), &matches) + parse_seek_skip_amt(&100, OFlags::default().seek_bytes, &matches, options::OSEEK) .unwrap() .unwrap() ); @@ -413,7 +413,7 @@ fn test_override_multiple_options() { // skip assert_eq!( 200, - parse_skip_amt(&100, &IFlags::default(), &matches) + parse_seek_skip_amt(&100, IFlags::default().skip_bytes, &matches, options::SKIP) .unwrap() .unwrap() ); @@ -421,7 +421,7 @@ fn test_override_multiple_options() { // seek assert_eq!( 200, - parse_seek_amt(&100, &OFlags::default(), &matches) + parse_seek_skip_amt(&100, OFlags::default().seek_bytes, &matches, options::SEEK) .unwrap() .unwrap() ); @@ -429,7 +429,7 @@ fn test_override_multiple_options() { // iseek assert_eq!( 200, - parse_iseek_amt(&100, &IFlags::default(), &matches) + parse_seek_skip_amt(&100, IFlags::default().skip_bytes, &matches, options::ISEEK) .unwrap() .unwrap() ); @@ -437,7 +437,7 @@ fn test_override_multiple_options() { // oseek assert_eq!( 200, - parse_oseek_amt(&100, &OFlags::default(), &matches) + parse_seek_skip_amt(&100, OFlags::default().seek_bytes, &matches, options::OSEEK) .unwrap() .unwrap() ); From ac8dcb6bd3acb02b1ccdcfa7121e90045248b31e Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 17 Mar 2022 16:06:24 +0100 Subject: [PATCH 10/38] df: remove unused "--direct" option --- src/uu/df/src/df.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 338648e10..adea3ad68 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -31,7 +31,6 @@ const USAGE: &str = "{} [OPTION]... [FILE]..."; static OPT_ALL: &str = "all"; static OPT_BLOCKSIZE: &str = "blocksize"; -static OPT_DIRECT: &str = "direct"; static OPT_TOTAL: &str = "total"; static OPT_HUMAN_READABLE: &str = "human-readable"; static OPT_HUMAN_READABLE_2: &str = "human-readable-2"; @@ -338,11 +337,6 @@ pub fn uu_app<'a>() -> App<'a> { '-BM' prints sizes in units of 1,048,576 bytes", ), ) - .arg( - Arg::new(OPT_DIRECT) - .long("direct") - .help("show statistics for a file instead of mount point"), - ) .arg( Arg::new(OPT_TOTAL) .long("total") From 50c6599a32210062dd12f77746057198067f54b3 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 18 Mar 2022 15:33:04 +0100 Subject: [PATCH 11/38] df: omit reserved filesystem blocks in "Available" fixes #3251 --- src/uu/df/src/table.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/uu/df/src/table.rs b/src/uu/df/src/table.rs index a126876dd..00fe31caf 100644 --- a/src/uu/df/src/table.rs +++ b/src/uu/df/src/table.rs @@ -39,8 +39,8 @@ pub(crate) struct Row { /// Number of used bytes. bytes_used: u64, - /// Number of free bytes. - bytes_free: u64, + /// Number of available bytes. + bytes_avail: u64, /// Percentage of bytes that are used, given as a float between 0 and 1. /// @@ -78,7 +78,7 @@ impl Row { fs_mount: "-".into(), bytes: 0, bytes_used: 0, - bytes_free: 0, + bytes_avail: 0, bytes_usage: None, #[cfg(target_os = "macos")] bytes_capacity: None, @@ -106,7 +106,7 @@ impl AddAssign for Row { fs_mount: "-".into(), bytes, bytes_used, - bytes_free: self.bytes_free + rhs.bytes_free, + bytes_avail: self.bytes_avail + rhs.bytes_avail, bytes_usage: if bytes == 0 { None } else { @@ -139,7 +139,6 @@ impl From for Row { blocksize, blocks, bfree, - #[cfg(target_os = "macos")] bavail, files, ffree, @@ -151,7 +150,7 @@ impl From for Row { fs_mount: mount_dir, bytes: blocksize * blocks, bytes_used: blocksize * (blocks - bfree), - bytes_free: blocksize * bfree, + bytes_avail: blocksize * bavail, bytes_usage: if blocks == 0 { None } else { @@ -236,7 +235,7 @@ impl fmt::Display for DisplayRow<'_> { Column::Source => write!(f, "{0: <16} ", self.row.fs_device)?, Column::Size => write!(f, "{0: >12} ", self.scaled(self.row.bytes)?)?, Column::Used => write!(f, "{0: >12} ", self.scaled(self.row.bytes_used)?)?, - Column::Avail => write!(f, "{0: >12} ", self.scaled(self.row.bytes_free)?)?, + Column::Avail => write!(f, "{0: >12} ", self.scaled(self.row.bytes_avail)?)?, Column::Pcent => { write!(f, "{0: >5} ", DisplayRow::percentage(self.row.bytes_usage))?; } @@ -413,7 +412,7 @@ mod tests { bytes: 100, bytes_used: 25, - bytes_free: 75, + bytes_avail: 75, bytes_usage: Some(0.25), #[cfg(target_os = "macos")] @@ -444,7 +443,7 @@ mod tests { bytes: 100, bytes_used: 25, - bytes_free: 75, + bytes_avail: 75, bytes_usage: Some(0.25), #[cfg(target_os = "macos")] @@ -475,7 +474,7 @@ mod tests { bytes: 100, bytes_used: 25, - bytes_free: 75, + bytes_avail: 75, bytes_usage: Some(0.25), #[cfg(target_os = "macos")] @@ -506,7 +505,7 @@ mod tests { bytes: 4000, bytes_used: 1000, - bytes_free: 3000, + bytes_avail: 3000, bytes_usage: Some(0.25), #[cfg(target_os = "macos")] @@ -537,7 +536,7 @@ mod tests { bytes: 4096, bytes_used: 1024, - bytes_free: 3072, + bytes_avail: 3072, bytes_usage: Some(0.25), #[cfg(target_os = "macos")] @@ -567,7 +566,7 @@ mod tests { bytes: 100, bytes_used: 25, - bytes_free: 75, + bytes_avail: 75, bytes_usage: Some(0.251), #[cfg(target_os = "macos")] From 971f817a952c114f6e8eb6ad8953e01ef95e6ef2 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Fri, 18 Mar 2022 19:40:26 +0100 Subject: [PATCH 12/38] fix unittests not running in CI --- .github/workflows/CICD.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index bbbf60838..854b3ed0c 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -638,7 +638,7 @@ jobs: # target-specific options # * CARGO_FEATURES_OPTION CARGO_FEATURES_OPTION='' ; - if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi + if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi outputs CARGO_FEATURES_OPTION # * CARGO_USE_CROSS (truthy) CARGO_USE_CROSS='true' ; case '${{ matrix.job.use-cross }}' in ''|0|f|false|n|no) unset CARGO_USE_CROSS ;; esac; @@ -705,7 +705,7 @@ jobs: ## Dependent VARs setup outputs() { step_id="dep_vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo ::set-output name=${var}::${!var}; done; } # * determine sub-crate utility list - UTILITY_LIST="$(./util/show-utils.sh ${CARGO_FEATURES_OPTION})" + UTILITY_LIST="$(./util/show-utils.sh ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }})" echo UTILITY_LIST=${UTILITY_LIST} CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo "-puu_${u}"; done;)" outputs CARGO_UTILITY_LIST_OPTIONS @@ -988,7 +988,7 @@ jobs: ## Dependent VARs setup outputs() { step_id="dep_vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo ::set-output name=${var}::${!var}; done; } # * determine sub-crate utility list - UTILITY_LIST="$(./util/show-utils.sh ${CARGO_FEATURES_OPTION})" + UTILITY_LIST="$(./util/show-utils.sh ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }})" CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo "-puu_${u}"; done;)" outputs CARGO_UTILITY_LIST_OPTIONS - name: Test uucore From 094bb61a63a5022f802983ee75eae63e0a53395e Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 19 Mar 2022 10:58:45 +0100 Subject: [PATCH 13/38] fxi tests for unittests in dd and hashsum --- src/uu/dd/src/parseargs/unit_tests.rs | 12 ++++++------ src/uu/hashsum/src/digest.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/uu/dd/src/parseargs/unit_tests.rs b/src/uu/dd/src/parseargs/unit_tests.rs index 1e5b4b930..4680a038c 100644 --- a/src/uu/dd/src/parseargs/unit_tests.rs +++ b/src/uu/dd/src/parseargs/unit_tests.rs @@ -303,10 +303,10 @@ fn test_status_level_noxfer() { fn test_multiple_flags_options() { let args = vec![ String::from("dd"), - String::from("--iflag=fullblock,directory"), + String::from("--iflag=fullblock,count_bytes"), String::from("--iflag=skip_bytes"), - String::from("--oflag=direct"), - String::from("--oflag=dsync"), + String::from("--oflag=append"), + String::from("--oflag=seek_bytes"), String::from("--conv=ascii,ucase"), String::from("--conv=unblock"), ]; @@ -315,13 +315,13 @@ fn test_multiple_flags_options() { // iflag let iflags = parse_flag_list::(options::IFLAG, &matches).unwrap(); assert_eq!( - vec![Flag::FullBlock, Flag::Directory, Flag::SkipBytes], + vec![Flag::FullBlock, Flag::CountBytes, Flag::SkipBytes], iflags ); // oflag let oflags = parse_flag_list::(options::OFLAG, &matches).unwrap(); - assert_eq!(vec![Flag::Direct, Flag::Dsync], oflags); + assert_eq!(vec![Flag::Append, Flag::SeekBytes], oflags); // conv let conv = parse_flag_list::(options::CONV, &matches).unwrap(); @@ -685,7 +685,7 @@ mod test_64bit_arch { #[test] #[should_panic] fn test_overflow_panic() { - let bs_str = format!("{}KiB", usize::MAX); + let bs_str = format!("{}KiB", u64::MAX); parse_bytes_with_opt_multiplier(&bs_str).unwrap(); } diff --git a/src/uu/hashsum/src/digest.rs b/src/uu/hashsum/src/digest.rs index 60275701e..9220e04a0 100644 --- a/src/uu/hashsum/src/digest.rs +++ b/src/uu/hashsum/src/digest.rs @@ -274,7 +274,7 @@ mod tests { use crate::digest::DigestWriter; // Writing "\r" in one call to `write()`, and then "\n" in another. - let mut digest = Box::new(md5::Context::new()) as Box; + let mut digest = Box::new(md5::Md5::new()) as Box; let mut writer_crlf = DigestWriter::new(&mut digest, false); writer_crlf.write_all(&[b'\r']).unwrap(); writer_crlf.write_all(&[b'\n']).unwrap(); @@ -282,7 +282,7 @@ mod tests { let result_crlf = digest.result_str(); // We expect "\r\n" to be replaced with "\n" in text mode on Windows. - let mut digest = Box::new(md5::Context::new()) as Box; + let mut digest = Box::new(md5::Md5::new()) as Box; let mut writer_lf = DigestWriter::new(&mut digest, false); writer_lf.write_all(&[b'\n']).unwrap(); writer_lf.finalize(); From ee1ae6497041bb8c6fc44420dc15da8d3f51628e Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 19 Mar 2022 16:28:21 +0100 Subject: [PATCH 14/38] bump textwrap to 0.15 --- Cargo.lock | 15 +++------------ Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fcc0b4ca4..3c57717b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -349,7 +349,7 @@ dependencies = [ "selinux", "sha1", "tempfile", - "textwrap 0.14.2", + "textwrap 0.15.0", "time", "unindent", "unix_socket", @@ -2087,9 +2087,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" dependencies = [ "smawk", "terminal_size", @@ -2097,15 +2097,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "textwrap" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" -dependencies = [ - "terminal_size", -] - [[package]] name = "thiserror" version = "1.0.30" diff --git a/Cargo.toml b/Cargo.toml index 7668a27a0..517752e32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -249,7 +249,7 @@ clap = { version = "3.1", features = ["wrap_help", "cargo"] } clap_complete = "3.0" phf = "0.10.1" lazy_static = { version="1.3" } -textwrap = { version="0.14", features=["terminal_size"] } +textwrap = { version="0.15", features=["terminal_size"] } uucore = { version=">=0.0.11", package="uucore", path="src/uucore" } selinux = { version="0.2", optional = true } ureq = "2.4.0" From 6d2eff9c27aa1bcccb3cd40128df34e18f5bbfd3 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sat, 19 Mar 2022 12:11:03 -0400 Subject: [PATCH 15/38] split: catch and handle broken pipe errors Catch `BrokenPipe` errors and silently ignore them so that `split` terminates successfully on a broken pipe. This matches the behavior of GNU `split`. --- src/uu/split/src/split.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 73abc966b..ba465c3e8 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -1007,8 +1007,9 @@ where writers.push(writer); } - // This block evaluates to an object of type `std::io::Result<()>`. - { + // Capture the result of the `std::io::copy()` calls to check for + // `BrokenPipe`. + let result: std::io::Result<()> = { // Write `chunk_size` bytes from the reader into each writer // except the last. // @@ -1025,8 +1026,12 @@ where io::copy(&mut reader.by_ref().take(last_chunk_size), &mut writers[i])?; Ok(()) + }; + match result { + Ok(_) => Ok(()), + Err(e) if e.kind() == ErrorKind::BrokenPipe => Ok(()), + Err(e) => Err(uio_error!(e, "input/output error")), } - .map_err_context(|| "I/O error".to_string()) } /// Split a file into a specific number of chunks by line. @@ -1204,6 +1209,7 @@ fn split(settings: &Settings) -> UResult<()> { // indicate that. A special error message needs to be // printed in that case. ErrorKind::Other => Err(USimpleError::new(1, "output file suffixes exhausted")), + ErrorKind::BrokenPipe => Ok(()), _ => Err(uio_error!(e, "input/output error")), }, } @@ -1223,6 +1229,7 @@ fn split(settings: &Settings) -> UResult<()> { // indicate that. A special error message needs to be // printed in that case. ErrorKind::Other => Err(USimpleError::new(1, "output file suffixes exhausted")), + ErrorKind::BrokenPipe => Ok(()), _ => Err(uio_error!(e, "input/output error")), }, } @@ -1242,6 +1249,7 @@ fn split(settings: &Settings) -> UResult<()> { // indicate that. A special error message needs to be // printed in that case. ErrorKind::Other => Err(USimpleError::new(1, "output file suffixes exhausted")), + ErrorKind::BrokenPipe => Ok(()), _ => Err(uio_error!(e, "input/output error")), }, } From 0a226524a66a8c3bcab46a1fd829b8458b2d8613 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sat, 19 Mar 2022 12:03:10 -0400 Subject: [PATCH 16/38] split: elide all chunks when input file is empty Fix a bug in the behavior of `split -e -n NUM` when the input file is empty. Previously, it would panic due to overflow when subtracting 1 from 0. After this change, it will terminate successfully and produce no output chunks. --- src/uu/split/src/split.rs | 7 +++++++ tests/by-util/test_split.rs | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 73abc966b..36a95da9a 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -984,6 +984,13 @@ where (num_chunks, chunk_size) }; + // If we would have written zero chunks of output, then terminate + // immediately. This happens on `split -e -n 3 /dev/null`, for + // example. + if num_chunks == 0 { + return Ok(()); + } + let num_chunks: usize = num_chunks .try_into() .map_err(|_| USimpleError::new(1, "Number of chunks too big"))?; diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 642cb7c68..d51aadd3b 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -571,6 +571,19 @@ fn test_elide_empty_files() { assert!(!at.plus("xad").exists()); } +#[test] +#[cfg(unix)] +fn test_elide_dev_null() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-e", "-n", "3", "/dev/null"]) + .succeeds() + .no_stdout() + .no_stderr(); + assert!(!at.plus("xaa").exists()); + assert!(!at.plus("xab").exists()); + assert!(!at.plus("xac").exists()); +} + #[test] fn test_lines() { let (at, mut ucmd) = at_and_ucmd!(); From cf4a0fa5c81794a099fd08326ecbec3179aec9f5 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 19 Mar 2022 22:21:28 +0100 Subject: [PATCH 17/38] also run unittests in codecov --- .github/workflows/CICD.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 854b3ed0c..74f1d8ce0 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -948,7 +948,7 @@ jobs: # target-specific options # * CARGO_FEATURES_OPTION CARGO_FEATURES_OPTION='--all-features' ; ## default to '--all-features' for code coverage - if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi + if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi outputs CARGO_FEATURES_OPTION # * CODECOV_FLAGS CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' ) From 32cadbc715aa977fa941b4d34c36883fb04bc5bb Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 19 Mar 2022 23:04:20 +0100 Subject: [PATCH 18/38] pinky: don't include short flag in help --- src/uu/pinky/src/pinky.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/uu/pinky/src/pinky.rs b/src/uu/pinky/src/pinky.rs index b5ad2c5c9..437c20cf5 100644 --- a/src/uu/pinky/src/pinky.rs +++ b/src/uu/pinky/src/pinky.rs @@ -36,6 +36,7 @@ mod options { pub const OMIT_NAME_HOST: &str = "omit_name_host"; pub const OMIT_NAME_HOST_TIME: &str = "omit_name_host_time"; pub const USER: &str = "user"; + pub const HELP: &str = "help"; } fn get_long_usage() -> String { @@ -180,6 +181,13 @@ pub fn uu_app<'a>() -> Command<'a> { .takes_value(true) .multiple_occurrences(true), ) + .arg( + // Redefine the help argument to not include the short flag + // since that conflicts with omit_project_file. + Arg::new(options::HELP) + .long(options::HELP) + .help("Print help information"), + ) } struct Pinky { From 95f58fbf3c82c06f6319bddefcd5a9ed1fefcf85 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sat, 19 Mar 2022 23:50:02 -0400 Subject: [PATCH 19/38] split: handle no final newline with --line-bytes Fix a panic due to out-of-bounds indexing when using `split --line-bytes` with an input that had no trailing newline. --- src/uu/split/src/split.rs | 2 +- tests/by-util/test_split.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 026f13d0b..11cf776c6 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -886,7 +886,7 @@ impl<'a> Write for LineBytesChunkWriter<'a> { // then move on to the next chunk if necessary. None => { let end = self.num_bytes_remaining_in_current_chunk; - let num_bytes_written = self.inner.write(&buf[..end])?; + let num_bytes_written = self.inner.write(&buf[..end.min(buf.len())])?; self.num_bytes_remaining_in_current_chunk -= num_bytes_written; total_bytes_written += num_bytes_written; buf = &buf[num_bytes_written..]; diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index d51aadd3b..950ba59bc 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -618,3 +618,19 @@ fn test_line_bytes() { assert_eq!(at.read("xac"), "cccc\ndd\n"); assert_eq!(at.read("xad"), "ee\n"); } + +#[test] +fn test_line_bytes_no_final_newline() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-C", "2"]) + .pipe_in("1\n2222\n3\n4") + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("xaa"), "1\n"); + assert_eq!(at.read("xab"), "22"); + assert_eq!(at.read("xac"), "22"); + assert_eq!(at.read("xad"), "\n"); + assert_eq!(at.read("xae"), "3\n"); + assert_eq!(at.read("xaf"), "4"); +} From a0bd88b51b80a235ddfe26c7fd5f3ceac0e22042 Mon Sep 17 00:00:00 2001 From: Eli Youngs Date: Sat, 19 Mar 2022 14:47:14 -0700 Subject: [PATCH 20/38] Add comments and an additional test --- .../tokenize/num_format/formatters/decf.rs | 125 ++++++++++++------ tests/by-util/test_printf.rs | 8 ++ 2 files changed, 93 insertions(+), 40 deletions(-) diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatters/decf.rs b/src/uucore/src/lib/features/tokenize/num_format/formatters/decf.rs index 3d420ecdb..07e1b3f47 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatters/decf.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatters/decf.rs @@ -7,8 +7,18 @@ use super::float_common::{get_primitive_dec, primitive_to_str_common, FloatAnaly const SIGNIFICANT_FIGURES: usize = 6; +// Parse a numeric string as the nearest integer with a given significance. +// This is a helper function for round(). +// Examples: +// round_to_significance("456", 1) == 500 +// round_to_significance("456", 2) == 460 +// round_to_significance("456", 9) == 456 fn round_to_significance(input: &str, significant_figures: usize) -> u32 { if significant_figures < input.len() { + // If the input has too many digits, use a float intermediary + // to round it before converting to an integer. Otherwise, + // converting straight to integer will truncate. + // There might be a cleaner way to do this... let digits = &input[..significant_figures + 1]; let float_representation = digits.parse::().unwrap(); (float_representation / 10.0).round() as u32 @@ -17,16 +27,45 @@ fn round_to_significance(input: &str, significant_figures: usize) -> u32 { } } -fn round(mut format: FormatPrimitive) -> FormatPrimitive { - let mut significant_figures = SIGNIFICANT_FIGURES; +// Removing trailing zeroes, expressing the result as an integer where +// possible. This is a helper function for round(). +fn truncate(mut format: FormatPrimitive) -> FormatPrimitive { + if let Some(ref post_dec) = format.post_decimal { + let trimmed = post_dec.trim_end_matches('0'); + if trimmed.is_empty() { + // If there are no nonzero digits after the decimal point, + // use integer formatting by clearing post_decimal and suffix. + format.post_decimal = Some("".into()); + if format.suffix == Some("e+00".into()) { + format.suffix = Some("".into()); + } + } else if trimmed.len() != post_dec.len() { + // Otherwise, update the format to remove only the trailing + // zeroes (e.g. "4.50" becomes "4.5", not "4"). If there were + // no trailing zeroes, do nothing. + format.post_decimal = Some(trimmed.to_owned()); + } + } + format +} + +// Round a format to six significant figures and remove trailing zeroes. +fn round(mut format: FormatPrimitive) -> FormatPrimitive { + let mut significant_digits_remaining = SIGNIFICANT_FIGURES; + + // First, take as many significant digits as possible from pre_decimal, if format.pre_decimal.is_some() { let input = format.pre_decimal.as_ref().unwrap(); - let rounded = round_to_significance(input, significant_figures); + let rounded = round_to_significance(input, significant_digits_remaining); let mut rounded_str = rounded.to_string(); - significant_figures -= rounded_str.len(); + significant_digits_remaining -= rounded_str.len(); - if significant_figures == 0 { + // If the pre_decimal has exactly enough significant digits, + // round the input to the nearest integer. If the first + // post_decimal digit is 5 or higher, round up by incrementing + // the pre_decimal number. Otherwise, use the pre_decimal as-is. + if significant_digits_remaining == 0 { if let Some(digits) = &format.post_decimal { if digits.chars().next().unwrap_or('0') >= '5' { let rounded = rounded + 1; @@ -37,46 +76,51 @@ fn round(mut format: FormatPrimitive) -> FormatPrimitive { format.pre_decimal = Some(rounded_str); } - if significant_figures == 0 { + // If no significant digits remain, or there's no post_decimal to + // round, return the rounded pre_decimal value with no post_decimal. + // Otherwise, round the post_decimal to the remaining significance. + if significant_digits_remaining == 0 { format.post_decimal = Some(String::new()); } else if let Some(input) = format.post_decimal { let leading_zeroes = input.len() - input.trim_start_matches('0').len(); + let digits = &input[leading_zeroes..]; - let rounded_str = if leading_zeroes <= significant_figures { - let mut post_decimal = String::with_capacity(significant_figures); - for _ in 0..leading_zeroes { - post_decimal.push('0'); - } - - significant_figures -= leading_zeroes; - let rounded = round_to_significance(&input[leading_zeroes..], significant_figures); - post_decimal.push_str(&rounded.to_string()); - post_decimal - } else { - input[..significant_figures].to_string() - }; - format.post_decimal = Some(rounded_str); - } - format -} - -fn truncate(mut format: FormatPrimitive) -> FormatPrimitive { - if let Some(ref post_dec) = format.post_decimal { - let trimmed = post_dec.trim_end_matches('0'); - - if trimmed.is_empty() { - format.post_decimal = Some("".into()); - if format.suffix == Some("e+00".into()) { - format.suffix = Some("".into()); - } - } else if trimmed.len() != post_dec.len() { - format.post_decimal = Some(trimmed.to_owned()); + // In the post_decimal, leading zeroes are significant. "01.0010" + // has one significant digit in pre_decimal, and 3 from post_decimal. + let mut post_decimal_str = String::with_capacity(significant_digits_remaining); + for _ in 0..leading_zeroes { + post_decimal_str.push('0'); } + + if leading_zeroes < significant_digits_remaining { + // After significant leading zeroes, round the remaining digits + // to any remaining significance. + let rounded = round_to_significance(digits, significant_digits_remaining); + post_decimal_str.push_str(&rounded.to_string()); + } else if leading_zeroes == significant_digits_remaining + && digits.chars().next().unwrap_or('0') >= '5' + { + // If necessary, round up the post_decimal ("1.000009" should + // round to 1.00001, instead of truncating after the last + // significant leading zero). + post_decimal_str.pop(); + post_decimal_str.push('1'); + } else { + // If the rounded post_decimal is entirely zeroes, discard + // it and use integer formatting instead. + post_decimal_str = "".into(); + } + + format.post_decimal = Some(post_decimal_str); } - format + truncate(format) } -fn is_float_magnitude(suffix: &Option) -> bool { +// Given an exponent used in scientific notation, return whether the +// number is small enough to be expressed as a decimal instead. "Small +// enough" is based only on the number's magnitude, not the length of +// any string representation. +fn should_represent_as_decimal(suffix: &Option) -> bool { match suffix { Some(exponent) => { if exponent.chars().nth(1) == Some('-') { @@ -121,7 +165,9 @@ impl Formatter for Decf { Some(*field.field_char == 'G'), ); - if is_float_magnitude(&f_dec.suffix) { + if should_represent_as_decimal(&f_dec.suffix) { + // Use decimal formatting instead of scientific notation + // if the input's magnitude is small. f_dec = get_primitive_dec( initial_prefix, &str_in[initial_prefix.offset..], @@ -131,8 +177,7 @@ impl Formatter for Decf { ); } - f_dec = truncate(round(f_dec)); - Some(f_dec) + Some(round(f_dec)) } fn primitive_to_str(&self, prim: &FormatPrimitive, field: FormatField) -> String { primitive_to_str_common(prim, &field) diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index cb7126b9b..d5be4cd17 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -514,3 +514,11 @@ fn sub_general_round_float_to_integer() { .succeeds() .stdout_only("123457"); } + +#[test] +fn sub_general_round_float_leading_zeroes() { + new_ucmd!() + .args(&["%g", "1.000009"]) + .succeeds() + .stdout_only("1.00001"); +} From d90a81fb464fc6d0c8683b6e2ef45ccb734d5c63 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sun, 20 Mar 2022 10:14:32 +0100 Subject: [PATCH 21/38] all utils: remove short help flag if another -h flag is present --- src/uu/chcon/src/chcon.rs | 6 ++++++ src/uu/chgrp/src/chgrp.rs | 5 +++++ src/uu/chown/src/chown.rs | 5 +++++ src/uu/df/src/df.rs | 6 ++++++ src/uu/du/src/du.rs | 6 ++++++ src/uu/ls/src/ls.rs | 6 ++++++ src/uu/nl/src/nl.rs | 6 ++++++ src/uu/od/src/od.rs | 6 ++++++ src/uu/sort/src/sort.rs | 6 ++++++ src/uu/touch/src/touch.rs | 6 ++++++ src/uucore/src/lib/features/perms.rs | 1 + 11 files changed, 59 insertions(+) diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index 8f5e0f26b..4d589eddd 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -29,6 +29,7 @@ const USAGE: &str = "\ {} [OPTION]... --reference=RFILE FILE..."; pub mod options { + pub static HELP: &str = "help"; pub static VERBOSE: &str = "verbose"; pub static REFERENCE: &str = "reference"; @@ -160,6 +161,11 @@ pub fn uu_app<'a>() -> Command<'a> { .about(ABOUT) .override_usage(format_usage(USAGE)) .infer_long_args(true) + .arg( + Arg::new(options::HELP) + .long(options::HELP) + .help("Print help information."), + ) .arg( Arg::new(options::dereference::DEREFERENCE) .long(options::dereference::DEREFERENCE) diff --git a/src/uu/chgrp/src/chgrp.rs b/src/uu/chgrp/src/chgrp.rs index ce1cb5f37..d7e8baafe 100644 --- a/src/uu/chgrp/src/chgrp.rs +++ b/src/uu/chgrp/src/chgrp.rs @@ -60,6 +60,11 @@ pub fn uu_app<'a>() -> Command<'a> { .about(ABOUT) .override_usage(format_usage(USAGE)) .infer_long_args(true) + .arg( + Arg::new(options::HELP) + .long(options::HELP) + .help("Print help information.") + ) .arg( Arg::new(options::verbosity::CHANGES) .short('c') diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs index c1d7d1420..3add9df1f 100644 --- a/src/uu/chown/src/chown.rs +++ b/src/uu/chown/src/chown.rs @@ -69,6 +69,11 @@ pub fn uu_app<'a>() -> Command<'a> { .about(ABOUT) .override_usage(format_usage(USAGE)) .infer_long_args(true) + .arg( + Arg::new(options::HELP) + .long(options::HELP) + .help("Print help information."), + ) .arg( Arg::new(options::verbosity::CHANGES) .short('c') diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 466d027bc..d41233139 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -29,6 +29,7 @@ static ABOUT: &str = "Show information about the file system on which each FILE or all file systems by default."; const USAGE: &str = "{} [OPTION]... [FILE]..."; +static OPT_HELP: &str = "help"; static OPT_ALL: &str = "all"; static OPT_BLOCKSIZE: &str = "blocksize"; static OPT_DIRECT: &str = "direct"; @@ -322,6 +323,11 @@ pub fn uu_app<'a>() -> Command<'a> { .about(ABOUT) .override_usage(format_usage(USAGE)) .infer_long_args(true) + .arg( + Arg::new(OPT_HELP) + .long(OPT_HELP) + .help("Print help information."), + ) .arg( Arg::new(OPT_ALL) .short('a') diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 8d97b8b47..0690c6299 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -47,6 +47,7 @@ use winapi::um::winbase::GetFileInformationByHandleEx; use winapi::um::winnt::{FILE_ID_128, ULONGLONG}; mod options { + pub const HELP: &str = "help"; pub const NULL: &str = "0"; pub const ALL: &str = "all"; pub const APPARENT_SIZE: &str = "apparent-size"; @@ -624,6 +625,11 @@ pub fn uu_app<'a>() -> Command<'a> { .after_help(LONG_HELP) .override_usage(format_usage(USAGE)) .infer_long_args(true) + .arg( + Arg::new(options::HELP) + .long(options::HELP) + .help("Print help information.") + ) .arg( Arg::new(options::ALL) .short('a') diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index a7dbc7b42..fa1900bbb 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -116,6 +116,7 @@ pub mod options { pub static DIR_ARGS: &str = "dereference-command-line-symlink-to-dir"; } + pub static HELP: &str = "help"; pub static QUOTING_STYLE: &str = "quoting-style"; pub static HIDE_CONTROL_CHARS: &str = "hide-control-chars"; pub static SHOW_CONTROL_CHARS: &str = "show-control-chars"; @@ -806,6 +807,11 @@ pub fn uu_app<'a>() -> Command<'a> { whose names start with '.'.", ) .infer_long_args(true) + .arg( + Arg::new(options::HELP) + .long(options::HELP) + .help("Print help information.") + ) // Format arguments .arg( Arg::new(options::FORMAT) diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 09ad9a816..28cf3fb4d 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -66,6 +66,7 @@ enum NumberFormat { } pub mod options { + pub const HELP: &str = "help"; pub const FILE: &str = "file"; pub const BODY_NUMBERING: &str = "body-numbering"; pub const SECTION_DELIMITER: &str = "section-delimiter"; @@ -145,6 +146,11 @@ pub fn uu_app<'a>() -> Command<'a> { .version(crate_version!()) .override_usage(format_usage(USAGE)) .infer_long_args(true) + .arg( + Arg::new(options::HELP) + .long(options::HELP) + .help("Print help information."), + ) .arg( Arg::new(options::FILE) .hide(true) diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index eeca0171a..81cfb94de 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -98,6 +98,7 @@ If an error occurred, a diagnostic message will be printed to stderr, and the exitcode will be non-zero."#; pub(crate) mod options { + pub const HELP: &str = "help"; pub const ADDRESS_RADIX: &str = "address-radix"; pub const SKIP_BYTES: &str = "skip-bytes"; pub const READ_BYTES: &str = "read-bytes"; @@ -299,6 +300,11 @@ pub fn uu_app<'a>() -> Command<'a> { .dont_delimit_trailing_values(true) .infer_long_args(true) .setting(AppSettings::DeriveDisplayOrder) + .arg( + Arg::new(options::HELP) + .long(options::HELP) + .help("Print help information.") + ) .arg( Arg::new(options::ADDRESS_RADIX) .short('A') diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 70cebad4f..c6e1583a7 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -98,6 +98,7 @@ mod options { pub const DIAGNOSE_FIRST: &str = "diagnose-first"; } + pub const HELP: &str = "help"; pub const DICTIONARY_ORDER: &str = "dictionary-order"; pub const MERGE: &str = "merge"; pub const DEBUG: &str = "debug"; @@ -1274,6 +1275,11 @@ pub fn uu_app<'a>() -> Command<'a> { .about(ABOUT) .override_usage(format_usage(USAGE)) .infer_long_args(true) + .arg( + Arg::new(options::HELP) + .long(options::HELP) + .help("Print help information."), + ) .arg( Arg::new(options::modes::SORT) .long(options::modes::SORT) diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index 220a8476e..864917574 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -31,6 +31,7 @@ pub mod options { pub static REFERENCE: &str = "reference"; pub static CURRENT: &str = "current"; } + pub static HELP: &str = "help"; pub static ACCESS: &str = "access"; pub static MODIFICATION: &str = "modification"; pub static NO_CREATE: &str = "no-create"; @@ -155,6 +156,11 @@ pub fn uu_app<'a>() -> Command<'a> { .about(ABOUT) .override_usage(format_usage(USAGE)) .infer_long_args(true) + .arg( + Arg::new(options::HELP) + .long(options::HELP) + .help("Print help information."), + ) .arg( Arg::new(options::ACCESS) .short('a') diff --git a/src/uucore/src/lib/features/perms.rs b/src/uucore/src/lib/features/perms.rs index 970b2fca9..d8e345313 100644 --- a/src/uucore/src/lib/features/perms.rs +++ b/src/uucore/src/lib/features/perms.rs @@ -383,6 +383,7 @@ impl ChownExecutor { } pub mod options { + pub const HELP: &str = "help"; pub mod verbosity { pub const CHANGES: &str = "changes"; pub const QUIET: &str = "quiet"; From efd627bb20c5ea3ba1aaef51948e6f6271afe7fd Mon Sep 17 00:00:00 2001 From: Sam Caldwell Date: Tue, 1 Feb 2022 20:26:33 -0700 Subject: [PATCH 22/38] cp: only allow directory for -t --- src/uu/cp/src/cp.rs | 6 ++++++ tests/by-util/test_cp.rs | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index a4a512d6b..36916aef1 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -315,6 +315,12 @@ pub fn uu_app<'a>() -> App<'a> { .long(options::TARGET_DIRECTORY) .value_name(options::TARGET_DIRECTORY) .takes_value(true) + .validator(|s| { + if Path::new(s).is_dir() { + return Ok(()); + } + Err("must specify a directory") + }) .help("copy all SOURCE arguments into target-directory")) .arg(Arg::new(options::NO_TARGET_DIRECTORY) .short('T') diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 9ee76bb5e..443e67557 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -183,6 +183,16 @@ fn test_cp_arg_no_target_directory() { .stderr_contains("cannot overwrite directory"); } +#[test] +fn test_cp_target_directory_is_file() { + new_ucmd!() + .arg("-t") + .arg(TEST_HOW_ARE_YOU_SOURCE) + .arg(TEST_HELLO_WORLD_SOURCE) + .fails() + .stderr_contains("must specify a directory"); +} + #[test] fn test_cp_arg_interactive() { new_ucmd!() From 979909e3714aed5d11ce3203ece76bc0fe527a77 Mon Sep 17 00:00:00 2001 From: Sam Caldwell Date: Mon, 7 Feb 2022 20:06:27 -0700 Subject: [PATCH 23/38] cp: better error message for target-directory --- src/uu/cp/src/cp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 36916aef1..b94953fdf 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -319,7 +319,7 @@ pub fn uu_app<'a>() -> App<'a> { if Path::new(s).is_dir() { return Ok(()); } - Err("must specify a directory") + Err(format!("'{}' is not a directory", s)) }) .help("copy all SOURCE arguments into target-directory")) .arg(Arg::new(options::NO_TARGET_DIRECTORY) From f40fecf86d9365d17af1f6703cde1f5cbd3b9b03 Mon Sep 17 00:00:00 2001 From: Sam Caldwell Date: Mon, 28 Feb 2022 23:30:29 -0700 Subject: [PATCH 24/38] Add UError impl for clap::Error --- src/uu/cp/src/cp.rs | 2 +- src/uucore/src/lib/mods/error.rs | 11 +++++++++++ tests/by-util/test_cp.rs | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index b94953fdf..edd4f1bf2 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -475,7 +475,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { LONG_HELP, backup_control::BACKUP_CONTROL_LONG_HELP )) - .get_matches_from(args); + .try_get_matches_from(args)?; let options = Options::from_matches(&matches)?; diff --git a/src/uucore/src/lib/mods/error.rs b/src/uucore/src/lib/mods/error.rs index ba7722f1c..15d53233e 100644 --- a/src/uucore/src/lib/mods/error.rs +++ b/src/uucore/src/lib/mods/error.rs @@ -50,6 +50,7 @@ // spell-checker:ignore uioerror +use clap; use std::{ error::Error, fmt::{Display, Formatter}, @@ -615,3 +616,13 @@ impl From for Box { ExitCode::new(i) } } + +/// Implementations for clap::Error +impl UError for clap::Error { + fn code(&self) -> i32 { + match self.kind { + clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => 0, + _ => 1, + } + } +} diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 443e67557..11afa469e 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -190,7 +190,7 @@ fn test_cp_target_directory_is_file() { .arg(TEST_HOW_ARE_YOU_SOURCE) .arg(TEST_HELLO_WORLD_SOURCE) .fails() - .stderr_contains("must specify a directory"); + .stderr_contains(format!("'{}' is not a directory", TEST_HOW_ARE_YOU_SOURCE)); } #[test] From b79ff6b4fd4d68d30a4cc12077f63dc18eb4aef4 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sun, 20 Mar 2022 00:19:36 -0400 Subject: [PATCH 25/38] split: avoid writing final empty chunk with -C Fix a bug in which a final empty file was written when using `split --line-bytes` mode. --- src/uu/split/src/split.rs | 11 +++++------ tests/by-util/test_split.rs | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 11cf776c6..1082af248 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -858,6 +858,11 @@ impl<'a> Write for LineBytesChunkWriter<'a> { // Loop until we have written all bytes in the input buffer // (or an IO error occurs). loop { + // If the buffer is empty, then we are done writing. + if buf.is_empty() { + return Ok(total_bytes_written); + } + // If we have filled the current chunk with bytes, then // start a new chunk and initialize its corresponding // writer. @@ -875,12 +880,6 @@ impl<'a> Write for LineBytesChunkWriter<'a> { // Find the first newline character in the buffer. match memchr::memchr(b'\n', buf) { - // If there is no newline character and the buffer is - // empty, then we are done writing. - None if buf.is_empty() => { - return Ok(total_bytes_written); - } - // If there is no newline character and the buffer is // not empty, then write as many bytes as we can and // then move on to the next chunk if necessary. diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 950ba59bc..87c37787e 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -634,3 +634,24 @@ fn test_line_bytes_no_final_newline() { assert_eq!(at.read("xae"), "3\n"); assert_eq!(at.read("xaf"), "4"); } + +#[test] +fn test_line_bytes_no_empty_file() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-C", "1"]) + .pipe_in("1\n2222\n3\n4") + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("xaa"), "1"); + assert_eq!(at.read("xab"), "\n"); + assert_eq!(at.read("xac"), "2"); + assert_eq!(at.read("xad"), "2"); + assert_eq!(at.read("xae"), "2"); + assert_eq!(at.read("xaf"), "2"); + assert_eq!(at.read("xag"), "\n"); + assert_eq!(at.read("xah"), "3"); + assert_eq!(at.read("xai"), "\n"); + assert_eq!(at.read("xaj"), "4"); + assert!(!at.plus("xak").exists()); +} From 34d2d1d05e38b35b567bcbfb656be77af35f8379 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 20 Mar 2022 18:14:52 +0000 Subject: [PATCH 26/38] build(deps): bump libc from 0.2.113 to 0.2.121 Bumps [libc](https://github.com/rust-lang/libc) from 0.2.113 to 0.2.121. - [Release notes](https://github.com/rust-lang/libc/releases) - [Commits](https://github.com/rust-lang/libc/compare/0.2.113...0.2.121) --- updated-dependencies: - dependency-name: libc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- src/uu/chmod/Cargo.toml | 2 +- src/uu/cp/Cargo.toml | 2 +- src/uu/hostid/Cargo.toml | 2 +- src/uu/kill/Cargo.toml | 2 +- src/uu/logname/Cargo.toml | 2 +- src/uu/mkfifo/Cargo.toml | 2 +- src/uu/mknod/Cargo.toml | 2 +- src/uu/nice/Cargo.toml | 2 +- src/uu/nohup/Cargo.toml | 2 +- src/uu/nproc/Cargo.toml | 2 +- src/uu/pathchk/Cargo.toml | 2 +- src/uu/rmdir/Cargo.toml | 2 +- src/uu/sync/Cargo.toml | 2 +- src/uu/tail/Cargo.toml | 2 +- src/uu/tee/Cargo.toml | 2 +- src/uu/test/Cargo.toml | 2 +- src/uu/timeout/Cargo.toml | 2 +- src/uu/tty/Cargo.toml | 2 +- src/uu/whoami/Cargo.toml | 2 +- src/uucore/Cargo.toml | 2 +- 21 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c57717b8..831efd712 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1065,9 +1065,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.113" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9" +checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" [[package]] name = "libloading" diff --git a/src/uu/chmod/Cargo.toml b/src/uu/chmod/Cargo.toml index da23c62ef..1c52e2f2d 100644 --- a/src/uu/chmod/Cargo.toml +++ b/src/uu/chmod/Cargo.toml @@ -16,7 +16,7 @@ path = "src/chmod.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] } [[bin]] diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index 46637dadf..735a1fab3 100644 --- a/src/uu/cp/Cargo.toml +++ b/src/uu/cp/Cargo.toml @@ -21,7 +21,7 @@ path = "src/cp.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } filetime = "0.2" -libc = "0.2.85" +libc = "0.2.121" quick-error = "2.0.1" selinux = { version="0.2", optional=true } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms", "mode"] } diff --git a/src/uu/hostid/Cargo.toml b/src/uu/hostid/Cargo.toml index c1eeb413a..148804768 100644 --- a/src/uu/hostid/Cargo.toml +++ b/src/uu/hostid/Cargo.toml @@ -16,7 +16,7 @@ path = "src/hostid.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/kill/Cargo.toml b/src/uu/kill/Cargo.toml index a542cbd31..fb45a346b 100644 --- a/src/uu/kill/Cargo.toml +++ b/src/uu/kill/Cargo.toml @@ -16,7 +16,7 @@ path = "src/kill.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["signals"] } [[bin]] diff --git a/src/uu/logname/Cargo.toml b/src/uu/logname/Cargo.toml index 69bb32dbc..c3112cba5 100644 --- a/src/uu/logname/Cargo.toml +++ b/src/uu/logname/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/logname.rs" [dependencies] -libc = "0.2.42" +libc = "0.2.121" clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/mkfifo/Cargo.toml b/src/uu/mkfifo/Cargo.toml index 2a849fd3b..5fe9c9eb5 100644 --- a/src/uu/mkfifo/Cargo.toml +++ b/src/uu/mkfifo/Cargo.toml @@ -16,7 +16,7 @@ path = "src/mkfifo.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/mknod/Cargo.toml b/src/uu/mknod/Cargo.toml index c3eef1129..8a21d9a82 100644 --- a/src/uu/mknod/Cargo.toml +++ b/src/uu/mknod/Cargo.toml @@ -17,7 +17,7 @@ path = "src/mknod.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "^0.2.42" +libc = "^0.2.121" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["mode"] } [[bin]] diff --git a/src/uu/nice/Cargo.toml b/src/uu/nice/Cargo.toml index e814cd466..e139d9102 100644 --- a/src/uu/nice/Cargo.toml +++ b/src/uu/nice/Cargo.toml @@ -16,7 +16,7 @@ path = "src/nice.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" nix = "0.23.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/nohup/Cargo.toml b/src/uu/nohup/Cargo.toml index dd76cb703..78510ec96 100644 --- a/src/uu/nohup/Cargo.toml +++ b/src/uu/nohup/Cargo.toml @@ -16,7 +16,7 @@ path = "src/nohup.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/nproc/Cargo.toml b/src/uu/nproc/Cargo.toml index 8620b9cf2..38ed295cf 100644 --- a/src/uu/nproc/Cargo.toml +++ b/src/uu/nproc/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/nproc.rs" [dependencies] -libc = "0.2.42" +libc = "0.2.121" num_cpus = "1.10" clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/pathchk/Cargo.toml b/src/uu/pathchk/Cargo.toml index 2877efca3..a60aa38ca 100644 --- a/src/uu/pathchk/Cargo.toml +++ b/src/uu/pathchk/Cargo.toml @@ -16,7 +16,7 @@ path = "src/pathchk.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/rmdir/Cargo.toml b/src/uu/rmdir/Cargo.toml index d79e41d7f..97ce48b1e 100644 --- a/src/uu/rmdir/Cargo.toml +++ b/src/uu/rmdir/Cargo.toml @@ -17,7 +17,7 @@ path = "src/rmdir.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -libc = "0.2.42" +libc = "0.2.121" [[bin]] name = "rmdir" diff --git a/src/uu/sync/Cargo.toml b/src/uu/sync/Cargo.toml index ce085a1d8..edddee204 100644 --- a/src/uu/sync/Cargo.toml +++ b/src/uu/sync/Cargo.toml @@ -16,7 +16,7 @@ path = "src/sync.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] } winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "std", "winbase", "winerror"] } diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index 0a26ccf1f..39ce7b72b 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -16,7 +16,7 @@ path = "src/tail.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer", "lines"] } [target.'cfg(windows)'.dependencies] diff --git a/src/uu/tee/Cargo.toml b/src/uu/tee/Cargo.toml index f121d22ce..8dd41f7db 100644 --- a/src/uu/tee/Cargo.toml +++ b/src/uu/tee/Cargo.toml @@ -16,7 +16,7 @@ path = "src/tee.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" retain_mut = "=0.1.2" # ToDO: [2021-01-01; rivy; maint/MinSRV] ~ v0.1.5 uses const generics which aren't stabilized until rust v1.51.0 uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc"] } diff --git a/src/uu/test/Cargo.toml b/src/uu/test/Cargo.toml index 10e411b51..e45610547 100644 --- a/src/uu/test/Cargo.toml +++ b/src/uu/test/Cargo.toml @@ -16,7 +16,7 @@ path = "src/test.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [target.'cfg(target_os = "redox")'.dependencies] diff --git a/src/uu/timeout/Cargo.toml b/src/uu/timeout/Cargo.toml index 9dbd87240..a2bd8bb4e 100644 --- a/src/uu/timeout/Cargo.toml +++ b/src/uu/timeout/Cargo.toml @@ -16,7 +16,7 @@ path = "src/timeout.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" nix = "0.23.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["process", "signals"] } diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index 30c32b459..97cb2b357 100644 --- a/src/uu/tty/Cargo.toml +++ b/src/uu/tty/Cargo.toml @@ -16,7 +16,7 @@ path = "src/tty.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.42" +libc = "0.2.121" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/whoami/Cargo.toml b/src/uu/whoami/Cargo.toml index 8b92e7e63..807e99b35 100644 --- a/src/uu/whoami/Cargo.toml +++ b/src/uu/whoami/Cargo.toml @@ -22,7 +22,7 @@ uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=[ winapi = { version = "0.3", features = ["lmcons"] } [target.'cfg(unix)'.dependencies] -libc = "0.2.42" +libc = "0.2.121" [[bin]] name = "whoami" diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index c0fec88ee..d2d819edd 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -29,7 +29,7 @@ time = { version="<= 0.1.43", optional=true } data-encoding = { version="2.1", optional=true } data-encoding-macro = { version="0.1.12", optional=true } z85 = { version="3.0.3", optional=true } -libc = { version="0.2.15", optional=true } +libc = { version="0.2.121", optional=true } once_cell = "1.10.0" os_display = "0.1.0" From e849aaf846ffc894c7a0fff916ff0729d4c13d83 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sun, 20 Mar 2022 15:16:03 -0400 Subject: [PATCH 27/38] timeout: give usage error on invalid time interval --- src/uu/timeout/src/timeout.rs | 4 ++-- tests/by-util/test_timeout.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index 192892d4f..c48bee1e6 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -19,7 +19,7 @@ use std::io::ErrorKind; use std::process::{self, Child, Stdio}; use std::time::Duration; use uucore::display::Quotable; -use uucore::error::{UResult, USimpleError}; +use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::process::ChildExt; use uucore::signals::{signal_by_name_or_value, signal_name_by_value}; use uucore::{format_usage, InvalidEncodingHandling}; @@ -72,7 +72,7 @@ impl Config { let duration = match uucore::parse_time::from_str(options.value_of(options::DURATION).unwrap()) { Ok(duration) => duration, - Err(err) => return Err(USimpleError::new(1, err)), + Err(err) => return Err(UUsageError::new(1, err)), }; let preserve_status: bool = options.is_present(options::PRESERVE_STATUS); diff --git a/tests/by-util/test_timeout.rs b/tests/by-util/test_timeout.rs index 96a5b6a05..ac2d3e539 100644 --- a/tests/by-util/test_timeout.rs +++ b/tests/by-util/test_timeout.rs @@ -11,6 +11,14 @@ fn test_subcommand_return_code() { new_ucmd!().arg("1").arg("false").run().status_code(1); } +#[test] +fn test_invalid_time_interval() { + new_ucmd!() + .args(&["xyz", "sleep", "0"]) + .fails() + .usage_error("invalid time interval 'xyz'"); +} + #[test] fn test_command_with_args() { new_ucmd!() From c39c917db7039e5f664c803293461e952d11d141 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sun, 20 Mar 2022 15:21:50 -0400 Subject: [PATCH 28/38] sleep: give usage error on invalid time interval For example, $ sleep xyz sleep: invalid time interval 'xyz' Try 'sleep --help' for more information. This matches the behavior of GNU sleep. --- src/uu/sleep/src/sleep.rs | 4 ++-- tests/by-util/test_sleep.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/uu/sleep/src/sleep.rs b/src/uu/sleep/src/sleep.rs index 385f2017c..4d5095c31 100644 --- a/src/uu/sleep/src/sleep.rs +++ b/src/uu/sleep/src/sleep.rs @@ -9,7 +9,7 @@ use std::thread; use std::time::Duration; use uucore::{ - error::{UResult, USimpleError}, + error::{UResult, UUsageError}, format_usage, }; @@ -64,7 +64,7 @@ fn sleep(args: &[&str]) -> UResult<()> { Duration::new(0, 0), |result, arg| match uucore::parse_time::from_str(&arg[..]) { Ok(m) => Ok(m.saturating_add(result)), - Err(f) => Err(USimpleError::new(1, f)), + Err(f) => Err(UUsageError::new(1, f)), }, )?; thread::sleep(sleep_dur); diff --git a/tests/by-util/test_sleep.rs b/tests/by-util/test_sleep.rs index d33143ae0..6c3f940e8 100644 --- a/tests/by-util/test_sleep.rs +++ b/tests/by-util/test_sleep.rs @@ -3,6 +3,14 @@ use crate::common::util::*; use std::time::{Duration, Instant}; +#[test] +fn test_invalid_time_interval() { + new_ucmd!() + .arg("xyz") + .fails() + .usage_error("invalid time interval 'xyz'"); +} + #[test] fn test_sleep_no_suffix() { let millis_100 = Duration::from_millis(100); From af8726af4307825a7eed3f60eeb5e9449a03ba99 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 20 Mar 2022 19:58:21 +0100 Subject: [PATCH 29/38] 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 a1d6a8f17a20b49bce97ea794758d46aef2dc165 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 21 Mar 2022 09:13:33 +0100 Subject: [PATCH 30/38] sort: add two missing spaces in help texts --- src/uu/sort/src/sort.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index c6e1583a7..b5b03454d 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -55,7 +55,7 @@ use uucore::{format_usage, InvalidEncodingHandling}; use crate::tmp_dir::TmpDirWrapper; const ABOUT: &str = "\ - Display sorted concatenation of all FILE(s).\ + Display sorted concatenation of all FILE(s). \ With no FILE, or when FILE is -, read standard input."; const USAGE: &str = "{} [OPTION]... [FILE]..."; @@ -1363,7 +1363,7 @@ pub fn uu_app<'a>() -> Command<'a> { .long(options::check::CHECK_SILENT) .conflicts_with(options::OUTPUT) .help( - "exit successfully if the given file is already sorted,\ + "exit successfully if the given file is already sorted, \ and exit with status 1 otherwise.", ), ) From 3009c73e9c080d89ca24e9396945afd36179c2eb Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 21 Mar 2022 09:13:56 +0100 Subject: [PATCH 31/38] 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 32/38] 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(".."); +} From 4942e519fa104d2d3a7e5ae1257326c448a8eb27 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 20 Mar 2022 23:16:03 +0100 Subject: [PATCH 33/38] nproc: add the full support of OMP_THREAD_LIMIT --- src/uu/nproc/src/nproc.rs | 17 ++++++++++++++--- tests/by-util/test_nproc.rs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/uu/nproc/src/nproc.rs b/src/uu/nproc/src/nproc.rs index fdebea65a..2615e0c66 100644 --- a/src/uu/nproc/src/nproc.rs +++ b/src/uu/nproc/src/nproc.rs @@ -25,7 +25,9 @@ pub const _SC_NPROCESSORS_CONF: libc::c_int = 1001; static OPT_ALL: &str = "all"; static OPT_IGNORE: &str = "ignore"; -static ABOUT: &str = "Print the number of cores available to the current process."; +static ABOUT: &str = r#"Print the number of cores available to the current process. +If the OMP_NUM_THREADS or OMP_THREAD_LIMIT environment variables are set, then +they will determine the minimum and maximum returned value respectively."#; const USAGE: &str = "{} [OPTIONS]..."; #[uucore::main] @@ -45,6 +47,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { None => 0, }; + let limit = match env::var("OMP_THREAD_LIMIT") { + // Uses the OpenMP variable to limit the number of threads + // If the parsing fails, returns the max size (so, no impact) + Ok(threadstr) => threadstr.parse().unwrap_or(usize::MAX), + // the variable 'OMP_THREAD_LIMIT' doesn't exist + // fallback to the max + Err(_) => usize::MAX, + }; + let mut cores = if matches.is_present(OPT_ALL) { num_cpus_all() } else { @@ -53,12 +64,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // Uses the OpenMP variable to force the number of threads // If the parsing fails, returns the number of CPU Ok(threadstr) => threadstr.parse().unwrap_or_else(|_| num_cpus::get()), - // the variable 'OMP_NUM_THREADS' doesn't exit + // the variable 'OMP_NUM_THREADS' doesn't exist // fallback to the regular CPU detection Err(_) => num_cpus::get(), } }; - + cores = std::cmp::min(limit, cores); if cores <= ignore { cores = 1; } else { diff --git a/tests/by-util/test_nproc.rs b/tests/by-util/test_nproc.rs index 5657e6b7e..6d3fb1fd0 100644 --- a/tests/by-util/test_nproc.rs +++ b/tests/by-util/test_nproc.rs @@ -72,3 +72,37 @@ fn test_nproc_ignore_all_omp() { let nproc: u8 = result.stdout_str().trim().parse().unwrap(); assert!(nproc == 2); } + +#[test] +fn test_nproc_omp_limit() { + let result = TestScenario::new(util_name!()) + .ucmd_keepenv() + .env("OMP_NUM_THREADS", "42") + .env("OMP_THREAD_LIMIT", "0") + .succeeds(); + let nproc: u8 = result.stdout_str().trim().parse().unwrap(); + assert!(nproc == 1); + + let result = TestScenario::new(util_name!()) + .ucmd_keepenv() + .env("OMP_NUM_THREADS", "42") + .env("OMP_THREAD_LIMIT", "2") + .succeeds(); + let nproc: u8 = result.stdout_str().trim().parse().unwrap(); + assert!(nproc == 2); + + let result = TestScenario::new(util_name!()) + .ucmd_keepenv() + .env("OMP_NUM_THREADS", "42") + .env("OMP_THREAD_LIMIT", "2bad") + .succeeds(); + let nproc: u8 = result.stdout_str().trim().parse().unwrap(); + assert!(nproc == 42); + + let result = TestScenario::new(util_name!()) + .ucmd_keepenv() + .env("OMP_THREAD_LIMIT", "1") + .succeeds(); + let nproc: u8 = result.stdout_str().trim().parse().unwrap(); + assert!(nproc == 1); +} From 2024cc37e63ef9b1cd7ccc52ba2b44dd9514d5c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 16:50:55 +0000 Subject: [PATCH 34/38] build(deps): bump ouroboros from 0.14.2 to 0.15.0 Bumps [ouroboros](https://github.com/joshua-maros/ouroboros) from 0.14.2 to 0.15.0. - [Release notes](https://github.com/joshua-maros/ouroboros/releases) - [Commits](https://github.com/joshua-maros/ouroboros/compare/0.14.2...0.15.0) --- updated-dependencies: - dependency-name: ouroboros dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ src/uu/sort/Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c57717b8..8e159029a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1065,9 +1065,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.113" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9" +checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" [[package]] name = "libloading" @@ -1375,9 +1375,9 @@ dependencies = [ [[package]] name = "ouroboros" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71643f290d126e18ac2598876d01e1d57aed164afc78fdb6e2a0c6589a1f6662" +checksum = "9f31a3b678685b150cba82b702dcdc5e155893f63610cf388d30cd988d4ca2bf" dependencies = [ "aliasable", "ouroboros_macro", @@ -1386,9 +1386,9 @@ dependencies = [ [[package]] name = "ouroboros_macro" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9a247206016d424fe8497bc611e510887af5c261fbbf977877c4bb55ca4d82" +checksum = "084fd65d5dd8b3772edccb5ffd1e4b7eba43897ecd0f9401e330e8c542959408" dependencies = [ "Inflector", "proc-macro-error", diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index 2adf49c44..b1c152acf 100644 --- a/src/uu/sort/Cargo.toml +++ b/src/uu/sort/Cargo.toml @@ -22,7 +22,7 @@ ctrlc = { version = "3.0", features = ["termination"] } fnv = "1.0.7" itertools = "0.10.0" memchr = "2.4.0" -ouroboros = "0.14.2" +ouroboros = "0.15.0" rand = "0.8" rayon = "1.5" tempfile = "3" From d8102503bfccfb75966f30826548b46272211633 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 21 Mar 2022 21:39:16 +0000 Subject: [PATCH 35/38] fsext solaris/illumos build fix --- .../cspell.dictionaries/acronyms+names.wordlist.txt | 1 + docs/compiles_table.py | 2 ++ src/uucore/src/lib/features/fsext.rs | 10 +++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt b/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt index 53307bf35..81bc3bc5f 100644 --- a/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt +++ b/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt @@ -48,6 +48,7 @@ EditorConfig FreeBSD Gmail GNU +Illumos Irix MS-DOS MSDOS diff --git a/docs/compiles_table.py b/docs/compiles_table.py index aa1b8703c..e2c4c0a8d 100644 --- a/docs/compiles_table.py +++ b/docs/compiles_table.py @@ -40,6 +40,8 @@ TARGETS = [ "x86_64-linux-android", # Solaris "x86_64-sun-solaris", + # Illumos + "x86_64-unknown-illumos", # WASM "wasm32-wasi", # Redox diff --git a/src/uucore/src/lib/features/fsext.rs b/src/uucore/src/lib/features/fsext.rs index b8207d68c..cf17067e8 100644 --- a/src/uucore/src/lib/features/fsext.rs +++ b/src/uucore/src/lib/features/fsext.rs @@ -90,6 +90,8 @@ pub use libc::statfs as StatFs; target_os = "netbsd", target_os = "bitrig", target_os = "dragonfly", + target_os = "illumos", + target_os = "solaris", target_os = "redox" ))] pub use libc::statvfs as StatFs; @@ -100,13 +102,15 @@ pub use libc::statvfs as StatFs; target_os = "android", target_os = "freebsd", target_os = "openbsd", + target_os = "redox" ))] pub use libc::statfs as statfs_fn; #[cfg(any( target_os = "netbsd", target_os = "bitrig", - target_os = "dragonfly", - target_os = "redox" + target_os = "illumos", + target_os = "solaris", + target_os = "dragonfly" ))] pub use libc::statvfs as statfs_fn; @@ -476,7 +480,7 @@ pub fn read_fs_list() -> Vec { } mounts } - #[cfg(target_os = "redox")] + #[cfg(any(target_os = "redox", target_os = "illumos", target_os = "solaris"))] { // No method to read mounts, yet Vec::new() From f4af22682068f44a32523ad929b3a3f3e66f156b Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sun, 20 Mar 2022 15:35:32 -0400 Subject: [PATCH 36/38] uucore: error on negative interval in parse_time Return an error when a negative interval is provided as the argument to `uucore::parse_time::from_str()`, since a `Duration` should only be non-negative. --- src/uucore/src/lib/parser/parse_time.rs | 9 +++++++++ tests/by-util/test_sleep.rs | 8 ++++++++ tests/by-util/test_timeout.rs | 8 ++++++++ 3 files changed, 25 insertions(+) diff --git a/src/uucore/src/lib/parser/parse_time.rs b/src/uucore/src/lib/parser/parse_time.rs index 366eebdea..79387c0b1 100644 --- a/src/uucore/src/lib/parser/parse_time.rs +++ b/src/uucore/src/lib/parser/parse_time.rs @@ -63,6 +63,10 @@ pub fn from_str(string: &str) -> Result { .parse::() .map_err(|e| format!("invalid time interval {}: {}", string.quote(), e))?; + if num < 0. { + return Err(format!("invalid time interval {}", string.quote())); + } + const NANOS_PER_SEC: u32 = 1_000_000_000; let whole_secs = num.trunc(); let nanos = (num.fract() * (NANOS_PER_SEC as f64)).trunc(); @@ -105,4 +109,9 @@ mod tests { fn test_error_invalid_magnitude() { assert!(from_str("12abc3s").is_err()); } + + #[test] + fn test_negative() { + assert!(from_str("-1").is_err()); + } } diff --git a/tests/by-util/test_sleep.rs b/tests/by-util/test_sleep.rs index 6c3f940e8..c7c6b3af1 100644 --- a/tests/by-util/test_sleep.rs +++ b/tests/by-util/test_sleep.rs @@ -149,3 +149,11 @@ fn test_sum_overflow() { .no_stderr() .no_stdout(); } + +#[test] +fn test_negative_interval() { + new_ucmd!() + .args(&["--", "-1"]) + .fails() + .usage_error("invalid time interval '-1'"); +} diff --git a/tests/by-util/test_timeout.rs b/tests/by-util/test_timeout.rs index ac2d3e539..01ff85590 100644 --- a/tests/by-util/test_timeout.rs +++ b/tests/by-util/test_timeout.rs @@ -89,3 +89,11 @@ fn test_dont_overflow() { .no_stderr() .no_stdout(); } + +#[test] +fn test_negative_interval() { + new_ucmd!() + .args(&["--", "-1", "sleep", "0"]) + .fails() + .usage_error("invalid time interval '-1'"); +} From e357d2650c1034cfbf5a966b35682485519cccd9 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Tue, 22 Mar 2022 21:44:11 -0400 Subject: [PATCH 37/38] clippy fixes from nightly rust --- src/uu/chcon/src/chcon.rs | 16 +++++----- src/uu/chroot/src/error.rs | 18 ++++++------ src/uu/cp/src/cp.rs | 6 ++-- src/uu/dd/src/parseargs.rs | 8 ++--- src/uu/expr/src/tokens.rs | 2 +- src/uu/groups/src/groups.rs | 6 ++-- src/uu/hashsum/src/hashsum.rs | 4 +-- src/uu/nohup/src/nohup.rs | 8 ++--- src/uu/numfmt/src/options.rs | 10 +++---- src/uu/ptx/src/ptx.rs | 6 ++-- src/uu/seq/src/extendedbigdecimal.rs | 14 ++++----- src/uu/sort/src/sort.rs | 32 ++++++++++---------- src/uu/split/src/filenames.rs | 6 ++-- src/uu/tr/src/operation.rs | 44 ++++++++++++++-------------- src/uucore/src/lib/mods/error.rs | 2 +- 15 files changed, 90 insertions(+), 92 deletions(-) diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index 4d589eddd..e49191ea3 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -408,23 +408,21 @@ enum RecursiveMode { impl RecursiveMode { fn is_recursive(self) -> bool { match self { - RecursiveMode::NotRecursive => false, + Self::NotRecursive => false, - RecursiveMode::RecursiveButDoNotFollowSymLinks - | RecursiveMode::RecursiveAndFollowAllDirSymLinks - | RecursiveMode::RecursiveAndFollowArgDirSymLinks => true, + Self::RecursiveButDoNotFollowSymLinks + | Self::RecursiveAndFollowAllDirSymLinks + | Self::RecursiveAndFollowArgDirSymLinks => true, } } fn fts_open_options(self) -> c_int { match self { - RecursiveMode::NotRecursive | RecursiveMode::RecursiveButDoNotFollowSymLinks => { - fts_sys::FTS_PHYSICAL - } + Self::NotRecursive | Self::RecursiveButDoNotFollowSymLinks => fts_sys::FTS_PHYSICAL, - RecursiveMode::RecursiveAndFollowAllDirSymLinks => fts_sys::FTS_LOGICAL, + Self::RecursiveAndFollowAllDirSymLinks => fts_sys::FTS_LOGICAL, - RecursiveMode::RecursiveAndFollowArgDirSymLinks => { + Self::RecursiveAndFollowArgDirSymLinks => { fts_sys::FTS_PHYSICAL | fts_sys::FTS_COMFOLLOW } } diff --git a/src/uu/chroot/src/error.rs b/src/uu/chroot/src/error.rs index ebf8f6212..69e8ac54b 100644 --- a/src/uu/chroot/src/error.rs +++ b/src/uu/chroot/src/error.rs @@ -55,25 +55,25 @@ impl UError for ChrootError { impl Display for ChrootError { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { - ChrootError::CannotEnter(s, e) => write!(f, "cannot chroot to {}: {}", s.quote(), e,), - ChrootError::CommandFailed(s, e) => { + Self::CannotEnter(s, e) => write!(f, "cannot chroot to {}: {}", s.quote(), e,), + Self::CommandFailed(s, e) => { write!(f, "failed to run command {}: {}", s.to_string().quote(), e,) } - ChrootError::InvalidUserspec(s) => write!(f, "invalid userspec: {}", s.quote(),), - ChrootError::MissingNewRoot => write!( + Self::InvalidUserspec(s) => write!(f, "invalid userspec: {}", s.quote(),), + Self::MissingNewRoot => write!( f, "Missing operand: NEWROOT\nTry '{} --help' for more information.", uucore::execution_phrase(), ), - ChrootError::NoSuchGroup(s) => write!(f, "no such group: {}", s.maybe_quote(),), - ChrootError::NoSuchDirectory(s) => write!( + Self::NoSuchGroup(s) => write!(f, "no such group: {}", s.maybe_quote(),), + Self::NoSuchDirectory(s) => write!( f, "cannot change root directory to {}: no such directory", s.quote(), ), - ChrootError::SetGidFailed(s, e) => write!(f, "cannot set gid to {}: {}", s, e), - ChrootError::SetGroupsFailed(e) => write!(f, "cannot set groups: {}", e), - ChrootError::SetUserFailed(s, e) => { + Self::SetGidFailed(s, e) => write!(f, "cannot set gid to {}: {}", s, e), + Self::SetGroupsFailed(e) => write!(f, "cannot set groups: {}", e), + Self::SetUserFailed(s, e) => { write!(f, "cannot set user to {}: {}", s.maybe_quote(), e) } } diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 8a8d7e30b..d69bb705b 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1093,8 +1093,8 @@ fn copy_directory( impl OverwriteMode { fn verify(&self, path: &Path) -> CopyResult<()> { match *self { - OverwriteMode::NoClobber => Err(Error::NotAllFilesCopied), - OverwriteMode::Interactive(_) => { + Self::NoClobber => Err(Error::NotAllFilesCopied), + Self::Interactive(_) => { if prompt_yes!("{}: overwrite {}? ", uucore::util_name(), path.quote()) { Ok(()) } else { @@ -1104,7 +1104,7 @@ impl OverwriteMode { ))) } } - OverwriteMode::Clobber(_) => Ok(()), + Self::Clobber(_) => Ok(()), } } } diff --git a/src/uu/dd/src/parseargs.rs b/src/uu/dd/src/parseargs.rs index 75703b629..8f2f10e70 100644 --- a/src/uu/dd/src/parseargs.rs +++ b/src/uu/dd/src/parseargs.rs @@ -100,16 +100,16 @@ impl std::fmt::Display for ParseError { Self::StatusLevelNotRecognized(arg) => { write!(f, "status=LEVEL not recognized -> {}", arg) } - ParseError::BsOutOfRange => { + Self::BsOutOfRange => { write!(f, "bs=N cannot fit into memory") } - ParseError::IbsOutOfRange => { + Self::IbsOutOfRange => { write!(f, "ibs=N cannot fit into memory") } - ParseError::ObsOutOfRange => { + Self::ObsOutOfRange => { write!(f, "obs=N cannot fit into memory") } - ParseError::CbsOutOfRange => { + Self::CbsOutOfRange => { write!(f, "cbs=N cannot fit into memory") } Self::Unimplemented(arg) => { diff --git a/src/uu/expr/src/tokens.rs b/src/uu/expr/src/tokens.rs index 247046941..a0365898d 100644 --- a/src/uu/expr/src/tokens.rs +++ b/src/uu/expr/src/tokens.rs @@ -65,7 +65,7 @@ impl Token { } } fn is_a_close_paren(&self) -> bool { - matches!(*self, Token::ParClose) + matches!(*self, Self::ParClose) } } diff --git a/src/uu/groups/src/groups.rs b/src/uu/groups/src/groups.rs index e1bf99fbc..cd0d05b07 100644 --- a/src/uu/groups/src/groups.rs +++ b/src/uu/groups/src/groups.rs @@ -50,9 +50,9 @@ impl UError for GroupsError {} impl Display for GroupsError { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { - GroupsError::GetGroupsFailed => write!(f, "failed to fetch groups"), - GroupsError::GroupNotFound(gid) => write!(f, "cannot find name for group ID {}", gid), - GroupsError::UserNotFound(user) => write!(f, "{}: no such user", user.quote()), + Self::GetGroupsFailed => write!(f, "failed to fetch groups"), + Self::GroupNotFound(gid) => write!(f, "cannot find name for group ID {}", gid), + Self::UserNotFound(user) => write!(f, "{}: no such user", user.quote()), } } } diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index fbfe1c1f2..722585033 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -473,8 +473,8 @@ impl UError for HashsumError {} impl std::fmt::Display for HashsumError { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { - HashsumError::InvalidRegex => write!(f, "invalid regular expression"), - HashsumError::InvalidFormat => Ok(()), + Self::InvalidRegex => write!(f, "invalid regular expression"), + Self::InvalidFormat => Ok(()), } } } diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index c2593f8ea..cfafb6b5b 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -58,7 +58,7 @@ impl std::error::Error for NohupError {} impl UError for NohupError { fn code(&self) -> i32 { match self { - NohupError::OpenFailed(code, _) | NohupError::OpenFailed2(code, _, _, _) => *code, + Self::OpenFailed(code, _) | Self::OpenFailed2(code, _, _, _) => *code, _ => 2, } } @@ -67,9 +67,9 @@ impl UError for NohupError { impl Display for NohupError { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { match self { - NohupError::CannotDetach => write!(f, "Cannot detach from console"), - NohupError::CannotReplace(s, e) => write!(f, "Cannot replace {}: {}", s, e), - NohupError::OpenFailed(_, e) => { + Self::CannotDetach => write!(f, "Cannot detach from console"), + Self::CannotReplace(s, e) => write!(f, "Cannot replace {}: {}", s, e), + Self::OpenFailed(_, e) => { write!(f, "failed to open {}: {}", NOHUP_OUT.quote(), e) } NohupError::OpenFailed2(_, e1, s, e2) => write!( diff --git a/src/uu/numfmt/src/options.rs b/src/uu/numfmt/src/options.rs index bd76b18b8..f61d4c704 100644 --- a/src/uu/numfmt/src/options.rs +++ b/src/uu/numfmt/src/options.rs @@ -42,23 +42,23 @@ pub enum RoundMethod { impl RoundMethod { pub fn round(&self, f: f64) -> f64 { match self { - RoundMethod::Up => f.ceil(), - RoundMethod::Down => f.floor(), - RoundMethod::FromZero => { + Self::Up => f.ceil(), + Self::Down => f.floor(), + Self::FromZero => { if f < 0.0 { f.floor() } else { f.ceil() } } - RoundMethod::TowardsZero => { + Self::TowardsZero => { if f < 0.0 { f.ceil() } else { f.floor() } } - RoundMethod::Nearest => f.round(), + Self::Nearest => f.round(), } } } diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index 9c3aee133..86a123530 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -174,11 +174,11 @@ impl UError for PtxError {} impl Display for PtxError { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { match self { - PtxError::DumbFormat => { + Self::DumbFormat => { write!(f, "There is no dumb format with GNU extensions disabled") } - PtxError::NotImplemented(s) => write!(f, "{} not implemented yet", s), - PtxError::ParseError(e) => e.fmt(f), + Self::NotImplemented(s) => write!(f, "{} not implemented yet", s), + Self::ParseError(e) => e.fmt(f), } } } diff --git a/src/uu/seq/src/extendedbigdecimal.rs b/src/uu/seq/src/extendedbigdecimal.rs index 77d7fa423..253fadfd5 100644 --- a/src/uu/seq/src/extendedbigdecimal.rs +++ b/src/uu/seq/src/extendedbigdecimal.rs @@ -92,7 +92,7 @@ impl ExtendedBigDecimal { /// The smallest integer greater than or equal to this number. pub fn ceil(self) -> ExtendedBigInt { match self { - ExtendedBigDecimal::BigDecimal(x) => ExtendedBigInt::BigInt(ceil(x)), + Self::BigDecimal(x) => ExtendedBigInt::BigInt(ceil(x)), other => From::from(other), } } @@ -100,7 +100,7 @@ impl ExtendedBigDecimal { /// The largest integer less than or equal to this number. pub fn floor(self) -> ExtendedBigInt { match self { - ExtendedBigDecimal::BigDecimal(x) => ExtendedBigInt::BigInt(floor(x)), + Self::BigDecimal(x) => ExtendedBigInt::BigInt(floor(x)), other => From::from(other), } } @@ -121,17 +121,17 @@ impl From for ExtendedBigDecimal { impl Display for ExtendedBigDecimal { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - ExtendedBigDecimal::BigDecimal(x) => { + Self::BigDecimal(x) => { let (n, p) = x.as_bigint_and_exponent(); match p { 0 => Self::BigDecimal(BigDecimal::new(n * 10, 1)).fmt(f), _ => x.fmt(f), } } - ExtendedBigDecimal::Infinity => f32::INFINITY.fmt(f), - ExtendedBigDecimal::MinusInfinity => f32::NEG_INFINITY.fmt(f), - ExtendedBigDecimal::MinusZero => (-0.0f32).fmt(f), - ExtendedBigDecimal::Nan => "nan".fmt(f), + Self::Infinity => f32::INFINITY.fmt(f), + Self::MinusInfinity => f32::NEG_INFINITY.fmt(f), + Self::MinusZero => (-0.0f32).fmt(f), + Self::Nan => "nan".fmt(f), } } } diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index b5b03454d..a1aa92a2b 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -181,7 +181,7 @@ impl UError for SortError { impl Display for SortError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - SortError::Disorder { + Self::Disorder { file, line_number, line, @@ -199,7 +199,7 @@ impl Display for SortError { Ok(()) } } - SortError::OpenFailed { path, error } => { + Self::OpenFailed { path, error } => { write!( f, "open failed: {}: {}", @@ -207,10 +207,10 @@ impl Display for SortError { strip_errno(error) ) } - SortError::ParseKeyError { key, msg } => { + Self::ParseKeyError { key, msg } => { write!(f, "failed to parse key {}: {}", key.quote(), msg) } - SortError::ReadFailed { path, error } => { + Self::ReadFailed { path, error } => { write!( f, "cannot read: {}: {}", @@ -218,17 +218,17 @@ impl Display for SortError { strip_errno(error) ) } - SortError::OpenTmpFileFailed { error } => { + Self::OpenTmpFileFailed { error } => { write!(f, "failed to open temporary file: {}", strip_errno(error)) } - SortError::CompressProgExecutionFailed { code } => { + Self::CompressProgExecutionFailed { code } => { write!(f, "couldn't execute compress program: errno {}", code) } - SortError::CompressProgTerminatedAbnormally { prog } => { + Self::CompressProgTerminatedAbnormally { prog } => { write!(f, "{} terminated abnormally", prog.quote()) } - SortError::TmpDirCreationFailed => write!(f, "could not create temporary directory"), - SortError::Uft8Error { error } => write!(f, "{}", error), + Self::TmpDirCreationFailed => write!(f, "could not create temporary directory"), + Self::Uft8Error { error } => write!(f, "{}", error), } } } @@ -247,13 +247,13 @@ enum SortMode { impl SortMode { fn get_short_name(&self) -> Option { match self { - SortMode::Numeric => Some('n'), - SortMode::HumanNumeric => Some('h'), - SortMode::GeneralNumeric => Some('g'), - SortMode::Month => Some('M'), - SortMode::Version => Some('V'), - SortMode::Random => Some('R'), - SortMode::Default => None, + Self::Numeric => Some('n'), + Self::HumanNumeric => Some('h'), + Self::GeneralNumeric => Some('g'), + Self::Month => Some('M'), + Self::Version => Some('V'), + Self::Random => Some('R'), + Self::Default => None, } } } diff --git a/src/uu/split/src/filenames.rs b/src/uu/split/src/filenames.rs index 31742194d..6f68caeb4 100644 --- a/src/uu/split/src/filenames.rs +++ b/src/uu/split/src/filenames.rs @@ -46,9 +46,9 @@ impl SuffixType { /// The radix to use when representing the suffix string as digits. pub fn radix(&self) -> u8 { match self { - SuffixType::Alphabetic => 26, - SuffixType::Decimal => 10, - SuffixType::Hexadecimal => 16, + Self::Alphabetic => 26, + Self::Decimal => 10, + Self::Hexadecimal => 16, } } } diff --git a/src/uu/tr/src/operation.rs b/src/uu/tr/src/operation.rs index afb9a1881..2c88758c5 100644 --- a/src/uu/tr/src/operation.rs +++ b/src/uu/tr/src/operation.rs @@ -37,20 +37,20 @@ pub enum BadSequence { impl Display for BadSequence { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - BadSequence::MissingCharClassName => writeln!(f, "missing character class name '[::]'"), - BadSequence::MissingEquivalentClassChar => { + Self::MissingCharClassName => writeln!(f, "missing character class name '[::]'"), + Self::MissingEquivalentClassChar => { writeln!(f, "missing equivalence class character '[==]'") } - BadSequence::MultipleCharRepeatInSet2 => { + Self::MultipleCharRepeatInSet2 => { writeln!(f, "only one [c*] repeat construct may appear in string2") } - BadSequence::CharRepeatInSet1 => { + Self::CharRepeatInSet1 => { writeln!(f, "the [c*] repeat construct may not appear in string1") } - BadSequence::InvalidRepeatCount(count) => { + Self::InvalidRepeatCount(count) => { writeln!(f, "invalid repeat count '{}' in [c*n] construct", count) } - BadSequence::EmptySet2WhenNotTruncatingSet1 => { + Self::EmptySet2WhenNotTruncatingSet1 => { writeln!(f, "when not truncating set1, string2 must be non-empty") } } @@ -83,20 +83,20 @@ pub enum Sequence { impl Sequence { pub fn flatten(&self) -> Box> { match self { - Sequence::Char(c) => Box::new(std::iter::once(*c)), - Sequence::CharRange(l, r) => Box::new((*l..=*r).flat_map(std::char::from_u32)), - Sequence::CharStar(c) => Box::new(std::iter::repeat(*c)), - Sequence::CharRepeat(c, n) => Box::new(std::iter::repeat(*c).take(*n)), - Sequence::Alnum => Box::new(('0'..='9').chain('A'..='Z').chain('a'..='z')), - Sequence::Alpha => Box::new(('A'..='Z').chain('a'..='z')), - Sequence::Blank => Box::new(unicode_table::BLANK.iter().cloned()), - Sequence::Control => Box::new( + Self::Char(c) => Box::new(std::iter::once(*c)), + Self::CharRange(l, r) => Box::new((*l..=*r).flat_map(std::char::from_u32)), + Self::CharStar(c) => Box::new(std::iter::repeat(*c)), + Self::CharRepeat(c, n) => Box::new(std::iter::repeat(*c).take(*n)), + Self::Alnum => Box::new(('0'..='9').chain('A'..='Z').chain('a'..='z')), + Self::Alpha => Box::new(('A'..='Z').chain('a'..='z')), + Self::Blank => Box::new(unicode_table::BLANK.iter().cloned()), + Self::Control => Box::new( (0..=31) .chain(std::iter::once(127)) .flat_map(std::char::from_u32), ), - Sequence::Digit => Box::new('0'..='9'), - Sequence::Graph => Box::new( + Self::Digit => Box::new('0'..='9'), + Self::Graph => Box::new( (48..=57) // digit .chain(65..=90) // uppercase .chain(97..=122) // lowercase @@ -108,8 +108,8 @@ impl Sequence { .chain(std::iter::once(32)) // space .flat_map(std::char::from_u32), ), - Sequence::Lower => Box::new('a'..='z'), - Sequence::Print => Box::new( + Self::Lower => Box::new('a'..='z'), + Self::Print => Box::new( (48..=57) // digit .chain(65..=90) // uppercase .chain(97..=122) // lowercase @@ -120,16 +120,16 @@ impl Sequence { .chain(123..=126) .flat_map(std::char::from_u32), ), - Sequence::Punct => Box::new( + Self::Punct => Box::new( (33..=47) .chain(58..=64) .chain(91..=96) .chain(123..=126) .flat_map(std::char::from_u32), ), - Sequence::Space => Box::new(unicode_table::SPACES.iter().cloned()), - Sequence::Upper => Box::new('A'..='Z'), - Sequence::Xdigit => Box::new(('0'..='9').chain('A'..='F').chain('a'..='f')), + Self::Space => Box::new(unicode_table::SPACES.iter().cloned()), + Self::Upper => Box::new('A'..='Z'), + Self::Xdigit => Box::new(('0'..='9').chain('A'..='F').chain('a'..='f')), } } diff --git a/src/uucore/src/lib/mods/error.rs b/src/uucore/src/lib/mods/error.rs index 15d53233e..dbe4d5bc1 100644 --- a/src/uucore/src/lib/mods/error.rs +++ b/src/uucore/src/lib/mods/error.rs @@ -620,7 +620,7 @@ impl From for Box { /// Implementations for clap::Error impl UError for clap::Error { fn code(&self) -> i32 { - match self.kind { + match self.kind() { clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => 0, _ => 1, } From 33c49666c35171afcd9158446b4aa762f58ea1dd Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 23 Mar 2022 12:12:54 +0100 Subject: [PATCH 38/38] nproc: make tests/misc/nproc-override.sh pass by implementing OMP_NUM_THREADS=X,Y,Z (#3296) + nproc tests: use assert_eq when comparing the two values Co-authored-by: jfinkels --- src/uu/nproc/src/nproc.rs | 21 +++++++++- tests/by-util/test_nproc.rs | 80 ++++++++++++++++++++++++++++++++----- 2 files changed, 89 insertions(+), 12 deletions(-) diff --git a/src/uu/nproc/src/nproc.rs b/src/uu/nproc/src/nproc.rs index 2615e0c66..87fe9a4e7 100644 --- a/src/uu/nproc/src/nproc.rs +++ b/src/uu/nproc/src/nproc.rs @@ -50,7 +50,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let limit = match env::var("OMP_THREAD_LIMIT") { // Uses the OpenMP variable to limit the number of threads // If the parsing fails, returns the max size (so, no impact) - Ok(threadstr) => threadstr.parse().unwrap_or(usize::MAX), + // If OMP_THREAD_LIMIT=0, rejects the value + Ok(threadstr) => match threadstr.parse() { + Ok(0) | Err(_) => usize::MAX, + Ok(n) => n, + }, // the variable 'OMP_THREAD_LIMIT' doesn't exist // fallback to the max Err(_) => usize::MAX, @@ -63,12 +67,25 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { match env::var("OMP_NUM_THREADS") { // Uses the OpenMP variable to force the number of threads // If the parsing fails, returns the number of CPU - Ok(threadstr) => threadstr.parse().unwrap_or_else(|_| num_cpus::get()), + Ok(threadstr) => { + // In some cases, OMP_NUM_THREADS can be "x,y,z" + // In this case, only take the first one (like GNU) + // If OMP_NUM_THREADS=0, rejects the value + let thread: Vec<&str> = threadstr.split_terminator(',').collect(); + match &thread[..] { + [] => num_cpus::get(), + [s, ..] => match s.parse() { + Ok(0) | Err(_) => num_cpus::get(), + Ok(n) => n, + }, + } + } // the variable 'OMP_NUM_THREADS' doesn't exist // fallback to the regular CPU detection Err(_) => num_cpus::get(), } }; + cores = std::cmp::min(limit, cores); if cores <= ignore { cores = 1; diff --git a/tests/by-util/test_nproc.rs b/tests/by-util/test_nproc.rs index 6d3fb1fd0..330f327cb 100644 --- a/tests/by-util/test_nproc.rs +++ b/tests/by-util/test_nproc.rs @@ -20,7 +20,7 @@ fn test_nproc_all_omp() { .succeeds(); let nproc_omp: u8 = result.stdout_str().trim().parse().unwrap(); - assert!(nproc_omp == 60); + assert_eq!(nproc_omp, 60); let result = TestScenario::new(util_name!()) .ucmd_keepenv() @@ -28,7 +28,7 @@ fn test_nproc_all_omp() { .arg("--all") .succeeds(); let nproc_omp: u8 = result.stdout_str().trim().parse().unwrap(); - assert!(nproc == nproc_omp); + assert_eq!(nproc, nproc_omp); // If the parsing fails, returns the number of CPU let result = TestScenario::new(util_name!()) @@ -36,7 +36,7 @@ fn test_nproc_all_omp() { .env("OMP_NUM_THREADS", "incorrectnumber") // returns the number CPU .succeeds(); let nproc_omp: u8 = result.stdout_str().trim().parse().unwrap(); - assert!(nproc == nproc_omp); + assert_eq!(nproc, nproc_omp); } #[test] @@ -51,14 +51,14 @@ fn test_nproc_ignore() { .arg((nproc_total - 1).to_string()) .succeeds(); let nproc: u8 = result.stdout_str().trim().parse().unwrap(); - assert!(nproc == 1); + assert_eq!(nproc, 1); // Ignore all CPU but one with a string let result = TestScenario::new(util_name!()) .ucmd_keepenv() .arg("--ignore= 1") .succeeds(); let nproc: u8 = result.stdout_str().trim().parse().unwrap(); - assert!(nproc_total - 1 == nproc); + assert_eq!(nproc_total - 1, nproc); } } @@ -70,7 +70,7 @@ fn test_nproc_ignore_all_omp() { .arg("--ignore=40") .succeeds(); let nproc: u8 = result.stdout_str().trim().parse().unwrap(); - assert!(nproc == 2); + assert_eq!(nproc, 2); } #[test] @@ -81,7 +81,7 @@ fn test_nproc_omp_limit() { .env("OMP_THREAD_LIMIT", "0") .succeeds(); let nproc: u8 = result.stdout_str().trim().parse().unwrap(); - assert!(nproc == 1); + assert_eq!(nproc, 42); let result = TestScenario::new(util_name!()) .ucmd_keepenv() @@ -89,7 +89,7 @@ fn test_nproc_omp_limit() { .env("OMP_THREAD_LIMIT", "2") .succeeds(); let nproc: u8 = result.stdout_str().trim().parse().unwrap(); - assert!(nproc == 2); + assert_eq!(nproc, 2); let result = TestScenario::new(util_name!()) .ucmd_keepenv() @@ -97,12 +97,72 @@ fn test_nproc_omp_limit() { .env("OMP_THREAD_LIMIT", "2bad") .succeeds(); let nproc: u8 = result.stdout_str().trim().parse().unwrap(); - assert!(nproc == 42); + assert_eq!(nproc, 42); + + let result = new_ucmd!().arg("--all").succeeds(); + let nproc_system: u8 = result.stdout_str().trim().parse().unwrap(); + assert!(nproc_system > 0); let result = TestScenario::new(util_name!()) .ucmd_keepenv() .env("OMP_THREAD_LIMIT", "1") .succeeds(); let nproc: u8 = result.stdout_str().trim().parse().unwrap(); - assert!(nproc == 1); + assert_eq!(nproc, 1); + + let result = TestScenario::new(util_name!()) + .ucmd_keepenv() + .env("OMP_NUM_THREADS", "0") + .env("OMP_THREAD_LIMIT", "") + .succeeds(); + let nproc: u8 = result.stdout_str().trim().parse().unwrap(); + assert_eq!(nproc, nproc_system); + + let result = TestScenario::new(util_name!()) + .ucmd_keepenv() + .env("OMP_NUM_THREADS", "") + .env("OMP_THREAD_LIMIT", "") + .succeeds(); + let nproc: u8 = result.stdout_str().trim().parse().unwrap(); + assert_eq!(nproc, nproc_system); + + let result = TestScenario::new(util_name!()) + .ucmd_keepenv() + .env("OMP_NUM_THREADS", "2,2,1") + .env("OMP_THREAD_LIMIT", "") + .succeeds(); + let nproc: u8 = result.stdout_str().trim().parse().unwrap(); + assert_eq!(2, nproc); + + let result = TestScenario::new(util_name!()) + .ucmd_keepenv() + .env("OMP_NUM_THREADS", "2,ignored") + .env("OMP_THREAD_LIMIT", "") + .succeeds(); + let nproc: u8 = result.stdout_str().trim().parse().unwrap(); + assert_eq!(2, nproc); + + let result = TestScenario::new(util_name!()) + .ucmd_keepenv() + .env("OMP_NUM_THREADS", "2,2,1") + .env("OMP_THREAD_LIMIT", "0") + .succeeds(); + let nproc: u8 = result.stdout_str().trim().parse().unwrap(); + assert_eq!(2, nproc); + + let result = TestScenario::new(util_name!()) + .ucmd_keepenv() + .env("OMP_NUM_THREADS", "2,2,1") + .env("OMP_THREAD_LIMIT", "1bad") + .succeeds(); + let nproc: u8 = result.stdout_str().trim().parse().unwrap(); + assert_eq!(2, nproc); + + let result = TestScenario::new(util_name!()) + .ucmd_keepenv() + .env("OMP_NUM_THREADS", "29,2,1") + .env("OMP_THREAD_LIMIT", "1bad") + .succeeds(); + let nproc: u8 = result.stdout_str().trim().parse().unwrap(); + assert_eq!(29, nproc); }