From 233a7789634aa0c5f4fb2fc69e01411ed23e42c7 Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Sun, 27 Jun 2021 12:52:46 +0200 Subject: [PATCH 1/3] sort/ls: implement version cmp matching GNU spec This reimplements version_cmp, which is used in sort and ls to sort according to versions. However, it is not bug-for-bug identical with GNU's implementation. I reported a bug with GNU here: https://lists.gnu.org/archive/html/bug-coreutils/2021-06/msg00045.html This implementation does not contain the bugs regarding the handling of file extensions and null bytes. --- Cargo.lock | 16 - src/uu/ls/src/ls.rs | 7 +- src/uu/ls/src/version_cmp.rs | 306 --------------- src/uu/sort/Cargo.toml | 1 - src/uu/sort/src/sort.rs | 31 +- src/uucore/src/lib/lib.rs | 1 + src/uucore/src/lib/mods.rs | 1 + src/uucore/src/lib/mods/version_cmp.rs | 361 ++++++++++++++++++ tests/by-util/test_sort.rs | 6 +- .../sort/version-empty-lines.expected | 4 + .../sort/version-empty-lines.expected.debug | 45 +++ tests/fixtures/sort/version-empty-lines.txt | 4 + 12 files changed, 423 insertions(+), 360 deletions(-) delete mode 100644 src/uu/ls/src/version_cmp.rs create mode 100644 src/uucore/src/lib/mods/version_cmp.rs create mode 100644 tests/fixtures/sort/version-empty-lines.expected.debug diff --git a/Cargo.lock b/Cargo.lock index 51424332d..e2dd7d5f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1434,21 +1434,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "sha1" version = "0.6.0" @@ -2488,7 +2473,6 @@ dependencies = [ "ouroboros", "rand 0.7.3", "rayon", - "semver", "tempfile", "unicode-width", "uucore", diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 6ca3f4bbe..b866253a9 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -14,7 +14,6 @@ extern crate uucore; extern crate lazy_static; mod quoting_style; -mod version_cmp; use clap::{crate_version, App, Arg}; use globset::{self, Glob, GlobSet, GlobSetBuilder}; @@ -44,6 +43,7 @@ use term_grid::{Cell, Direction, Filling, Grid, GridOptions}; use unicode_width::UnicodeWidthStr; #[cfg(unix)] use uucore::libc::{S_IXGRP, S_IXOTH, S_IXUSR}; +use uucore::{fs::display_permissions, version_cmp::version_cmp}; static ABOUT: &str = " By default, ls will list the files and contents of any directories on @@ -1256,7 +1256,8 @@ fn sort_entries(entries: &mut Vec, config: &Config) { } // The default sort in GNU ls is case insensitive Sort::Name => entries.sort_by(|a, b| a.display_name.cmp(&b.display_name)), - Sort::Version => entries.sort_by(|a, b| version_cmp::version_cmp(&a.p_buf, &b.p_buf)), + Sort::Version => entries + .sort_by(|a, b| version_cmp(&a.p_buf.to_string_lossy(), &b.p_buf.to_string_lossy())), Sort::Extension => entries.sort_by(|a, b| { a.p_buf .extension() @@ -1467,8 +1468,6 @@ fn display_grid( } } -use uucore::fs::display_permissions; - fn display_item_long( item: &PathData, max_links: usize, diff --git a/src/uu/ls/src/version_cmp.rs b/src/uu/ls/src/version_cmp.rs deleted file mode 100644 index e3f7e29e3..000000000 --- a/src/uu/ls/src/version_cmp.rs +++ /dev/null @@ -1,306 +0,0 @@ -use std::cmp::Ordering; -use std::path::Path; - -/// Compare paths in a way that matches the GNU version sort, meaning that -/// numbers get sorted in a natural way. -pub(crate) fn version_cmp(a: &Path, b: &Path) -> Ordering { - let a_string = a.to_string_lossy(); - let b_string = b.to_string_lossy(); - let mut a = a_string.chars().peekable(); - let mut b = b_string.chars().peekable(); - - // The order determined from the number of leading zeroes. - // This is used if the filenames are equivalent up to leading zeroes. - let mut leading_zeroes = Ordering::Equal; - - loop { - match (a.next(), b.next()) { - // If the characters are both numerical. We collect the rest of the number - // and parse them to u64's and compare them. - (Some(a_char @ '0'..='9'), Some(b_char @ '0'..='9')) => { - let mut a_leading_zeroes = 0; - if a_char == '0' { - a_leading_zeroes = 1; - while let Some('0') = a.peek() { - a_leading_zeroes += 1; - a.next(); - } - } - - let mut b_leading_zeroes = 0; - if b_char == '0' { - b_leading_zeroes = 1; - while let Some('0') = b.peek() { - b_leading_zeroes += 1; - b.next(); - } - } - // The first different number of leading zeros determines the order - // so if it's already been determined by a previous number, we leave - // it as that ordering. - // It's b.cmp(&a), because the *largest* number of leading zeros - // should go first - if leading_zeroes == Ordering::Equal { - leading_zeroes = b_leading_zeroes.cmp(&a_leading_zeroes); - } - - let mut a_str = String::new(); - let mut b_str = String::new(); - if a_char != '0' { - a_str.push(a_char); - } - if b_char != '0' { - b_str.push(b_char); - } - - // Unwrapping here is fine because we only call next if peek returns - // Some(_), so next should also return Some(_). - while let Some('0'..='9') = a.peek() { - a_str.push(a.next().unwrap()); - } - - while let Some('0'..='9') = b.peek() { - b_str.push(b.next().unwrap()); - } - - // Since the leading zeroes are stripped, the length can be - // used to compare the numbers. - match a_str.len().cmp(&b_str.len()) { - Ordering::Equal => {} - x => return x, - } - - // At this point, leading zeroes are stripped and the lengths - // are equal, meaning that the strings can be compared using - // the standard compare function. - match a_str.cmp(&b_str) { - Ordering::Equal => {} - x => return x, - } - } - // If there are two characters we just compare the characters - (Some(a_char), Some(b_char)) => match a_char.cmp(&b_char) { - Ordering::Equal => {} - x => return x, - }, - // Otherwise, we compare the options (because None < Some(_)) - (a_opt, b_opt) => match a_opt.cmp(&b_opt) { - // If they are completely equal except for leading zeroes, we use the leading zeroes. - Ordering::Equal => return leading_zeroes, - x => return x, - }, - } - } -} - -#[cfg(test)] -mod tests { - use crate::version_cmp::version_cmp; - use std::cmp::Ordering; - use std::path::PathBuf; - #[test] - fn test_version_cmp() { - // Identical strings - assert_eq!( - version_cmp(&PathBuf::from("hello"), &PathBuf::from("hello")), - Ordering::Equal - ); - - assert_eq!( - version_cmp(&PathBuf::from("file12"), &PathBuf::from("file12")), - Ordering::Equal - ); - - assert_eq!( - version_cmp( - &PathBuf::from("file12-suffix"), - &PathBuf::from("file12-suffix") - ), - Ordering::Equal - ); - - assert_eq!( - version_cmp( - &PathBuf::from("file12-suffix24"), - &PathBuf::from("file12-suffix24") - ), - Ordering::Equal - ); - - // Shortened names - assert_eq!( - version_cmp(&PathBuf::from("world"), &PathBuf::from("wo")), - Ordering::Greater, - ); - - assert_eq!( - version_cmp(&PathBuf::from("hello10wo"), &PathBuf::from("hello10world")), - Ordering::Less, - ); - - // Simple names - assert_eq!( - version_cmp(&PathBuf::from("world"), &PathBuf::from("hello")), - Ordering::Greater, - ); - - assert_eq!( - version_cmp(&PathBuf::from("hello"), &PathBuf::from("world")), - Ordering::Less - ); - - assert_eq!( - version_cmp(&PathBuf::from("apple"), &PathBuf::from("ant")), - Ordering::Greater - ); - - assert_eq!( - version_cmp(&PathBuf::from("ant"), &PathBuf::from("apple")), - Ordering::Less - ); - - // Uppercase letters - assert_eq!( - version_cmp(&PathBuf::from("Beef"), &PathBuf::from("apple")), - Ordering::Less, - "Uppercase letters are sorted before all lowercase letters" - ); - - assert_eq!( - version_cmp(&PathBuf::from("Apple"), &PathBuf::from("apple")), - Ordering::Less - ); - - assert_eq!( - version_cmp(&PathBuf::from("apple"), &PathBuf::from("aPple")), - Ordering::Greater - ); - - // Numbers - assert_eq!( - version_cmp(&PathBuf::from("100"), &PathBuf::from("20")), - Ordering::Greater, - "Greater numbers are greater even if they start with a smaller digit", - ); - - assert_eq!( - version_cmp(&PathBuf::from("20"), &PathBuf::from("20")), - Ordering::Equal, - "Equal numbers are equal" - ); - - assert_eq!( - version_cmp(&PathBuf::from("15"), &PathBuf::from("200")), - Ordering::Less, - "Small numbers are smaller" - ); - - // Comparing numbers with other characters - assert_eq!( - version_cmp(&PathBuf::from("1000"), &PathBuf::from("apple")), - Ordering::Less, - "Numbers are sorted before other characters" - ); - - assert_eq!( - // spell-checker:disable-next-line - version_cmp(&PathBuf::from("file1000"), &PathBuf::from("fileapple")), - Ordering::Less, - "Numbers in the middle of the name are sorted before other characters" - ); - - // Leading zeroes - assert_eq!( - version_cmp(&PathBuf::from("012"), &PathBuf::from("12")), - Ordering::Less, - "A single leading zero can make a difference" - ); - - assert_eq!( - version_cmp(&PathBuf::from("000800"), &PathBuf::from("0000800")), - Ordering::Greater, - "Leading number of zeroes is used even if both non-zero number of zeros" - ); - - // Numbers and other characters combined - assert_eq!( - version_cmp(&PathBuf::from("ab10"), &PathBuf::from("aa11")), - Ordering::Greater - ); - - assert_eq!( - version_cmp(&PathBuf::from("aa10"), &PathBuf::from("aa11")), - Ordering::Less, - "Numbers after other characters are handled correctly." - ); - - assert_eq!( - version_cmp(&PathBuf::from("aa2"), &PathBuf::from("aa100")), - Ordering::Less, - "Numbers after alphabetical characters are handled correctly." - ); - - assert_eq!( - version_cmp(&PathBuf::from("aa10bb"), &PathBuf::from("aa11aa")), - Ordering::Less, - "Number is used even if alphabetical characters after it differ." - ); - - assert_eq!( - version_cmp(&PathBuf::from("aa10aa0010"), &PathBuf::from("aa11aa1")), - Ordering::Less, - "Second number is ignored if the first number differs." - ); - - assert_eq!( - version_cmp(&PathBuf::from("aa10aa0010"), &PathBuf::from("aa10aa1")), - Ordering::Greater, - "Second number is used if the rest is equal." - ); - - assert_eq!( - version_cmp(&PathBuf::from("aa10aa0010"), &PathBuf::from("aa00010aa1")), - Ordering::Greater, - "Second number is used if the rest is equal up to leading zeroes of the first number." - ); - - assert_eq!( - version_cmp(&PathBuf::from("aa10aa0022"), &PathBuf::from("aa010aa022")), - Ordering::Greater, - "The leading zeroes of the first number has priority." - ); - - assert_eq!( - version_cmp(&PathBuf::from("aa10aa0022"), &PathBuf::from("aa10aa022")), - Ordering::Less, - "The leading zeroes of other numbers than the first are used." - ); - - assert_eq!( - version_cmp(&PathBuf::from("file-1.4"), &PathBuf::from("file-1.13")), - Ordering::Less, - "Periods are handled as normal text, not as a decimal point." - ); - - // Greater than u64::Max - // u64 == 18446744073709551615 so this should be plenty: - // 20000000000000000000000 - assert_eq!( - version_cmp( - &PathBuf::from("aa2000000000000000000000bb"), - &PathBuf::from("aa002000000000000000000001bb") - ), - Ordering::Less, - "Numbers larger than u64::MAX are handled correctly without crashing" - ); - - assert_eq!( - version_cmp( - &PathBuf::from("aa2000000000000000000000bb"), - &PathBuf::from("aa002000000000000000000000bb") - ), - Ordering::Greater, - "Leading zeroes for numbers larger than u64::MAX are handled correctly without crashing" - ); - } -} diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index f06610248..d454179b0 100644 --- a/src/uu/sort/Cargo.toml +++ b/src/uu/sort/Cargo.toml @@ -24,7 +24,6 @@ memchr = "2.4.0" ouroboros = "0.9.3" rand = "0.7" rayon = "1.5" -semver = "0.9.0" tempfile = "3" unicode-width = "0.1.8" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index fb0241945..821def70d 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -32,7 +32,6 @@ use numeric_str_cmp::{human_numeric_str_cmp, numeric_str_cmp, NumInfo, NumInfoPa use rand::distributions::Alphanumeric; use rand::{thread_rng, Rng}; use rayon::prelude::*; -use semver::Version; use std::cmp::Ordering; use std::env; use std::ffi::OsStr; @@ -44,6 +43,7 @@ use std::path::Path; use std::path::PathBuf; use unicode_width::UnicodeWidthStr; use uucore::parse_size::{parse_size, ParseSizeError}; +use uucore::version_cmp::version_cmp; use uucore::InvalidEncodingHandling; const NAME: &str = "sort"; @@ -1410,7 +1410,7 @@ fn compare_by<'a>( general_numeric_compare(a_float, b_float) } SortMode::Month => month_compare(a_str, b_str), - SortMode::Version => version_compare(a_str, b_str), + SortMode::Version => version_cmp(a_str, b_str), SortMode::Default => custom_str_cmp( a_str, b_str, @@ -1615,31 +1615,6 @@ fn month_compare(a: &str, b: &str) -> Ordering { } } -fn version_parse(a: &str) -> Version { - let result = Version::parse(a); - - match result { - Ok(vers_a) => vers_a, - // Non-version lines parse to 0.0.0 - Err(_e) => Version::parse("0.0.0").unwrap(), - } -} - -fn version_compare(a: &str, b: &str) -> Ordering { - #![allow(clippy::comparison_chain)] - let ver_a = version_parse(a); - let ver_b = version_parse(b); - - // Version::cmp is not implemented; implement comparison directly - if ver_a > ver_b { - Ordering::Greater - } else if ver_a < ver_b { - Ordering::Less - } else { - Ordering::Equal - } -} - fn print_sorted<'a, T: Iterator>>(iter: T, settings: &GlobalSettings) { let mut writer = settings.out_writer(); for line in iter { @@ -1712,7 +1687,7 @@ mod tests { let a = "1.2.3-alpha2"; let b = "1.4.0"; - assert_eq!(Ordering::Less, version_compare(a, b)); + assert_eq!(Ordering::Less, version_cmp(a, b)); } #[test] diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index bf2e5b1bb..ac505e42f 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -30,6 +30,7 @@ pub use crate::mods::coreopts; pub use crate::mods::os; pub use crate::mods::panic; pub use crate::mods::ranges; +pub use crate::mods::version_cmp; // * string parsing modules pub use crate::parser::parse_size; diff --git a/src/uucore/src/lib/mods.rs b/src/uucore/src/lib/mods.rs index 2689361a0..f81d05ed9 100644 --- a/src/uucore/src/lib/mods.rs +++ b/src/uucore/src/lib/mods.rs @@ -5,3 +5,4 @@ pub mod coreopts; pub mod os; pub mod panic; pub mod ranges; +pub mod version_cmp; diff --git a/src/uucore/src/lib/mods/version_cmp.rs b/src/uucore/src/lib/mods/version_cmp.rs new file mode 100644 index 000000000..99b8c8b40 --- /dev/null +++ b/src/uucore/src/lib/mods/version_cmp.rs @@ -0,0 +1,361 @@ +use std::cmp::Ordering; + +/// Compares the non-digit parts of a version. +/// Special cases: ~ are before everything else, even ends ("a~" < "a") +/// Letters are before non-letters +fn version_non_digit_cmp(a: &str, b: &str) -> Ordering { + let mut a_chars = a.chars(); + let mut b_chars = b.chars(); + loop { + match (a_chars.next(), b_chars.next()) { + (Some(c1), Some(c2)) if c1 == c2 => {} + (None, None) => return Ordering::Equal, + (_, Some('~')) => return Ordering::Greater, + (Some('~'), _) => return Ordering::Less, + (None, Some(_)) => return Ordering::Less, + (Some(_), None) => return Ordering::Greater, + (Some(c1), Some(c2)) if c1.is_ascii_alphabetic() && !c2.is_ascii_alphabetic() => { + return Ordering::Less + } + (Some(c1), Some(c2)) if !c1.is_ascii_alphabetic() && c2.is_ascii_alphabetic() => { + return Ordering::Greater + } + (Some(c1), Some(c2)) => return c1.cmp(&c2), + } + } +} + +/// Remove file endings matching the regex (\.[A-Za-z~][A-Za-z0-9~]*)*$ +fn remove_file_ending(a: &str) -> &str { + let mut ending_start = None; + let mut prev_was_dot = false; + for (idx, char) in a.char_indices() { + if char == '.' { + if ending_start.is_none() || prev_was_dot { + ending_start = Some(idx); + } + prev_was_dot = true; + } else if prev_was_dot { + prev_was_dot = false; + if !char.is_ascii_alphabetic() && char != '~' { + ending_start = None; + } + } else if !char.is_ascii_alphanumeric() && char != '~' { + ending_start = None; + } + } + if prev_was_dot { + ending_start = None; + } + if let Some(ending_start) = ending_start { + &a[..ending_start] + } else { + a + } +} + +pub fn version_cmp(mut a: &str, mut b: &str) -> Ordering { + let str_cmp = a.cmp(b); + if str_cmp == Ordering::Equal { + return str_cmp; + } + + // Special cases: + // 1. Empty strings + match (a.is_empty(), b.is_empty()) { + (true, false) => return Ordering::Less, + (false, true) => return Ordering::Greater, + (true, true) => unreachable!(), + (false, false) => {} + } + // 2. Dots + match (a == ".", b == ".") { + (true, false) => return Ordering::Less, + (false, true) => return Ordering::Greater, + (true, true) => unreachable!(), + (false, false) => {} + } + // 3. Two Dots + match (a == "..", b == "..") { + (true, false) => return Ordering::Less, + (false, true) => return Ordering::Greater, + (true, true) => unreachable!(), + (false, false) => {} + } + // 4. Strings starting with a dot + match (a.starts_with('.'), b.starts_with('.')) { + (true, false) => return Ordering::Less, + (false, true) => return Ordering::Greater, + (true, true) => { + // Strip the leading dot for later comparisons + a = &a[1..]; + b = &b[1..]; + } + _ => {} + } + + // Try to strip file extensions + let (mut a, mut b) = match (remove_file_ending(a), remove_file_ending(b)) { + (a_stripped, b_stripped) if a_stripped == b_stripped => { + // If both would be the same after stripping file extensions, don't strip them. + (a, b) + } + stripped => stripped, + }; + + // 1. Compare leading non-numerical part + // 2. Compare leading numerical part + // 3. Repeat + loop { + let a_numerical_start = a.find(|c: char| c.is_ascii_digit()).unwrap_or(a.len()); + let b_numerical_start = b.find(|c: char| c.is_ascii_digit()).unwrap_or(b.len()); + + let a_str = &a[..a_numerical_start]; + let b_str = &b[..b_numerical_start]; + + match version_non_digit_cmp(a_str, b_str) { + Ordering::Equal => {} + ord => return ord, + } + + a = &a[a_numerical_start..]; + b = &b[a_numerical_start..]; + + let a_numerical_end = a.find(|c: char| !c.is_ascii_digit()).unwrap_or(a.len()); + let b_numerical_end = b.find(|c: char| !c.is_ascii_digit()).unwrap_or(b.len()); + + let a_str = a[..a_numerical_end].trim_start_matches('0'); + let b_str = b[..b_numerical_end].trim_start_matches('0'); + + match a_str.len().cmp(&b_str.len()) { + Ordering::Equal => {} + ord => return ord, + } + + match a_str.cmp(b_str) { + Ordering::Equal => {} + ord => return ord, + } + + a = &a[a_numerical_end..]; + b = &b[b_numerical_end..]; + + if a.is_empty() && b.is_empty() { + // Default to the lexical comparison. + return str_cmp; + } + } +} + +#[cfg(test)] +mod tests { + use crate::version_cmp::version_cmp; + use std::cmp::Ordering; + #[test] + fn test_version_cmp() { + // Identical strings + assert_eq!(version_cmp("hello", "hello"), Ordering::Equal); + + assert_eq!(version_cmp("file12", "file12"), Ordering::Equal); + + assert_eq!( + version_cmp("file12-suffix", "file12-suffix"), + Ordering::Equal + ); + + assert_eq!( + version_cmp("file12-suffix24", "file12-suffix24"), + Ordering::Equal + ); + + // Shortened names + assert_eq!(version_cmp("world", "wo"), Ordering::Greater,); + + assert_eq!(version_cmp("hello10wo", "hello10world"), Ordering::Less,); + + // Simple names + assert_eq!(version_cmp("world", "hello"), Ordering::Greater,); + + assert_eq!(version_cmp("hello", "world"), Ordering::Less); + + assert_eq!(version_cmp("apple", "ant"), Ordering::Greater); + + assert_eq!(version_cmp("ant", "apple"), Ordering::Less); + + // Uppercase letters + assert_eq!( + version_cmp("Beef", "apple"), + Ordering::Less, + "Uppercase letters are sorted before all lowercase letters" + ); + + assert_eq!(version_cmp("Apple", "apple"), Ordering::Less); + + assert_eq!(version_cmp("apple", "aPple"), Ordering::Greater); + + // Numbers + assert_eq!( + version_cmp("100", "20"), + Ordering::Greater, + "Greater numbers are greater even if they start with a smaller digit", + ); + + assert_eq!( + version_cmp("20", "20"), + Ordering::Equal, + "Equal numbers are equal" + ); + + assert_eq!( + version_cmp("15", "200"), + Ordering::Less, + "Small numbers are smaller" + ); + + // Comparing numbers with other characters + assert_eq!( + version_cmp("1000", "apple"), + Ordering::Less, + "Numbers are sorted before other characters" + ); + + assert_eq!( + // spell-checker:disable-next-line + version_cmp("file1000", "fileapple"), + Ordering::Less, + "Numbers in the middle of the name are sorted before other characters" + ); + + // Leading zeroes + assert_eq!( + version_cmp("012", "12"), + Ordering::Less, + "A single leading zero can make a difference" + ); + + assert_eq!( + version_cmp("000800", "0000800"), + Ordering::Greater, + "Leading number of zeroes is used even if both non-zero number of zeros" + ); + + // Numbers and other characters combined + assert_eq!(version_cmp("ab10", "aa11"), Ordering::Greater); + + assert_eq!( + version_cmp("aa10", "aa11"), + Ordering::Less, + "Numbers after other characters are handled correctly." + ); + + assert_eq!( + version_cmp("aa2", "aa100"), + Ordering::Less, + "Numbers after alphabetical characters are handled correctly." + ); + + assert_eq!( + version_cmp("aa10bb", "aa11aa"), + Ordering::Less, + "Number is used even if alphabetical characters after it differ." + ); + + assert_eq!( + version_cmp("aa10aa0010", "aa11aa1"), + Ordering::Less, + "Second number is ignored if the first number differs." + ); + + assert_eq!( + version_cmp("aa10aa0010", "aa10aa1"), + Ordering::Greater, + "Second number is used if the rest is equal." + ); + + assert_eq!( + version_cmp("aa10aa0010", "aa00010aa1"), + Ordering::Greater, + "Second number is used if the rest is equal up to leading zeroes of the first number." + ); + + assert_eq!( + version_cmp("aa10aa0022", "aa010aa022"), + Ordering::Greater, + "The leading zeroes of the first number has priority." + ); + + assert_eq!( + version_cmp("aa10aa0022", "aa10aa022"), + Ordering::Less, + "The leading zeroes of other numbers than the first are used." + ); + + assert_eq!( + version_cmp("file-1.4", "file-1.13"), + Ordering::Less, + "Periods are handled as normal text, not as a decimal point." + ); + + // Greater than u64::Max + // u64 == 18446744073709551615 so this should be plenty: + // 20000000000000000000000 + assert_eq!( + version_cmp("aa2000000000000000000000bb", "aa002000000000000000000001bb"), + Ordering::Less, + "Numbers larger than u64::MAX are handled correctly without crashing" + ); + + assert_eq!( + version_cmp("aa2000000000000000000000bb", "aa002000000000000000000000bb"), + Ordering::Greater, + "Leading zeroes for numbers larger than u64::MAX are \ + handled correctly without crashing" + ); + + assert_eq!( + version_cmp(" a", "a"), + Ordering::Greater, + "Whitespace is after letters because letters are before non-letters" + ); + + assert_eq!( + version_cmp("a~", "ab"), + Ordering::Less, + "A tilde is before other letters" + ); + + assert_eq!( + version_cmp("a~", "a"), + Ordering::Less, + "A tilde is before the line end" + ); + assert_eq!( + version_cmp("~", ""), + Ordering::Greater, + "A tilde is after the empty string" + ); + assert_eq!( + version_cmp(".f", ".1"), + Ordering::Greater, + "if both start with a dot it is ignored for the comparison" + ); + + // The following tests are incompatible with GNU as of 2021/06. + // I think that's because of a bug in GNU, reported as https://lists.gnu.org/archive/html/bug-coreutils/2021-06/msg00045.html + assert_eq!( + version_cmp("a..a", "a.+"), + Ordering::Less, + ".a is stripped before the comparison" + ); + assert_eq!( + version_cmp("a.", "a+"), + Ordering::Greater, + ". is not stripped before the comparison" + ); + assert_eq!( + version_cmp("a\0a", "a"), + Ordering::Greater, + "NULL bytes are handled comparison" + ); + } +} diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index 3e841f630..2c99c1536 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -127,11 +127,7 @@ fn test_months_whitespace() { #[test] fn test_version_empty_lines() { - new_ucmd!() - .arg("-V") - .arg("version-empty-lines.txt") - .succeeds() - .stdout_is("\n\n\n\n\n\n\n1.2.3-alpha\n1.2.3-alpha2\n\t\t\t1.12.4\n11.2.3\n"); + test_helper("version-empty-lines", &["-V", "--version-sort"]); } #[test] diff --git a/tests/fixtures/sort/version-empty-lines.expected b/tests/fixtures/sort/version-empty-lines.expected index c496c0ff5..69a648966 100644 --- a/tests/fixtures/sort/version-empty-lines.expected +++ b/tests/fixtures/sort/version-empty-lines.expected @@ -8,4 +8,8 @@ 1.2.3-alpha 1.2.3-alpha2 11.2.3 +bar2 +bar2.0.0 +foo0.1 +foo1.0 1.12.4 diff --git a/tests/fixtures/sort/version-empty-lines.expected.debug b/tests/fixtures/sort/version-empty-lines.expected.debug new file mode 100644 index 000000000..d3f2aaceb --- /dev/null +++ b/tests/fixtures/sort/version-empty-lines.expected.debug @@ -0,0 +1,45 @@ + +^ no match for key +^ no match for key + +^ no match for key +^ no match for key + +^ no match for key +^ no match for key + +^ no match for key +^ no match for key + +^ no match for key +^ no match for key + +^ no match for key +^ no match for key + +^ no match for key +^ no match for key +1.2.3-alpha +___________ +___________ +1.2.3-alpha2 +____________ +____________ +11.2.3 +______ +______ +bar2 +____ +____ +bar2.0.0 +________ +________ +foo0.1 +______ +______ +foo1.0 +______ +______ +>>>1.12.4 +_________ +_________ diff --git a/tests/fixtures/sort/version-empty-lines.txt b/tests/fixtures/sort/version-empty-lines.txt index 9b6b89788..fef474259 100644 --- a/tests/fixtures/sort/version-empty-lines.txt +++ b/tests/fixtures/sort/version-empty-lines.txt @@ -9,3 +9,7 @@ 1.12.4 +foo1.0 +foo0.1 +bar2.0.0 +bar2 \ No newline at end of file From 2ebca384c6a782c30bb5615253f12580cc1dfcca Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Sun, 27 Jun 2021 16:15:49 +0200 Subject: [PATCH 2/3] all utils: enable wrap_help This makes clap wrap the help text according to the terminal width, which improves readability for terminal widths < 120 chars, because clap defaults to a width of 120 chars without this feature. --- Cargo.lock | 1 + Cargo.toml | 2 +- src/uu/arch/Cargo.toml | 2 +- src/uu/base32/Cargo.toml | 2 +- src/uu/base64/Cargo.toml | 2 +- src/uu/basename/Cargo.toml | 2 +- src/uu/cat/Cargo.toml | 2 +- src/uu/chgrp/Cargo.toml | 2 +- src/uu/chmod/Cargo.toml | 2 +- src/uu/chown/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/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/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/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 +- 96 files changed, 96 insertions(+), 95 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 51424332d..ba289cc5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -177,6 +177,7 @@ dependencies = [ "atty", "bitflags", "strsim", + "term_size", "textwrap", "unicode-width", "vec_map", diff --git a/Cargo.toml b/Cargo.toml index 2783ff1b4..02d0abb88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -225,7 +225,7 @@ test = [ "uu_test" ] [workspace] [dependencies] -clap = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } lazy_static = { version="1.3" } textwrap = { version="=0.11.0", features=["term_size"] } # !maint: [2020-05-10; rivy] unstable crate using undocumented features; pinned currently, will review uucore = { version=">=0.0.8", package="uucore", path="src/uucore" } diff --git a/src/uu/arch/Cargo.toml b/src/uu/arch/Cargo.toml index b3fe1f8cb..855b577d6 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.1" -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/base32/Cargo.toml b/src/uu/base32/Cargo.toml index 1b448af0a..a024c49db 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features = ["encoding"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/base64/Cargo.toml b/src/uu/base64/Cargo.toml index d4ee69f03..202c6511b 100644 --- a/src/uu/base64/Cargo.toml +++ b/src/uu/base64/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/base64.rs" [dependencies] -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features = ["encoding"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } uu_base32 = { version=">=0.0.6", package="uu_base32", path="../base32"} diff --git a/src/uu/basename/Cargo.toml b/src/uu/basename/Cargo.toml index 0072619b7..9912dfd87 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 = "2.33.2" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/cat/Cargo.toml b/src/uu/cat/Cargo.toml index 9218e84fe..f20cddcf9 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } thiserror = "1.0" atty = "0.2" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/chgrp/Cargo.toml b/src/uu/chgrp/Cargo.toml index 0e43f7c02..619bdaaad 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } walkdir = "2.2" diff --git a/src/uu/chmod/Cargo.toml b/src/uu/chmod/Cargo.toml index ac7030b62..c523829f3 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs", "mode"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/chown/Cargo.toml b/src/uu/chown/Cargo.toml index 74533af04..f19ed39a8 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } glob = "0.3.0" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/cksum/Cargo.toml b/src/uu/cksum/Cargo.toml index 0332efbf8..792c6c0c7 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/comm/Cargo.toml b/src/uu/comm/Cargo.toml index f02217790..b1f8948e7 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index 9d582adae..76990863d 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } filetime = "0.2" libc = "0.2.85" quick-error = "1.2.3" diff --git a/src/uu/csplit/Cargo.toml b/src/uu/csplit/Cargo.toml index 7687991b0..48655316f 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } thiserror = "1.0" regex = "1.0.0" glob = "0.2.11" diff --git a/src/uu/cut/Cargo.toml b/src/uu/cut/Cargo.toml index 47b8223c5..9a83ff554 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } memchr = "2" diff --git a/src/uu/date/Cargo.toml b/src/uu/date/Cargo.toml index db6c077bd..3751e071e 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.4" -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/df/Cargo.toml b/src/uu/df/Cargo.toml index 0e65fdb32..4700d419a 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } number_prefix = "0.4" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["libc", "fsext"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/dircolors/Cargo.toml b/src/uu/dircolors/Cargo.toml index 7d47fa5c4..a97c78c78 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } glob = "0.3.0" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/dirname/Cargo.toml b/src/uu/dirname/Cargo.toml index 0975f33bb..2375d66c9 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/du/Cargo.toml b/src/uu/du/Cargo.toml index dcd1f720e..60f37db06 100644 --- a/src/uu/du/Cargo.toml +++ b/src/uu/du/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/du.rs" [dependencies] -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } chrono = "0.4" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/echo/Cargo.toml b/src/uu/echo/Cargo.toml index 15f189030..5ba44d4a8 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/env/Cargo.toml b/src/uu/env/Cargo.toml index ef0017e02..7cbd812c2 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" rust-ini = "0.13.0" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } diff --git a/src/uu/expand/Cargo.toml b/src/uu/expand/Cargo.toml index 4931cf53c..2119897b4 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } unicode-width = "0.1.5" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/expr/Cargo.toml b/src/uu/expr/Cargo.toml index 0906856d1..4211a2d25 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } 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 eb977760f..c9cfe78ab 100644 --- a/src/uu/factor/Cargo.toml +++ b/src/uu/factor/Cargo.toml @@ -21,7 +21,7 @@ rand = { version = "0.7", features = ["small_rng"] } smallvec = { version = "0.6.14, < 1.0" } uucore = { version = ">=0.0.8", package = "uucore", path = "../../uucore" } uucore_procs = { version = ">=0.0.5", package = "uucore_procs", path = "../../uucore_procs" } -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } [dev-dependencies] paste = "0.1.18" diff --git a/src/uu/false/Cargo.toml b/src/uu/false/Cargo.toml index 644051d59..93913b7e2 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/fmt/Cargo.toml b/src/uu/fmt/Cargo.toml index 24ee13b35..fdb1f8ca4 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" unicode-width = "0.1.5" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } diff --git a/src/uu/fold/Cargo.toml b/src/uu/fold/Cargo.toml index c5578384e..50ed34388 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/groups/Cargo.toml b/src/uu/groups/Cargo.toml index 4a5a537e5..14ee44d18 100644 --- a/src/uu/groups/Cargo.toml +++ b/src/uu/groups/Cargo.toml @@ -17,7 +17,7 @@ path = "src/groups.rs" [dependencies] uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["entries", "process"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } [[bin]] name = "groups" diff --git a/src/uu/hashsum/Cargo.toml b/src/uu/hashsum/Cargo.toml index 11388ebf8..87a2b8aa1 100644 --- a/src/uu/hashsum/Cargo.toml +++ b/src/uu/hashsum/Cargo.toml @@ -16,7 +16,7 @@ path = "src/hashsum.rs" [dependencies] digest = "0.6.2" -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } hex = "0.2.0" libc = "0.2.42" md5 = "0.3.5" diff --git a/src/uu/head/Cargo.toml b/src/uu/head/Cargo.toml index 661052f58..a0f1f9d95 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["ringbuffer"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/hostid/Cargo.toml b/src/uu/hostid/Cargo.toml index ab8b43f05..95e20db68 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/hostname/Cargo.toml b/src/uu/hostname/Cargo.toml index fb1d00682..e4d78441c 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" hostname = { version = "0.3", features = ["set"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["wide"] } diff --git a/src/uu/id/Cargo.toml b/src/uu/id/Cargo.toml index 308d6089d..97f478ef9 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["entries", "process"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/install/Cargo.toml b/src/uu/install/Cargo.toml index 91463199a..5beef2b29 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } 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 9371b7601..21284a6c3 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/kill/Cargo.toml b/src/uu/kill/Cargo.toml index e33411c70..c3a5368d9 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["signals"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/link/Cargo.toml b/src/uu/link/Cargo.toml index 14a6ac7c9..0457ec479 100644 --- a/src/uu/link/Cargo.toml +++ b/src/uu/link/Cargo.toml @@ -18,7 +18,7 @@ path = "src/link.rs" libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } [[bin]] name = "link" diff --git a/src/uu/ln/Cargo.toml b/src/uu/ln/Cargo.toml index c19d8fb52..4386d7522 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/logname/Cargo.toml b/src/uu/logname/Cargo.toml index 4aa4d68f4..2a541073f 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index ab58a7300..ecd4f1b8d 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -17,7 +17,7 @@ path = "src/ls.rs" [dependencies] locale = "0.2.2" chrono = "0.4.19" -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } 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 a8d374bf9..ad7972f2d 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs", "mode"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/mkfifo/Cargo.toml b/src/uu/mkfifo/Cargo.toml index d66003b10..5a78183ea 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/mknod/Cargo.toml b/src/uu/mknod/Cargo.toml index 1320e3546..c7ba535fd 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "^0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["mode"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/mktemp/Cargo.toml b/src/uu/mktemp/Cargo.toml index c669f0acc..93fb88857 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } rand = "0.5" tempfile = "3.1" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } diff --git a/src/uu/more/Cargo.toml b/src/uu/more/Cargo.toml index af6781876..497f91f4e 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version = ">=0.0.7", package = "uucore", path = "../../uucore" } uucore_procs = { version = ">=0.0.5", package = "uucore_procs", path = "../../uucore_procs" } crossterm = ">=0.19" diff --git a/src/uu/mv/Cargo.toml b/src/uu/mv/Cargo.toml index 8f1e7b9ee..94d3de15e 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } fs_extra = "1.1.0" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/nice/Cargo.toml b/src/uu/nice/Cargo.toml index 279e79ae3..eed524b8a 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" nix = { version="<=0.13" } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } diff --git a/src/uu/nl/Cargo.toml b/src/uu/nl/Cargo.toml index a51a2555e..4197bfd8e 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } 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 839219a84..f7166a4b6 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" atty = "0.2" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/nproc/Cargo.toml b/src/uu/nproc/Cargo.toml index be9d8f2e3..a4eec07eb 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/numfmt/Cargo.toml b/src/uu/numfmt/Cargo.toml index ac5266d68..7a81e36d6 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/od/Cargo.toml b/src/uu/od/Cargo.toml index 6f9a75318..24da14b31 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } half = "1.6" libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } diff --git a/src/uu/paste/Cargo.toml b/src/uu/paste/Cargo.toml index 4e9971368..cfc70a3bd 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/pathchk/Cargo.toml b/src/uu/pathchk/Cargo.toml index 8c4e61d2b..c39eb6e16 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/pinky/Cargo.toml b/src/uu/pinky/Cargo.toml index a3c36259a..2cdb28d92 100644 --- a/src/uu/pinky/Cargo.toml +++ b/src/uu/pinky/Cargo.toml @@ -17,7 +17,7 @@ path = "src/pinky.rs" [dependencies] uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["utmpx", "entries"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } -clap = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } [[bin]] name = "pinky" diff --git a/src/uu/pr/Cargo.toml b/src/uu/pr/Cargo.toml index de519161a..122bed694 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["utmpx", "entries"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } getopts = "0.2.21" diff --git a/src/uu/printenv/Cargo.toml b/src/uu/printenv/Cargo.toml index be95b8157..faa24a33b 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/printf/Cargo.toml b/src/uu/printf/Cargo.toml index 13d54fcca..f980837e7 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } itertools = "0.8.0" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/ptx/Cargo.toml b/src/uu/ptx/Cargo.toml index eb4413cbd..1ccdd9ad4 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } 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 f4350d54c..3393a63b3 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/readlink/Cargo.toml b/src/uu/readlink/Cargo.toml index 6e4be4dd8..65b5c149b 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/realpath/Cargo.toml b/src/uu/realpath/Cargo.toml index 327a875f8..dc21bdaca 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/relpath/Cargo.toml b/src/uu/relpath/Cargo.toml index 7a316c29c..1240d9b1b 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/rm/Cargo.toml b/src/uu/rm/Cargo.toml index d84756fd3..20fd60745 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } walkdir = "2.2" remove_dir_all = "0.5.1" winapi = { version="0.3", features=[] } diff --git a/src/uu/rmdir/Cargo.toml b/src/uu/rmdir/Cargo.toml index b6e04f71c..40c2efbb1 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/seq/Cargo.toml b/src/uu/seq/Cargo.toml index 32f2bbac8..726c7242b 100644 --- a/src/uu/seq/Cargo.toml +++ b/src/uu/seq/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/seq.rs" [dependencies] -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } num-bigint = "0.4.0" num-traits = "0.2.14" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } diff --git a/src/uu/shred/Cargo.toml b/src/uu/shred/Cargo.toml index dda68b45b..dafff162b 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } filetime = "0.2.1" libc = "0.2.42" rand = "0.5" diff --git a/src/uu/shuf/Cargo.toml b/src/uu/shuf/Cargo.toml index dbf559454..6c0353681 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } rand = "0.5" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/sleep/Cargo.toml b/src/uu/sleep/Cargo.toml index 618ea7e28..14c4c5300 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index f06610248..91580a7d9 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } compare = "0.1.0" fnv = "1.0.7" itertools = "0.10.0" diff --git a/src/uu/split/Cargo.toml b/src/uu/split/Cargo.toml index 056fbe034..e19695a39 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/stat/Cargo.toml b/src/uu/stat/Cargo.toml index 86b7da139..81af993a5 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["entries", "libc", "fs", "fsext"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/stdbuf/Cargo.toml b/src/uu/stdbuf/Cargo.toml index 884a98785..a3eb059eb 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } tempfile = "3.1" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/sum/Cargo.toml b/src/uu/sum/Cargo.toml index 64b6d3de9..e16c865a3 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/sync/Cargo.toml b/src/uu/sync/Cargo.toml index fcff6002e..83efb815d 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["wide"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/tac/Cargo.toml b/src/uu/tac/Cargo.toml index 3a530d0ce..2d0623cd9 100644 --- a/src/uu/tac/Cargo.toml +++ b/src/uu/tac/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/tac.rs" [dependencies] -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index 273c67bb3..a895819cd 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["ringbuffer"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/tee/Cargo.toml b/src/uu/tee/Cargo.toml index 7ac81adc4..a88d76508 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" retain_mut = "0.1.2" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["libc"] } diff --git a/src/uu/test/Cargo.toml b/src/uu/test/Cargo.toml index cd0282a45..6f6dd340e 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/timeout/Cargo.toml b/src/uu/timeout/Cargo.toml index 70ce64630..63a16c086 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" nix = "0.20.0" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["process", "signals"] } diff --git a/src/uu/touch/Cargo.toml b/src/uu/touch/Cargo.toml index 0608a7b7c..e2f948a5a 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } time = "0.1.40" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["libc"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/tr/Cargo.toml b/src/uu/tr/Cargo.toml index a3d066bfb..7783db144 100644 --- a/src/uu/tr/Cargo.toml +++ b/src/uu/tr/Cargo.toml @@ -17,7 +17,7 @@ path = "src/tr.rs" [dependencies] bit-set = "0.5.0" fnv = "1.0.5" -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/true/Cargo.toml b/src/uu/true/Cargo.toml index f121d56de..06e7c35ff 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 = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/truncate/Cargo.toml b/src/uu/truncate/Cargo.toml index e2c0afadc..50d3dc4f3 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index 49b7669df..90396ff40 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" atty = "0.2" uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/uname/Cargo.toml b/src/uu/uname/Cargo.toml index 9707d8444..54a1591a2 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } platform-info = "0.1" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/unexpand/Cargo.toml b/src/uu/unexpand/Cargo.toml index e39dd87ca..5e47d8b58 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } unicode-width = "0.1.5" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/uniq/Cargo.toml b/src/uu/uniq/Cargo.toml index 3fe89b450..be082fe88 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } strum = "0.20" strum_macros = "0.20" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } diff --git a/src/uu/unlink/Cargo.toml b/src/uu/unlink/Cargo.toml index 08da2624e..ef0f291f8 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } libc = "0.2.42" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/uptime/Cargo.toml b/src/uu/uptime/Cargo.toml index 1136e6420..eec745ab1 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" -clap = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["libc", "utmpx"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/users/Cargo.toml b/src/uu/users/Cargo.toml index 84da13020..6cafd7c32 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["utmpx"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/wc/Cargo.toml b/src/uu/wc/Cargo.toml index 8ae79dc08..ad4301e7a 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } thiserror = "1.0" diff --git a/src/uu/who/Cargo.toml b/src/uu/who/Cargo.toml index 4d8eccb45..06388c7bf 100644 --- a/src/uu/who/Cargo.toml +++ b/src/uu/who/Cargo.toml @@ -17,7 +17,7 @@ path = "src/who.rs" [dependencies] uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["utmpx"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } -clap = "2.33.3" +clap = { version = "2.33", features = ["wrap_help"] } [[bin]] name = "who" diff --git a/src/uu/whoami/Cargo.toml b/src/uu/whoami/Cargo.toml index 28670c8b5..a7fc19848 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["entries", "wide"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/yes/Cargo.toml b/src/uu/yes/Cargo.toml index 4a843ddd8..0338a4037 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 = "2.33" +clap = { version = "2.33", features = ["wrap_help"] } uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["zero-copy"] } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } From d3732e08c4bbcd518d18017e102cbe8b1e5373c1 Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Sun, 27 Jun 2021 15:34:20 +0200 Subject: [PATCH 3/3] sort: disable -o with -C and -c --- src/uu/sort/src/sort.rs | 2 ++ tests/by-util/test_sort.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index fb0241945..0bad9de6b 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -1198,12 +1198,14 @@ pub fn uu_app() -> App<'static, 'static> { options::check::QUIET, options::check::DIAGNOSE_FIRST, ]) + .conflicts_with(options::OUTPUT) .help("check for sorted input; do not sort"), ) .arg( Arg::with_name(options::check::CHECK_SILENT) .short("C") .long(options::check::CHECK_SILENT) + .conflicts_with(options::OUTPUT) .help("exit successfully if the given file is already sorted, and exit with status 1 otherwise."), ) .arg( diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index 3e841f630..ea98643f7 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -941,3 +941,17 @@ fn test_sigpipe_panic() { Ok(String::new()) ); } + +#[test] +fn test_conflict_check_out() { + let check_flags = ["-c=silent", "-c=quiet", "-c=diagnose-first", "-c", "-C"]; + for check_flag in &check_flags { + new_ucmd!() + .arg(check_flag) + .arg("-o=/dev/null") + .fails() + .stderr_contains( + "error: The argument '--output ' cannot be used with '--check", + ); + } +}