From 42d6604e591307fa591e830cdaeef80d2f586b59 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 18 Apr 2023 10:12:17 +0200 Subject: [PATCH 001/370] fmt: implement default for FmtOptions --- src/uu/fmt/src/fmt.rs | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index d144bdd8a..fc2226d6b 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -60,6 +60,29 @@ pub struct FmtOptions { goal: usize, tabwidth: usize, } + +impl Default for FmtOptions { + fn default() -> Self { + Self { + crown: false, + tagged: false, + mail: false, + uniform: false, + quick: false, + split_only: false, + use_prefix: false, + prefix: String::new(), + xprefix: false, + use_anti_prefix: false, + anti_prefix: String::new(), + xanti_prefix: false, + width: 79, + goal: 74, + tabwidth: 8, + } + } +} + /// Parse the command line arguments and return the list of files and formatting options. /// /// # Arguments @@ -70,6 +93,7 @@ pub struct FmtOptions { /// /// A tuple containing a vector of file names and a `FmtOptions` struct. #[allow(clippy::cognitive_complexity)] +#[allow(clippy::field_reassign_with_default)] fn parse_arguments(args: impl uucore::Args) -> UResult<(Vec, FmtOptions)> { let matches = uu_app().try_get_matches_from(args)?; @@ -78,23 +102,7 @@ fn parse_arguments(args: impl uucore::Args) -> UResult<(Vec, FmtOptions) .map(|v| v.map(ToString::to_string).collect()) .unwrap_or_default(); - let mut fmt_opts = FmtOptions { - crown: false, - tagged: false, - mail: false, - uniform: false, - quick: false, - split_only: false, - use_prefix: false, - prefix: String::new(), - xprefix: false, - use_anti_prefix: false, - anti_prefix: String::new(), - xanti_prefix: false, - width: 79, - goal: 74, - tabwidth: 8, - }; + let mut fmt_opts = FmtOptions::default(); fmt_opts.tagged = matches.get_flag(OPT_TAGGED_PARAGRAPH); if matches.get_flag(OPT_CROWN_MARGIN) { From 09db8d8af926e8b376653a9398c9bdba833dacec Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 28 Apr 2023 16:55:01 +0200 Subject: [PATCH 002/370] fmt: adapt defaults to the ones used by GNU fmt --- src/uu/fmt/src/fmt.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index fc2226d6b..f112d1b07 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -76,8 +76,8 @@ impl Default for FmtOptions { use_anti_prefix: false, anti_prefix: String::new(), xanti_prefix: false, - width: 79, - goal: 74, + width: 75, + goal: 70, tabwidth: 8, } } @@ -95,6 +95,9 @@ impl Default for FmtOptions { #[allow(clippy::cognitive_complexity)] #[allow(clippy::field_reassign_with_default)] fn parse_arguments(args: impl uucore::Args) -> UResult<(Vec, FmtOptions)> { + // by default, goal is 93% of width + const DEFAULT_GOAL_TO_WIDTH_RATIO: usize = 93; + let matches = uu_app().try_get_matches_from(args)?; let mut files: Vec = matches @@ -149,7 +152,10 @@ fn parse_arguments(args: impl uucore::Args) -> UResult<(Vec, FmtOptions) ), )); } - fmt_opts.goal = cmp::min(fmt_opts.width * 94 / 100, fmt_opts.width - 3); + fmt_opts.goal = cmp::min( + fmt_opts.width * DEFAULT_GOAL_TO_WIDTH_RATIO / 100, + fmt_opts.width - 3, + ); }; if let Some(s) = matches.get_one::(OPT_GOAL) { @@ -163,7 +169,10 @@ fn parse_arguments(args: impl uucore::Args) -> UResult<(Vec, FmtOptions) } }; if !matches.get_flag(OPT_WIDTH) { - fmt_opts.width = cmp::max(fmt_opts.goal * 100 / 94, fmt_opts.goal + 3); + fmt_opts.width = cmp::max( + fmt_opts.goal * 100 / DEFAULT_GOAL_TO_WIDTH_RATIO, + fmt_opts.goal + 3, + ); } else if fmt_opts.goal > fmt_opts.width { return Err(USimpleError::new(1, "GOAL cannot be greater than WIDTH.")); } @@ -364,14 +373,14 @@ pub fn uu_app() -> Command { Arg::new(OPT_WIDTH) .short('w') .long("width") - .help("Fill output lines up to a maximum of WIDTH columns, default 79.") + .help("Fill output lines up to a maximum of WIDTH columns, default 75.") .value_name("WIDTH"), ) .arg( Arg::new(OPT_GOAL) .short('g') .long("goal") - .help("Goal width, default ~0.94*WIDTH. Must be less than WIDTH.") + .help("Goal width, default of 93% of WIDTH. Must be less than WIDTH.") .value_name("GOAL"), ) .arg( From d345a280bf588b325babb29c60dc7d84d2c22832 Mon Sep 17 00:00:00 2001 From: John Shin Date: Sun, 30 Jul 2023 14:37:17 -0700 Subject: [PATCH 003/370] seq: update inf and nan parsing --- src/uu/seq/src/numberparse.rs | 40 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/uu/seq/src/numberparse.rs b/src/uu/seq/src/numberparse.rs index 23d94ea2b..1921e2e4c 100644 --- a/src/uu/seq/src/numberparse.rs +++ b/src/uu/seq/src/numberparse.rs @@ -69,27 +69,25 @@ fn parse_no_decimal_no_exponent(s: &str) -> Result { // Possibly "NaN" or "inf". - // - // TODO In Rust v1.53.0, this change - // https://github.com/rust-lang/rust/pull/78618 improves the - // parsing of floats to include being able to parse "NaN" - // and "inf". So when the minimum version of this crate is - // increased to 1.53.0, we should just use the built-in - // `f32` parsing instead. - if s.eq_ignore_ascii_case("inf") { - Ok(PreciseNumber::new( - Number::Float(ExtendedBigDecimal::Infinity), - 0, - 0, - )) - } else if s.eq_ignore_ascii_case("-inf") { - Ok(PreciseNumber::new( - Number::Float(ExtendedBigDecimal::MinusInfinity), - 0, - 0, - )) - } else if s.eq_ignore_ascii_case("nan") || s.eq_ignore_ascii_case("-nan") { - Err(ParseNumberError::Nan) + if let Ok(num) = f32::from_str(s) { + // pattern matching on floating point literal is not encouraged 'https://github.com/rust-lang/rust/issues/41620' + if num == f32::INFINITY { + Ok(PreciseNumber::new( + Number::Float(ExtendedBigDecimal::Infinity), + 0, + 0, + )) + } else if num == f32::NEG_INFINITY { + Ok(PreciseNumber::new( + Number::Float(ExtendedBigDecimal::MinusInfinity), + 0, + 0, + )) + } else if num.is_nan() { + Err(ParseNumberError::Nan) + } else { + Err(ParseNumberError::Float) + } } else { Err(ParseNumberError::Float) } From ec27a074c03e9b7f65d370c790921ff68b69ecb6 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 1 Aug 2023 08:20:26 +0200 Subject: [PATCH 004/370] uucore: don't show error for ambiguous value that's a direct match in ShortcutValueParser --- .../src/lib/parser/shortcut_value_parser.rs | 68 +++++++++++++------ 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/src/uucore/src/lib/parser/shortcut_value_parser.rs b/src/uucore/src/lib/parser/shortcut_value_parser.rs index 0b0716158..07ed49cb3 100644 --- a/src/uucore/src/lib/parser/shortcut_value_parser.rs +++ b/src/uucore/src/lib/parser/shortcut_value_parser.rs @@ -1,3 +1,4 @@ +// spell-checker:ignore abcdefgh use clap::{ builder::{PossibleValue, TypedValueParser}, error::{ContextKind, ContextValue, ErrorKind}, @@ -15,6 +16,34 @@ impl ShortcutValueParser { pub fn new(values: impl Into) -> Self { values.into() } + + fn generate_clap_error( + &self, + cmd: &clap::Command, + arg: Option<&clap::Arg>, + value: &str, + ) -> clap::Error { + let mut err = clap::Error::new(ErrorKind::InvalidValue).with_cmd(cmd); + + if let Some(arg) = arg { + err.insert( + ContextKind::InvalidArg, + ContextValue::String(arg.to_string()), + ); + } + + err.insert( + ContextKind::InvalidValue, + ContextValue::String(value.to_string()), + ); + + err.insert( + ContextKind::ValidValue, + ContextValue::Strings(self.0.iter().map(|x| x.get_name().to_string()).collect()), + ); + + err + } } impl TypedValueParser for ShortcutValueParser { @@ -36,29 +65,16 @@ impl TypedValueParser for ShortcutValueParser { .filter(|x| x.get_name().starts_with(value)) .collect(); - if matched_values.len() == 1 { - Ok(matched_values[0].get_name().to_string()) - } else { - let mut err = clap::Error::new(ErrorKind::InvalidValue).with_cmd(cmd); - - if let Some(arg) = arg { - err.insert( - ContextKind::InvalidArg, - ContextValue::String(arg.to_string()), - ); + match matched_values.len() { + 0 => Err(self.generate_clap_error(cmd, arg, value)), + 1 => Ok(matched_values[0].get_name().to_string()), + _ => { + if let Some(direct_match) = matched_values.iter().find(|x| x.get_name() == value) { + Ok(direct_match.get_name().to_string()) + } else { + Err(self.generate_clap_error(cmd, arg, value)) + } } - - err.insert( - ContextKind::InvalidValue, - ContextValue::String(value.to_string()), - ); - - err.insert( - ContextKind::ValidValue, - ContextValue::Strings(self.0.iter().map(|x| x.get_name().to_string()).collect()), - ); - - Err(err) } } @@ -127,6 +143,14 @@ mod tests { assert_eq!("abef", result.unwrap()); } + #[test] + fn test_parse_ref_with_ambiguous_value_that_is_a_possible_value() { + let cmd = Command::new("cmd"); + let parser = ShortcutValueParser::new(["abcd", "abcdefgh"]); + let result = parser.parse_ref(&cmd, None, OsStr::new("abcd")); + assert_eq!("abcd", result.unwrap()); + } + #[test] #[cfg(unix)] fn test_parse_ref_with_invalid_utf8() { From 773e69078cd959c8d3e13dd8a7dbfaa51f315e6d Mon Sep 17 00:00:00 2001 From: Aneesh Date: Thu, 3 Aug 2023 13:39:38 +0530 Subject: [PATCH 005/370] docs(bin,has): add docstrings for macros bin and has --- src/uucore/src/lib/features/fs.rs | 3 +++ src/uucore/src/lib/lib.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index e92d0977f..5804a2235 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -31,6 +31,9 @@ use std::path::{Component, Path, PathBuf, MAIN_SEPARATOR}; #[cfg(target_os = "windows")] use winapi_util::AsHandleRef; +/// Used to check if the `mode` has its `perm` bit set. +/// +/// This macro expands to `mode & perm != 0`. #[cfg(unix)] #[macro_export] macro_rules! has { diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index ca9a48d25..02724e1bf 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -86,6 +86,10 @@ use std::sync::atomic::Ordering; use once_cell::sync::Lazy; +/// Execute utility code for `util`. +/// +/// This macro expands to a main function that invokes the `uumain` function in `util` +/// Exits with code returned by `uumain`. #[macro_export] macro_rules! bin { ($util:ident) => { From 271606ddfacbf46cf01187d486af2da56b1318cb Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 3 Aug 2023 16:12:29 +0200 Subject: [PATCH 006/370] nl: fix output of numbering styles --- src/uu/nl/src/nl.rs | 186 ++++++++++++--------------------------- tests/by-util/test_nl.rs | 159 +++++++++++++++++++++++++++++++-- 2 files changed, 208 insertions(+), 137 deletions(-) diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 502e7d518..85ddb1b41 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -44,7 +44,7 @@ impl Default for Settings { fn default() -> Self { Self { header_numbering: NumberingStyle::None, - body_numbering: NumberingStyle::All, + body_numbering: NumberingStyle::NonEmpty, footer_numbering: NumberingStyle::None, section_delimiter: ['\\', ':'], starting_line_number: 1, @@ -271,146 +271,70 @@ pub fn uu_app() -> Command { } // nl implements the main functionality for an individual buffer. -#[allow(clippy::cognitive_complexity)] fn nl(reader: &mut BufReader, settings: &Settings) -> UResult<()> { - let regexp: regex::Regex = regex::Regex::new(r".?").unwrap(); + let mut current_numbering_style = &settings.body_numbering; let mut line_no = settings.starting_line_number; - let mut empty_line_count: u64 = 0; - // Initially, we use the body's line counting settings - let mut regex_filter = match settings.body_numbering { - NumberingStyle::Regex(ref re) => re, - _ => ®exp, - }; - let mut line_filter: fn(&str, ®ex::Regex) -> bool = pass_regex; - for l in reader.lines() { - let mut l = l.map_err_context(|| "could not read line".to_string())?; - // Sanitize the string. We want to print the newline ourselves. - if l.ends_with('\n') { - l.pop(); - } - // Next we iterate through the individual chars to see if this - // is one of the special lines starting a new "section" in the - // document. - let line = l; - let mut odd = false; - // matched_group counts how many copies of section_delimiter - // this string consists of (0 if there's anything else) - let mut matched_groups = 0u8; - for c in line.chars() { - // If this is a newline character, the loop should end. - if c == '\n' { - break; - } - // If we have already seen three groups (corresponding to - // a header) or the current char does not form part of - // a new group, then this line is not a segment indicator. - if matched_groups >= 3 || settings.section_delimiter[usize::from(odd)] != c { - matched_groups = 0; - break; - } - if odd { - // We have seen a new group and count it. - matched_groups += 1; - } - odd = !odd; - } + let mut consecutive_empty_lines = 0; + + for line in reader.lines() { + let line = line.map_err_context(|| "could not read line".to_string())?; - // See how many groups we matched. That will tell us if this is - // a line starting a new segment, and the number of groups - // indicates what type of segment. - if matched_groups > 0 { - // The current line is a section delimiter, so we output - // a blank line. - println!(); - // However the line does not count as a blank line, so we - // reset the counter used for --join-blank-lines. - empty_line_count = 0; - match *match matched_groups { - 3 => { - // This is a header, so we may need to reset the - // line number - if settings.renumber { - line_no = settings.starting_line_number; - } - &settings.header_numbering - } - 1 => &settings.footer_numbering, - // The only option left is 2, but rust wants - // a catch-all here. - _ => &settings.body_numbering, - } { - NumberingStyle::All => { - line_filter = pass_all; - } - NumberingStyle::NonEmpty => { - line_filter = pass_nonempty; - } - NumberingStyle::None => { - line_filter = pass_none; - } - NumberingStyle::Regex(ref re) => { - line_filter = pass_regex; - regex_filter = re; - } - } - continue; - } - // From this point on we format and print a "regular" line. if line.is_empty() { - // The line is empty, which means that we have to care - // about the --join-blank-lines parameter. - empty_line_count += 1; + consecutive_empty_lines += 1; } else { - // This saves us from having to check for an empty string - // in the next selector. - empty_line_count = 0; + consecutive_empty_lines = 0; + }; + + // FIXME section delimiters are hardcoded and settings.section_delimiter is ignored + // because --section-delimiter is not correctly implemented yet + let _ = settings.section_delimiter; // XXX suppress "field never read" warning + let new_numbering_style = match line.as_str() { + "\\:\\:\\:" => Some(&settings.header_numbering), + "\\:\\:" => Some(&settings.body_numbering), + "\\:" => Some(&settings.footer_numbering), + _ => None, + }; + + if let Some(new_style) = new_numbering_style { + current_numbering_style = new_style; + line_no = settings.starting_line_number; + println!(); + } else { + let is_line_numbered = match current_numbering_style { + // consider $join_blank_lines consecutive empty lines to be one logical line + // for numbering, and only number the last one + NumberingStyle::All + if line.is_empty() + && consecutive_empty_lines % settings.join_blank_lines != 0 => + { + false + } + NumberingStyle::All => true, + NumberingStyle::NonEmpty => !line.is_empty(), + NumberingStyle::None => false, + NumberingStyle::Regex(re) => re.is_match(&line), + }; + + if is_line_numbered { + println!( + "{}{}{}", + settings + .number_format + .format(line_no, settings.number_width), + settings.number_separator, + line + ); + // update line number for the potential next line + line_no += settings.line_increment; + } else { + let spaces = " ".repeat(settings.number_width + 1); + println!("{spaces}{line}"); + } } - if !line_filter(&line, regex_filter) - || (empty_line_count > 0 && empty_line_count < settings.join_blank_lines) - { - // No number is printed for this line. Either we did not - // want to print one in the first place, or it is a blank - // line but we are still collecting more blank lines via - // the option --join-blank-lines. - println!("{line}"); - continue; - } - // If we make it here, then either we are printing a non-empty - // line or assigning a line number to an empty line. Either - // way, start counting empties from zero once more. - empty_line_count = 0; - // A line number is to be printed. - println!( - "{}{}{}", - settings - .number_format - .format(line_no, settings.number_width), - settings.number_separator, - line - ); - // Now update the line number for the (potential) next - // line. - line_no += settings.line_increment; } Ok(()) } -fn pass_regex(line: &str, re: ®ex::Regex) -> bool { - re.is_match(line) -} - -fn pass_nonempty(line: &str, _: ®ex::Regex) -> bool { - !line.is_empty() -} - -fn pass_none(_: &str, _: ®ex::Regex) -> bool { - false -} - -fn pass_all(_: &str, _: ®ex::Regex) -> bool { - true -} - #[cfg(test)] mod test { use super::*; diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index 08f009765..ab27fe148 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -52,15 +52,15 @@ fn test_sections_and_styles() { for (fixture, output) in [ ( "section.txt", - "\nHEADER1\nHEADER2\n\n1 |BODY1\n2 \ - |BODY2\n\nFOOTER1\nFOOTER2\n\nNEXTHEADER1\nNEXTHEADER2\n\n1 \ - |NEXTBODY1\n2 |NEXTBODY2\n\nNEXTFOOTER1\nNEXTFOOTER2\n", + "\n HEADER1\n HEADER2\n\n1 |BODY1\n2 \ + |BODY2\n\n FOOTER1\n FOOTER2\n\n NEXTHEADER1\n NEXTHEADER2\n\n1 \ + |NEXTBODY1\n2 |NEXTBODY2\n\n NEXTFOOTER1\n NEXTFOOTER2\n", ), ( "joinblanklines.txt", - "1 |Nonempty\n2 |Nonempty\n3 |Followed by 10x empty\n\n\n\n\n4 \ - |\n\n\n\n\n5 |\n6 |Followed by 5x empty\n\n\n\n\n7 |\n8 \ - |Followed by 4x empty\n\n\n\n\n9 |Nonempty\n10 |Nonempty\n11 \ + "1 |Nonempty\n2 |Nonempty\n3 |Followed by 10x empty\n \n \n \n \n4 \ + |\n \n \n \n \n5 |\n6 |Followed by 5x empty\n \n \n \n \n7 |\n8 \ + |Followed by 4x empty\n \n \n \n \n9 |Nonempty\n10 |Nonempty\n11 \ |Nonempty.\n", ), ] { @@ -257,6 +257,25 @@ fn test_invalid_line_increment() { } } +#[test] +fn test_join_blank_lines() { + for arg in ["-l3", "--join-blank-lines=3"] { + new_ucmd!() + .arg(arg) + .arg("--body-numbering=a") + .pipe_in("\n\n\n\n\n\n") + .succeeds() + .stdout_is(concat!( + " \n", + " \n", + " 1\t\n", + " \n", + " \n", + " 2\t\n", + )); + } +} + #[test] fn test_join_blank_lines_zero() { for arg in ["-l0", "--join-blank-lines=0"] { @@ -275,3 +294,131 @@ fn test_invalid_join_blank_lines() { .stderr_contains("invalid value 'invalid'"); } } + +#[test] +fn test_default_body_numbering() { + new_ucmd!() + .pipe_in("a\n\nb") + .succeeds() + .stdout_is(" 1\ta\n \n 2\tb\n"); +} + +#[test] +fn test_body_numbering_all_lines_without_delimiter() { + for arg in ["-ba", "--body-numbering=a"] { + new_ucmd!() + .arg(arg) + .pipe_in("a\n\nb") + .succeeds() + .stdout_is(" 1\ta\n 2\t\n 3\tb\n"); + } +} + +#[test] +fn test_body_numbering_no_lines_without_delimiter() { + for arg in ["-bn", "--body-numbering=n"] { + new_ucmd!() + .arg(arg) + .pipe_in("a\n\nb") + .succeeds() + .stdout_is(" a\n \n b\n"); + } +} + +#[test] +fn test_body_numbering_non_empty_lines_without_delimiter() { + for arg in ["-bt", "--body-numbering=t"] { + new_ucmd!() + .arg(arg) + .pipe_in("a\n\nb") + .succeeds() + .stdout_is(" 1\ta\n \n 2\tb\n"); + } +} + +#[test] +fn test_body_numbering_matched_lines_without_delimiter() { + for arg in ["-bp^[ac]", "--body-numbering=p^[ac]"] { + new_ucmd!() + .arg(arg) + .pipe_in("a\nb\nc") + .succeeds() + .stdout_is(" 1\ta\n b\n 2\tc\n"); + } +} + +#[test] +fn test_numbering_all_lines() { + let delimiters_and_args = [ + ("\\:\\:\\:\n", ["-ha", "--header-numbering=a"]), + ("\\:\\:\n", ["-ba", "--body-numbering=a"]), + ("\\:\n", ["-fa", "--footer-numbering=a"]), + ]; + + for (delimiter, args) in delimiters_and_args { + for arg in args { + new_ucmd!() + .arg(arg) + .pipe_in(format!("{delimiter}a\n\nb")) + .succeeds() + .stdout_is("\n 1\ta\n 2\t\n 3\tb\n"); + } + } +} + +#[test] +fn test_numbering_no_lines() { + let delimiters_and_args = [ + ("\\:\\:\\:\n", ["-hn", "--header-numbering=n"]), + ("\\:\\:\n", ["-bn", "--body-numbering=n"]), + ("\\:\n", ["-fn", "--footer-numbering=n"]), + ]; + + for (delimiter, args) in delimiters_and_args { + for arg in args { + new_ucmd!() + .arg(arg) + .pipe_in(format!("{delimiter}a\n\nb")) + .succeeds() + .stdout_is("\n a\n \n b\n"); + } + } +} + +#[test] +fn test_numbering_non_empty_lines() { + let delimiters_and_args = [ + ("\\:\\:\\:\n", ["-ht", "--header-numbering=t"]), + ("\\:\\:\n", ["-bt", "--body-numbering=t"]), + ("\\:\n", ["-ft", "--footer-numbering=t"]), + ]; + + for (delimiter, args) in delimiters_and_args { + for arg in args { + new_ucmd!() + .arg(arg) + .pipe_in(format!("{delimiter}a\n\nb")) + .succeeds() + .stdout_is("\n 1\ta\n \n 2\tb\n"); + } + } +} + +#[test] +fn test_numbering_matched_lines() { + let delimiters_and_args = [ + ("\\:\\:\\:\n", ["-hp^[ac]", "--header-numbering=p^[ac]"]), + ("\\:\\:\n", ["-bp^[ac]", "--body-numbering=p^[ac]"]), + ("\\:\n", ["-fp^[ac]", "--footer-numbering=p^[ac]"]), + ]; + + for (delimiter, args) in delimiters_and_args { + for arg in args { + new_ucmd!() + .arg(arg) + .pipe_in(format!("{delimiter}a\nb\nc")) + .succeeds() + .stdout_is("\n 1\ta\n b\n 2\tc\n"); + } + } +} From 745110ccbf17c196254eea0e8ce28d2e81e568cd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 6 Aug 2023 01:03:34 +0000 Subject: [PATCH 007/370] chore(deps): update rust crate regex to 1.9.3 --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2d316d0ff..433c1becf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1778,9 +1778,9 @@ checksum = "f1bfbf25d7eb88ddcbb1ec3d755d0634da8f7657b2cb8b74089121409ab8228f" [[package]] name = "regex" -version = "1.9.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" dependencies = [ "aho-corasick 1.0.1", "memchr", @@ -1790,9 +1790,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.1" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaecc05d5c4b5f7da074b9a0d1a0867e71fd36e7fc0482d8bcfe8e8fc56290" +checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" dependencies = [ "aho-corasick 1.0.1", "memchr", @@ -1801,9 +1801,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab07dc67230e4a4718e70fd5c20055a4334b121f1f9db8fe63ef39ce9b8c846" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "relative-path" diff --git a/Cargo.toml b/Cargo.toml index accc027ab..2d03e1f05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -310,7 +310,7 @@ rand = { version = "0.8", features = ["small_rng"] } rand_core = "0.6" rayon = "1.7" redox_syscall = "0.3" -regex = "1.9.1" +regex = "1.9.3" rstest = "0.18.1" rust-ini = "0.19.0" same-file = "1.0.6" From 2bb56d44a4161b1b40225f27f8e30090910aae38 Mon Sep 17 00:00:00 2001 From: John Shin Date: Sat, 5 Aug 2023 18:23:29 -0700 Subject: [PATCH 008/370] seq: add tests for infinity and -infinity args --- src/uu/seq/src/numberparse.rs | 12 ++++++++++++ tests/by-util/test_seq.rs | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/uu/seq/src/numberparse.rs b/src/uu/seq/src/numberparse.rs index 1921e2e4c..156f80fb9 100644 --- a/src/uu/seq/src/numberparse.rs +++ b/src/uu/seq/src/numberparse.rs @@ -477,11 +477,23 @@ mod tests { #[test] fn test_parse_inf() { assert_eq!(parse("inf"), Number::Float(ExtendedBigDecimal::Infinity)); + assert_eq!( + parse("infinity"), + Number::Float(ExtendedBigDecimal::Infinity) + ); assert_eq!(parse("+inf"), Number::Float(ExtendedBigDecimal::Infinity)); + assert_eq!( + parse("+infinity"), + Number::Float(ExtendedBigDecimal::Infinity) + ); assert_eq!( parse("-inf"), Number::Float(ExtendedBigDecimal::MinusInfinity) ); + assert_eq!( + parse("-infinity"), + Number::Float(ExtendedBigDecimal::MinusInfinity) + ); } #[test] diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index de0781912..95de2f3cd 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -619,11 +619,21 @@ fn test_neg_inf() { run(&["--", "-inf", "0"], b"-inf\n-inf\n-inf\n"); } +#[test] +fn test_neg_infinity() { + run(&["--", "-infinity", "0"], b"-inf\n-inf\n-inf\n"); +} + #[test] fn test_inf() { run(&["inf"], b"1\n2\n3\n"); } +#[test] +fn test_infinity() { + run(&["infinity"], b"1\n2\n3\n"); +} + #[test] fn test_inf_width() { run( From 0f5b6e897859eb2e0f6f20ea5c63c29ad35d9e26 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 6 Aug 2023 15:10:10 +0200 Subject: [PATCH 009/370] deny.toml: add bitflags to skip list --- deny.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deny.toml b/deny.toml index 84dae2b98..e101c89fd 100644 --- a/deny.toml +++ b/deny.toml @@ -86,6 +86,8 @@ skip = [ { name = "aho-corasick", version = "0.7.19" }, # various crates { name = "syn", version = "1.0.109" }, + # various crates + { name = "bitflags", version = "1.3.2" }, ] # spell-checker: enable From f03f18c3e865b05cbc37331808444442b3df8b66 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 6 Aug 2023 16:10:01 +0200 Subject: [PATCH 010/370] Bump filetime from 0.2.20 to 0.2.22 --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 433c1becf..829f875b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -841,14 +841,14 @@ checksum = "31a7a908b8f32538a2143e59a6e4e2508988832d5d4d6f7c156b3cbc762643a5" [[package]] name = "filetime" -version = "0.2.20" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" +checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", - "windows-sys 0.45.0", + "redox_syscall 0.3.5", + "windows-sys 0.48.0", ] [[package]] From d9921e48cafadda9ed7df770941c265a28682d4a Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 6 Aug 2023 16:12:32 +0200 Subject: [PATCH 011/370] Bump parking_lot_core from 0.9.7 to 0.9.8 --- Cargo.lock | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 829f875b7..82bf12892 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -847,7 +847,7 @@ checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall", "windows-sys 0.48.0", ] @@ -1522,15 +1522,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets 0.48.0", ] [[package]] @@ -1752,15 +1752,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - [[package]] name = "redox_syscall" version = "0.3.5" @@ -2130,7 +2121,7 @@ dependencies = [ "autocfg", "cfg-if", "fastrand", - "redox_syscall 0.3.5", + "redox_syscall", "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -3106,7 +3097,7 @@ version = "0.0.20" dependencies = [ "clap", "libc", - "redox_syscall 0.3.5", + "redox_syscall", "uucore", ] From 5c3fb3c53b250ba5a88f4dc161e12ec971de78a6 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 6 Aug 2023 16:15:00 +0200 Subject: [PATCH 012/370] deny.toml: remove redox_syscall from skip list --- deny.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/deny.toml b/deny.toml index 84dae2b98..2db037826 100644 --- a/deny.toml +++ b/deny.toml @@ -80,8 +80,6 @@ skip = [ { name = "windows_x86_64_gnullvm", version = "0.42.2" }, # windows-targets { name = "windows_x86_64_msvc", version = "0.42.2" }, - # tempfile - { name = "redox_syscall", version = "0.3.5" }, # cpp_macros { name = "aho-corasick", version = "0.7.19" }, # various crates From a4f5145445b8452c3969716875ee642e86ad4ce9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 05:03:04 +0000 Subject: [PATCH 013/370] chore(deps): update rust crate crossterm to >=0.27.0 --- Cargo.lock | 42 ++++++++++++++++++++++++------------------ Cargo.toml | 2 +- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82bf12892..68f28a1c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,7 +135,7 @@ version = "0.63.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36d860121800b2a9a94f9b5604b332d5cffb234ce17609ea479d723dbc9d3885" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static", @@ -157,6 +157,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + [[package]] name = "blake2b_simd" version = "1.0.1" @@ -281,7 +287,7 @@ checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" dependencies = [ "anstream", "anstyle", - "bitflags", + "bitflags 1.3.2", "clap_lex", "once_cell", "strsim", @@ -644,11 +650,11 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.26.1" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags", + "bitflags 2.3.3", "crossterm_winapi", "libc", "mio", @@ -660,9 +666,9 @@ dependencies = [ [[package]] name = "crossterm_winapi" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" dependencies = [ "winapi", ] @@ -818,7 +824,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cfeb22a59deb24c3262c43ffcafd1eb807180f371f9fcc99098d181b5d639be" dependencies = [ - "bitflags", + "bitflags 1.3.2", "log", "scopeguard", "uuid", @@ -1120,7 +1126,7 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" dependencies = [ - "bitflags", + "bitflags 1.3.2", "inotify-sys", "libc", ] @@ -1215,7 +1221,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8367585489f01bc55dd27404dcf56b95e6da061a256a666ab23be9ba96a2e587" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", ] @@ -1365,7 +1371,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "static_assertions", @@ -1387,7 +1393,7 @@ version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5738a2795d57ea20abec2d6d76c6081186709c0024187cd5977265eda6598b51" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crossbeam-channel", "filetime", "fsevent-sys", @@ -1475,7 +1481,7 @@ version = "6.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "once_cell", "onig_sys", @@ -1658,7 +1664,7 @@ version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "943ca7f9f29bab5844ecd8fdb3992c5969b6622bb9609b9502fef9b4310e3f1f" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "hex", "lazy_static", @@ -1758,7 +1764,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1877,7 +1883,7 @@ version = "0.36.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -1891,7 +1897,7 @@ version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -1926,7 +1932,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a00576725d21b588213fbd4af84cd7e4cc4304e8e9bd6c0f5a1498a3e2ca6a51" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "once_cell", "reference-counted-singleton", diff --git a/Cargo.toml b/Cargo.toml index 2d03e1f05..2cefec1ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -272,7 +272,7 @@ clap_complete = "4.3" clap_mangen = "0.2" compare = "0.1.0" coz = { version = "0.1.3" } -crossterm = ">=0.26.1" +crossterm = ">=0.27.0" ctrlc = { version = "3.4", features = ["termination"] } exacl = "0.10.0" file_diff = "1.0.0" From 0aa29682d0e079e4e92b6b9eb75413ab30522237 Mon Sep 17 00:00:00 2001 From: John Shin Date: Mon, 7 Aug 2023 00:09:14 -0700 Subject: [PATCH 014/370] seq: display -0 --- src/uu/seq/src/extendedbigint.rs | 12 ++---------- src/uu/seq/src/seq.rs | 9 +++------ 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/uu/seq/src/extendedbigint.rs b/src/uu/seq/src/extendedbigint.rs index bbe64300a..46153bb7d 100644 --- a/src/uu/seq/src/extendedbigint.rs +++ b/src/uu/seq/src/extendedbigint.rs @@ -65,11 +65,7 @@ impl Display for ExtendedBigInt { Self::BigInt(n) => n.fmt(f), Self::Infinity => f32::INFINITY.fmt(f), Self::MinusInfinity => f32::NEG_INFINITY.fmt(f), - Self::MinusZero => { - // FIXME Come up with a way of formatting this with a - // "-" prefix. - 0.fmt(f) - } + Self::MinusZero => "-0".fmt(f), Self::Nan => "nan".fmt(f), } } @@ -206,13 +202,9 @@ mod tests { #[test] fn test_display() { assert_eq!(format!("{}", ExtendedBigInt::BigInt(BigInt::zero())), "0"); + assert_eq!(format!("{}", ExtendedBigInt::MinusZero), "-0"); assert_eq!(format!("{}", ExtendedBigInt::Infinity), "inf"); assert_eq!(format!("{}", ExtendedBigInt::MinusInfinity), "-inf"); assert_eq!(format!("{}", ExtendedBigInt::Nan), "nan"); - // FIXME Come up with a way of displaying negative zero as - // "-0". Currently it displays as just "0". - // - // assert_eq!(format!("{}", ExtendedBigInt::MinusZero), "-0"); - // } } diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index 2e55efa4a..de883fe8a 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -223,16 +223,13 @@ fn write_value_int( value: &ExtendedBigInt, width: usize, pad: bool, - is_first_iteration: bool, ) -> std::io::Result<()> { let value_as_str = if pad { - if *value == ExtendedBigInt::MinusZero && is_first_iteration { - format!("-{value:>0width$}", width = width - 1) + if *value == ExtendedBigInt::MinusZero { + format!("{value:00width$}") } - } else if *value == ExtendedBigInt::MinusZero && is_first_iteration { - format!("-{value}") } else { format!("{value}") }; @@ -347,7 +344,7 @@ fn print_seq_integers( exit(1); } } - None => write_value_int(&mut stdout, &value, padding, pad, is_first_iteration)?, + None => write_value_int(&mut stdout, &value, padding, pad)?, } // TODO Implement augmenting addition. value = value + increment.clone(); From 6b1c4d1fa9c4663ec6f33cb59e2e3f6a8d77abf6 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 7 Aug 2023 15:22:06 +0200 Subject: [PATCH 015/370] seq: remove unused param from write_value_float() --- src/uu/seq/src/seq.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index de883fe8a..dec66a7b1 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -206,7 +206,6 @@ fn write_value_float( value: &ExtendedBigDecimal, width: usize, precision: usize, - _is_first_iteration: bool, ) -> std::io::Result<()> { let value_as_str = if *value == ExtendedBigDecimal::Infinity || *value == ExtendedBigDecimal::MinusInfinity { @@ -279,13 +278,7 @@ fn print_seq( exit(1); } } - None => write_value_float( - &mut stdout, - &value, - padding, - largest_dec, - is_first_iteration, - )?, + None => write_value_float(&mut stdout, &value, padding, largest_dec)?, } // TODO Implement augmenting addition. value = value + increment.clone(); From 5b33670f96a50ebcdf39d5255d433109651c37f5 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 8 Aug 2023 09:05:53 +0200 Subject: [PATCH 016/370] Bump fundu from 1.2.0 to 2.0.0 --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68f28a1c7..6c5f8d556 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -900,18 +900,18 @@ dependencies = [ [[package]] name = "fundu" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34804ed59f10b3a630c79822ebf7370b562b7281028369e9baa40547c17f8bdc" +checksum = "6c04cb831a8dccadfe3774b07cba4574a1ec24974d761510e65d8a543c2d7cb4" dependencies = [ "fundu-core", ] [[package]] name = "fundu-core" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71a99190954ca83bade03ba054799b17a158ea948a6855c6bb8121adb6b49d9f" +checksum = "76a889e633afd839fb5b04fe53adfd588cefe518e71ec8d3c929698c6daf2acd" [[package]] name = "futures" diff --git a/Cargo.toml b/Cargo.toml index 2cefec1ea..365b160dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -280,7 +280,7 @@ filetime = "0.2" fnv = "1.0.7" fs_extra = "1.3.0" fts-sys = "0.2" -fundu = "1.2.0" +fundu = "2.0.0" gcd = "2.3" glob = "0.3.1" half = "2.2" From cef9ab10c38c036994275009636a78c95f483c13 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 8 Aug 2023 09:10:33 +0200 Subject: [PATCH 017/370] sleep: adapt two tests to fundu 2.0.0 --- tests/by-util/test_sleep.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/by-util/test_sleep.rs b/tests/by-util/test_sleep.rs index 13aa882b9..76e98e012 100644 --- a/tests/by-util/test_sleep.rs +++ b/tests/by-util/test_sleep.rs @@ -10,7 +10,7 @@ fn test_invalid_time_interval() { new_ucmd!() .arg("xyz") .fails() - .usage_error("invalid time interval 'xyz': Invalid input: 'xyz' at position 1"); + .usage_error("invalid time interval 'xyz': Invalid input: xyz"); new_ucmd!() .args(&["--", "-1"]) .fails() @@ -211,7 +211,7 @@ fn test_sleep_when_input_has_only_whitespace_then_error(#[case] input: &str) { #[test] fn test_sleep_when_multiple_input_some_with_error_then_shows_all_errors() { - let expected = "invalid time interval 'abc': Invalid input: 'abc' at position 1\n\ + let expected = "invalid time interval 'abc': Invalid input: abc\n\ sleep: invalid time interval '1years': Invalid time unit: 'years' at position 2\n\ sleep: invalid time interval ' ': Found only whitespace in input"; From 256b6bbb23b4145d4fc896d7958027254090c832 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 9 Aug 2023 07:36:03 +0200 Subject: [PATCH 018/370] Bump aho-corasick crates From 0.7.19 to 0.7.20 and from 1.0.1 to 1.0.2 --- Cargo.lock | 14 +++++++------- deny.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c5f8d556..e27a6f894 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,18 +10,18 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "0.7.19" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] @@ -578,7 +578,7 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fdaa01904c12a8989dbfa110b41ef27efc432ac9934f691b9732f01cb64dc01" dependencies = [ - "aho-corasick 0.7.19", + "aho-corasick 0.7.20", "byteorder", "cpp_common", "lazy_static", @@ -1779,7 +1779,7 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" dependencies = [ - "aho-corasick 1.0.1", + "aho-corasick 1.0.2", "memchr", "regex-automata", "regex-syntax", @@ -1791,7 +1791,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" dependencies = [ - "aho-corasick 1.0.1", + "aho-corasick 1.0.2", "memchr", "regex-syntax", ] diff --git a/deny.toml b/deny.toml index 215b65529..6703a6a07 100644 --- a/deny.toml +++ b/deny.toml @@ -81,7 +81,7 @@ skip = [ # windows-targets { name = "windows_x86_64_msvc", version = "0.42.2" }, # cpp_macros - { name = "aho-corasick", version = "0.7.19" }, + { name = "aho-corasick", version = "0.7.20" }, # various crates { name = "syn", version = "1.0.109" }, # various crates From 492c9a459127625b72920b57575a590df7dd6037 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 9 Aug 2023 07:47:30 +0200 Subject: [PATCH 019/370] Bump rustix crates From 0.36.14 to 0.36.15 and from 0.37.19 to 0.37.23 --- Cargo.lock | 16 ++++++++-------- deny.toml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c5f8d556..d956dd697 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1168,7 +1168,7 @@ checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi", "io-lifetimes", - "rustix 0.37.19", + "rustix 0.37.23", "windows-sys 0.48.0", ] @@ -1668,7 +1668,7 @@ dependencies = [ "byteorder", "hex", "lazy_static", - "rustix 0.36.14", + "rustix 0.36.15", ] [[package]] @@ -1879,9 +1879,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.14" +version = "0.36.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62" +checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" dependencies = [ "bitflags 1.3.2", "errno", @@ -1893,9 +1893,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.19" +version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ "bitflags 1.3.2", "errno", @@ -2128,7 +2128,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall", - "rustix 0.37.19", + "rustix 0.37.23", "windows-sys 0.48.0", ] @@ -2147,7 +2147,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" dependencies = [ - "rustix 0.37.19", + "rustix 0.37.23", "windows-sys 0.48.0", ] diff --git a/deny.toml b/deny.toml index 215b65529..75ea567bc 100644 --- a/deny.toml +++ b/deny.toml @@ -59,7 +59,7 @@ highlight = "all" # spell-checker: disable skip = [ # procfs - { name = "rustix", version = "0.36.14" }, + { name = "rustix", version = "0.36.15" }, # rustix { name = "linux-raw-sys", version = "0.1.4" }, # various crates From 09360e6796d1f4c757c9beb53166b2e8b8940b9a Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 9 Aug 2023 16:15:30 +0200 Subject: [PATCH 020/370] mv: remove unnecessary OR in condition --- src/uu/mv/src/mv.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 79245a427..03d3881b1 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -433,9 +433,7 @@ fn rename( let mut backup_path = None; if to.exists() { - if (b.update == UpdateMode::ReplaceIfOlder || b.update == UpdateMode::ReplaceNone) - && b.overwrite == OverwriteMode::Interactive - { + if b.update == UpdateMode::ReplaceIfOlder && b.overwrite == OverwriteMode::Interactive { // `mv -i --update old new` when `new` exists doesn't move anything // and exit with 0 return Ok(()); From e3ea6144cbb11376a4cf84862af200176d281456 Mon Sep 17 00:00:00 2001 From: Rayhan Faizel Date: Thu, 10 Aug 2023 08:33:53 +0530 Subject: [PATCH 021/370] stat: Output error when - and -f are used together. --- src/uu/stat/src/stat.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 69f3c2760..9ffa064b8 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -614,6 +614,10 @@ impl Stater { fn do_stat(&self, file: &OsStr, stdin_is_fifo: bool) -> i32 { let display_name = file.to_string_lossy(); let file = if cfg!(unix) && display_name == "-" { + if self.show_fs { + show_error!("using '-' to denote standard input does not work in file system mode"); + return 1; + } if let Ok(p) = Path::new("/dev/stdin").canonicalize() { p.into_os_string() } else { @@ -622,7 +626,6 @@ impl Stater { } else { OsString::from(file) }; - if self.show_fs { #[cfg(unix)] let p = file.as_bytes(); From 414385926653fc14d1f692e638059b36b5c566ae Mon Sep 17 00:00:00 2001 From: Rayhan Faizel Date: Thu, 10 Aug 2023 08:41:19 +0530 Subject: [PATCH 022/370] tests/stat: Test case for using - and -f together --- tests/by-util/test_stat.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/by-util/test_stat.rs b/tests/by-util/test_stat.rs index 92a8bcd98..d932b35d6 100644 --- a/tests/by-util/test_stat.rs +++ b/tests/by-util/test_stat.rs @@ -304,6 +304,19 @@ fn test_stdin_pipe_fifo2() { .succeeded(); } +#[test] +#[cfg(all(unix, not(target_os = "android")))] +fn test_stdin_with_fs_option() { + // $ stat -f - + new_ucmd!() + .arg("-f") + .arg("-") + .set_stdin(std::process::Stdio::null()) + .fails() + .code_is(1) + .stderr_contains("using '-' to denote standard input does not work in file system mode"); +} + #[test] #[cfg(all( unix, From 122c8c5b80abec7815240c20c54b9d4d9c4de3a3 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 10 Aug 2023 10:38:15 +0200 Subject: [PATCH 023/370] Bump futures from 0.3.25 to 0.3.28 --- Cargo.lock | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6f09b6cb..878fa09f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -915,9 +915,9 @@ checksum = "76a889e633afd839fb5b04fe53adfd588cefe518e71ec8d3c929698c6daf2acd" [[package]] name = "futures" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", @@ -930,9 +930,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -940,15 +940,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-executor" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" dependencies = [ "futures-core", "futures-task", @@ -957,32 +957,32 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.23", ] [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-timer" @@ -992,9 +992,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", From 677df5cb1a1b0ac241ba6d707fa0da18521264a7 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 10 Aug 2023 10:50:49 +0200 Subject: [PATCH 024/370] Bump cpp from 0.5.7 to 0.5.8 --- Cargo.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6f09b6cb..1b40f6a5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -539,44 +539,44 @@ dependencies = [ [[package]] name = "cpp" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec5e86d4f6547f0218ad923d9508244a71ef83b763196e6698b4f70f3595185" +checksum = "43b6a1d47f376a62bbea281408fe331879b9822c1edb8f67320c7cb8d96a02eb" dependencies = [ "cpp_macros", ] [[package]] name = "cpp_build" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f4d303b8ec35fb3afd7e963e2c898117f1e49930becb703e4a7ac528ad2dd0" +checksum = "5b8f839b67a3deba30b58b281b5fca61477a90830beb084c58bdb9bebd227a1a" dependencies = [ "cc", "cpp_common", "lazy_static", "proc-macro2", "regex", - "syn 1.0.109", + "syn 2.0.23", "unicode-xid", ] [[package]] name = "cpp_common" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76071bb9c8c4dd2b5eb209907deab7b031323cf1be3dfdc6ec5d37f4f187d8a1" +checksum = "42d2b968b7b2ac412836e8ce1dfc3dfd5648ae7e8a42fcbbf5bc1d33bb795b0d" dependencies = [ "lazy_static", "proc-macro2", - "syn 1.0.109", + "syn 2.0.23", ] [[package]] name = "cpp_macros" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdaa01904c12a8989dbfa110b41ef27efc432ac9934f691b9732f01cb64dc01" +checksum = "5d36d9acb58020380e756d56a8dfc84d0f6ace423bbd4fedf83992b257b7f147" dependencies = [ "aho-corasick 0.7.20", "byteorder", @@ -584,7 +584,7 @@ dependencies = [ "lazy_static", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.23", ] [[package]] From bdd25c37cfdf5a0c513e4dbfd6f5f5d59f742b7f Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 10 Aug 2023 15:27:20 +0200 Subject: [PATCH 025/370] rm: split prompt_file() into two functions --- src/uu/rm/src/rm.rs | 93 ++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index f2e2050d9..dde1e8595 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -370,7 +370,7 @@ fn handle_dir(path: &Path, options: &Options) -> bool { } fn remove_dir(path: &Path, options: &Options) -> bool { - if prompt_file(path, options, true) { + if prompt_dir(path, options) { if let Ok(mut read_dir) = fs::read_dir(path) { if options.dir || options.recursive { if read_dir.next().is_none() { @@ -415,7 +415,7 @@ fn remove_dir(path: &Path, options: &Options) -> bool { } fn remove_file(path: &Path, options: &Options) -> bool { - if prompt_file(path, options, false) { + if prompt_file(path, options) { match fs::remove_file(path) { Ok(_) => { if options.verbose { @@ -437,8 +437,23 @@ fn remove_file(path: &Path, options: &Options) -> bool { false } +fn prompt_dir(path: &Path, options: &Options) -> bool { + // If interactive is Never we never want to send prompts + if options.interactive == InteractiveMode::Never { + return true; + } + + // We can't use metadata.permissions.readonly for directories because it only works on files + // So we have to handle whether a directory is writable manually + if let Ok(metadata) = fs::metadata(path) { + handle_writable_directory(path, options, &metadata) + } else { + true + } +} + #[allow(clippy::cognitive_complexity)] -fn prompt_file(path: &Path, options: &Options, is_dir: bool) -> bool { +fn prompt_file(path: &Path, options: &Options) -> bool { // If interactive is Never we never want to send prompts if options.interactive == InteractiveMode::Never { return true; @@ -451,58 +466,48 @@ fn prompt_file(path: &Path, options: &Options, is_dir: bool) -> bool { } } } - if is_dir { - // We can't use metadata.permissions.readonly for directories because it only works on files - // So we have to handle whether a directory is writable on not manually - if let Ok(metadata) = fs::metadata(path) { - handle_writable_directory(path, options, &metadata) - } else { - true - } - } else { - // File::open(path) doesn't open the file in write mode so we need to use file options to open it in also write mode to check if it can written too - match File::options().read(true).write(true).open(path) { - Ok(file) => { - if let Ok(metadata) = file.metadata() { - if metadata.permissions().readonly() { - if metadata.len() == 0 { - prompt_yes!( - "remove write-protected regular empty file {}?", - path.quote() - ) - } else { - prompt_yes!("remove write-protected regular file {}?", path.quote()) - } - } else if options.interactive == InteractiveMode::Always { - if metadata.len() == 0 { - prompt_yes!("remove regular empty file {}?", path.quote()) - } else { - prompt_yes!("remove file {}?", path.quote()) - } + // File::open(path) doesn't open the file in write mode so we need to use file options to open it in also write mode to check if it can written too + match File::options().read(true).write(true).open(path) { + Ok(file) => { + if let Ok(metadata) = file.metadata() { + if metadata.permissions().readonly() { + if metadata.len() == 0 { + prompt_yes!( + "remove write-protected regular empty file {}?", + path.quote() + ) } else { - true + prompt_yes!("remove write-protected regular file {}?", path.quote()) + } + } else if options.interactive == InteractiveMode::Always { + if metadata.len() == 0 { + prompt_yes!("remove regular empty file {}?", path.quote()) + } else { + prompt_yes!("remove file {}?", path.quote()) } } else { true } + } else { + true } - Err(err) => { - if err.kind() == ErrorKind::PermissionDenied { - if let Ok(metadata) = fs::metadata(path) { - if metadata.len() == 0 { - prompt_yes!( - "remove write-protected regular empty file {}?", - path.quote() - ) - } else { - prompt_yes!("remove write-protected regular file {}?", path.quote()) - } + } + Err(err) => { + if err.kind() == ErrorKind::PermissionDenied { + if let Ok(metadata) = fs::metadata(path) { + if metadata.len() == 0 { + prompt_yes!( + "remove write-protected regular empty file {}?", + path.quote() + ) } else { prompt_yes!("remove write-protected regular file {}?", path.quote()) } } else { - true + prompt_yes!("remove write-protected regular file {}?", path.quote()) } + } else { + true } } } From 113972aa44482b4636fc4c259425a4211aaf3da2 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 10 Aug 2023 15:38:59 +0200 Subject: [PATCH 026/370] rm: replace "if" with "match" in prompt_file() --- src/uu/rm/src/rm.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index dde1e8595..fb4a2149e 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -494,17 +494,14 @@ fn prompt_file(path: &Path, options: &Options) -> bool { } Err(err) => { if err.kind() == ErrorKind::PermissionDenied { - if let Ok(metadata) = fs::metadata(path) { - if metadata.len() == 0 { + match fs::metadata(path) { + Ok(metadata) if metadata.len() == 0 => { prompt_yes!( "remove write-protected regular empty file {}?", path.quote() ) - } else { - prompt_yes!("remove write-protected regular file {}?", path.quote()) } - } else { - prompt_yes!("remove write-protected regular file {}?", path.quote()) + _ => prompt_yes!("remove write-protected regular file {}?", path.quote()), } } else { true From 7c58ec081dd31485639fa72ff1ed713dac35b651 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Thu, 10 Aug 2023 23:29:25 +0200 Subject: [PATCH 027/370] chore(deps): update clap, tempfile & is_terminal (all are rustix-based) --- Cargo.lock | 58 +++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db5604f7f..161949e8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,22 +272,21 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.0" +version = "4.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" +checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.0" +version = "4.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" +checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" dependencies = [ "anstream", "anstyle", - "bitflags 1.3.2", "clap_lex", "once_cell", "strsim", @@ -832,12 +831,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.8.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", -] +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] name = "file_diff" @@ -1140,15 +1136,6 @@ dependencies = [ "libc", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "io-lifetimes" version = "1.0.11" @@ -1162,13 +1149,12 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "io-lifetimes", - "rustix 0.37.23", + "rustix 0.38.8", "windows-sys 0.48.0", ] @@ -1271,6 +1257,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" + [[package]] name = "lock_api" version = "0.4.9" @@ -1905,6 +1897,19 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustix" +version = "0.38.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +dependencies = [ + "bitflags 2.3.3", + "errno", + "libc", + "linux-raw-sys 0.4.5", + "windows-sys 0.48.0", +] + [[package]] name = "same-file" version = "1.0.6" @@ -2120,15 +2125,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.6.0" +version = "3.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" dependencies = [ - "autocfg", "cfg-if", "fastrand", "redox_syscall", - "rustix 0.37.23", + "rustix 0.38.8", "windows-sys 0.48.0", ] From a4e8be445652be5d79dcfb3bc485b3bbf8a39299 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Thu, 10 Aug 2023 23:29:43 +0200 Subject: [PATCH 028/370] chore(deps): update deny.toml --- deny.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deny.toml b/deny.toml index 0df03fb2d..f587f0720 100644 --- a/deny.toml +++ b/deny.toml @@ -62,6 +62,9 @@ skip = [ { name = "rustix", version = "0.36.15" }, # rustix { name = "linux-raw-sys", version = "0.1.4" }, + { name = "linux-raw-sys", version = "0.3.8" }, + # tempfile + { name = "rustix", version = "0.37.23" }, # various crates { name = "windows-sys", version = "0.45.0" }, # windows-sys From 252b3754b514443aac477194067ae75f1b5abf3d Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Fri, 11 Aug 2023 12:35:29 +0200 Subject: [PATCH 029/370] chore(deps): update is-terminal and tempfile in Cargo.toml --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 365b160dd..48604fcde 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -285,7 +285,7 @@ gcd = "2.3" glob = "0.3.1" half = "2.2" indicatif = "0.17" -is-terminal = "0.4.7" +is-terminal = "0.4.9" itertools = "0.11.0" libc = "0.2.147" lscolors = { version = "0.15.0", default-features = false, features = [ @@ -318,7 +318,7 @@ self_cell = "1.0.1" selinux = "0.4" signal-hook = "0.3.17" smallvec = { version = "1.11", features = ["union"] } -tempfile = "3.6.0" +tempfile = "3.7.1" term_grid = "0.1.5" terminal_size = "0.2.6" textwrap = { version = "0.16.0", features = ["terminal_size"] } From ffa08f4741e6c05fc61fdb019b142d1583548ad3 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Fri, 11 Aug 2023 19:35:35 +0200 Subject: [PATCH 030/370] cp: make more types public and add more documentation --- src/uu/cp/src/copydir.rs | 4 +- src/uu/cp/src/cp.rs | 129 ++++++++++++++++++++++++++------------- 2 files changed, 90 insertions(+), 43 deletions(-) diff --git a/src/uu/cp/src/copydir.rs b/src/uu/cp/src/copydir.rs index aaeb73f5a..818b0d222 100644 --- a/src/uu/cp/src/copydir.rs +++ b/src/uu/cp/src/copydir.rs @@ -25,7 +25,7 @@ use walkdir::{DirEntry, WalkDir}; use crate::{ aligned_ancestors, context_for, copy_attributes, copy_file, copy_link, preserve_hardlinks, - CopyResult, Error, Options, TargetSlice, + CopyResult, Error, Options, }; /// Ensure a Windows path starts with a `\\?`. @@ -307,7 +307,7 @@ fn copy_direntry( pub(crate) fn copy_directory( progress_bar: &Option, root: &Path, - target: &TargetSlice, + target: &Path, options: &Options, symlinked_files: &mut HashSet, source_in_command_line: bool, diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index de9dd1c91..08ba4f1b3 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -9,7 +9,7 @@ // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. -// spell-checker:ignore (ToDO) copydir ficlone fiemap ftruncate linkgs lstat nlink nlinks pathbuf pwrite reflink strs xattrs symlinked deduplicated advcpmv +// spell-checker:ignore (ToDO) copydir ficlone fiemap ftruncate linkgs lstat nlink nlinks pathbuf pwrite reflink strs xattrs symlinked deduplicated advcpmv nushell use quick_error::quick_error; use std::borrow::Cow; @@ -51,6 +51,7 @@ use crate::copydir::copy_directory; mod copydir; mod platform; + quick_error! { #[derive(Debug)] pub enum Error { @@ -108,12 +109,8 @@ impl UError for Error { } pub type CopyResult = Result; -pub type Source = PathBuf; -pub type SourceSlice = Path; -pub type Target = PathBuf; -pub type TargetSlice = Path; -/// Specifies whether when overwrite files +/// Specifies how to overwrite files. #[derive(Clone, Copy, Eq, PartialEq)] pub enum ClobberMode { Force, @@ -121,7 +118,7 @@ pub enum ClobberMode { Standard, } -/// Specifies whether when overwrite files +/// Specifies whether files should be overwritten. #[derive(Clone, Copy, Eq, PartialEq)] pub enum OverwriteMode { /// [Default] Always overwrite existing files @@ -148,12 +145,13 @@ pub enum SparseMode { Never, } -/// Specifies the expected file type of copy target +/// The expected file type of copy target pub enum TargetType { Directory, File, } +/// Copy action to perform pub enum CopyMode { Link, SymLink, @@ -162,6 +160,7 @@ pub enum CopyMode { AttrOnly, } +/// Preservation settings for various attributes #[derive(Debug)] pub struct Attributes { #[cfg(unix)] @@ -209,30 +208,76 @@ impl Preserve { } } -/// Re-usable, extensible copy options +/// Options for the `cp` command +/// +/// All options are public so that the options can be programmatically +/// constructed by other crates, such as nushell. That means that this struct +/// is part of our public API. It should therefore not be changed without good +/// reason. +/// +/// The fields are documented with the arguments that determine their value. #[allow(dead_code)] pub struct Options { - attributes_only: bool, - backup: BackupMode, - copy_contents: bool, - cli_dereference: bool, - copy_mode: CopyMode, - dereference: bool, - no_target_dir: bool, - one_file_system: bool, - overwrite: OverwriteMode, - parents: bool, - sparse_mode: SparseMode, - strip_trailing_slashes: bool, - reflink_mode: ReflinkMode, - attributes: Attributes, - recursive: bool, - backup_suffix: String, - target_dir: Option, - update: UpdateMode, - debug: bool, - verbose: bool, - progress_bar: bool, + /// `--attributes-only` + pub attributes_only: bool, + /// `--backup[=CONTROL]`, `-b` + pub backup: BackupMode, + /// `--copy-contents` + pub copy_contents: bool, + /// `-H` + pub cli_dereference: bool, + /// Determines the type of copying that should be done + /// + /// Set by the following arguments: + /// - `-l`, `--link`: [`CopyMode::Link`] + /// - `-s`, `--symbolic-link`: [`CopyMode::SymLink`] + /// - `-u`, `--update[=WHEN]`: [`CopyMode::Update`] + /// - `--attributes-only`: [`CopyMode::AttrOnly`] + /// - otherwise: [`CopyMode::Copy`] + pub copy_mode: CopyMode, + /// `-L`, `--dereference` + pub dereference: bool, + /// `-T`, `--no-target-dir` + pub no_target_dir: bool, + /// `-x`, `--one-file-system` + pub one_file_system: bool, + /// Specifies what to do with an existing destination + /// + /// Set by the following arguments: + /// - `-i`, `--interactive`: [`OverwriteMode::Interactive`] + /// - `-n`, `--no-clobber`: [`OverwriteMode::NoClobber`] + /// - otherwise: [`OverwriteMode::Clobber`] + /// + /// The `Interactive` and `Clobber` variants have a [`ClobberMode`] argument, + /// set by the following arguments: + /// - `-f`, `--force`: [`ClobberMode::Force`] + /// - `--remove-destination`: [`ClobberMode::RemoveDestination`] + /// - otherwise: [`ClobberMode::Standard`] + pub overwrite: OverwriteMode, + /// `--parents` + pub parents: bool, + /// `--sparse[=WHEN]` + pub sparse_mode: SparseMode, + /// `--strip-trailing-slashes` + pub strip_trailing_slashes: bool, + /// `--reflink[=WHEN]` + pub reflink_mode: ReflinkMode, + /// `--preserve=[=ATTRIBUTE_LIST]` and `--no-preserve=ATTRIBUTE_LIST` + pub attributes: Attributes, + /// `-R`, `-r`, `--recursive` + pub recursive: bool, + /// `-S`, `--suffix` + pub backup_suffix: String, + /// `-t`, `--target-directory` + pub target_dir: Option, + /// `--update[=UPDATE]` + pub update: UpdateMode, + /// `--debug` + pub debug: bool, + /// `-v`, `--verbose` + pub verbose: bool, + /// `-g`, `--progress` + pub progress_bar: bool, } /// Enum representing various debug states of the offload and reflink actions. @@ -1000,7 +1045,7 @@ impl TargetType { /// /// Treat target as a dir if we have multiple sources or the target /// exists and already is a directory - fn determine(sources: &[Source], target: &TargetSlice) -> Self { + fn determine(sources: &[PathBuf], target: &Path) -> Self { if sources.len() > 1 || target.is_dir() { Self::Directory } else { @@ -1010,7 +1055,10 @@ impl TargetType { } /// Returns tuple of (Source paths, Target) -fn parse_path_args(mut paths: Vec, options: &Options) -> CopyResult<(Vec, Target)> { +fn parse_path_args( + mut paths: Vec, + options: &Options, +) -> CopyResult<(Vec, PathBuf)> { if paths.is_empty() { // No files specified return Err("missing file operand".into()); @@ -1122,14 +1170,13 @@ fn show_error_if_needed(error: &Error) { } } -/// Copy all `sources` to `target`. Returns an -/// `Err(Error::NotAllFilesCopied)` if at least one non-fatal error was -/// encountered. +/// Copy all `sources` to `target`. /// -/// Behavior depends on path`options`, see [`Options`] for details. +/// Returns an `Err(Error::NotAllFilesCopied)` if at least one non-fatal error +/// was encountered. /// -/// [`Options`]: ./struct.Options.html -fn copy(sources: &[Source], target: &TargetSlice, options: &Options) -> CopyResult<()> { +/// Behavior is determined by the `options` parameter, see [`Options`] for details. +pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult<()> { let target_type = TargetType::determine(sources, target); verify_target_type(target, &target_type)?; @@ -1192,7 +1239,7 @@ fn copy(sources: &[Source], target: &TargetSlice, options: &Options) -> CopyResu fn construct_dest_path( source_path: &Path, - target: &TargetSlice, + target: &Path, target_type: &TargetType, options: &Options, ) -> CopyResult { @@ -1223,8 +1270,8 @@ fn construct_dest_path( fn copy_source( progress_bar: &Option, - source: &SourceSlice, - target: &TargetSlice, + source: &Path, + target: &Path, target_type: &TargetType, options: &Options, symlinked_files: &mut HashSet, From 631b9892f67873396286863a2d64833e25a7e020 Mon Sep 17 00:00:00 2001 From: John Shin Date: Fri, 11 Aug 2023 18:36:08 -0700 Subject: [PATCH 031/370] split: loop over chars and remove char_from_digit function --- tests/by-util/test_split.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 35e5ebb05..de1bb9cdf 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -375,11 +375,6 @@ fn file_read(at: &AtPath, filename: &str) -> String { s } -// TODO Use char::from_digit() in Rust v1.51.0 or later. -fn char_from_digit(n: usize) -> char { - (b'a' + n as u8) as char -} - /// Test for the default suffix length behavior: dynamically increasing size. #[test] fn test_alphabetic_dynamic_suffix_length() { @@ -396,9 +391,9 @@ fn test_alphabetic_dynamic_suffix_length() { // ucmd.args(&["-b", "1", "sixhundredfiftyonebytes.txt"]) .succeeds(); - for i in 0..25 { - for j in 0..26 { - let filename = format!("x{}{}", char_from_digit(i), char_from_digit(j),); + for i in b'a'..=b'y' { + for j in b'a'..=b'z' { + let filename = format!("x{}{}", i as char, j as char); let contents = file_read(&at, &filename); assert_eq!(contents, "a"); } From df0a816f07f41ac1f910c5de4215f91f047afb2b Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 12 Aug 2023 13:38:45 +0200 Subject: [PATCH 032/370] Bump js-sys from 0.3.60 to 0.3.64 --- Cargo.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 161949e8a..7dbb497ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1175,9 +1175,9 @@ checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -3357,9 +3357,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3367,24 +3367,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.23", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3392,22 +3392,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.23", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "which" From 08e21e183b6952e21824f492e5d21a5526fac513 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 12 Aug 2023 14:36:22 +0200 Subject: [PATCH 033/370] nl: re-add handling for -p/--no-renumber --- src/uu/nl/src/nl.rs | 4 +++- tests/by-util/test_nl.rs | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 85ddb1b41..95121eb08 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -297,7 +297,9 @@ fn nl(reader: &mut BufReader, settings: &Settings) -> UResult<()> { if let Some(new_style) = new_numbering_style { current_numbering_style = new_style; - line_no = settings.starting_line_number; + if settings.renumber { + line_no = settings.starting_line_number; + } println!(); } else { let is_line_numbered = match current_numbering_style { diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index ab27fe148..fb04ba9ae 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -77,7 +77,11 @@ fn test_sections_and_styles() { #[test] fn test_no_renumber() { for arg in ["-p", "--no-renumber"] { - new_ucmd!().arg(arg).succeeds(); + new_ucmd!() + .arg(arg) + .pipe_in("a\n\\:\\:\nb") + .succeeds() + .stdout_is(" 1\ta\n\n 2\tb\n"); } } From 5f4bc812fb6f2cd9499740e4ac6225e777e3949e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 13 Aug 2023 10:02:53 +0000 Subject: [PATCH 034/370] chore(deps): update rust crate rstest to 0.18.2 --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7dbb497ed..bd15fc341 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1817,9 +1817,9 @@ checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316" [[package]] name = "rstest" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b96577ca10cb3eade7b337eb46520108a67ca2818a24d0b63f41fd62bc9651c" +checksum = "97eeab2f3c0a199bc4be135c36c924b6590b88c377d416494288c14f2db30199" dependencies = [ "futures", "futures-timer", @@ -1829,9 +1829,9 @@ dependencies = [ [[package]] name = "rstest_macros" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225e674cf31712b8bb15fdbca3ec0c1b9d825c5a24407ff2b7e005fb6a29ba03" +checksum = "d428f8247852f894ee1be110b375111b586d4fa431f6c46e64ba5a0dcccbe605" dependencies = [ "cfg-if", "glob", diff --git a/Cargo.toml b/Cargo.toml index 48604fcde..c3413d86b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -311,7 +311,7 @@ rand_core = "0.6" rayon = "1.7" redox_syscall = "0.3" regex = "1.9.3" -rstest = "0.18.1" +rstest = "0.18.2" rust-ini = "0.19.0" same-file = "1.0.6" self_cell = "1.0.1" From d5ab7bbacdec09c3aadd49c107ca744970c60e0c Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 13 Aug 2023 14:09:15 +0200 Subject: [PATCH 035/370] nl: implement TryFrom<&str> for NumberingStyle --- src/uu/nl/src/helper.rs | 76 +++++++++++----------------------------- src/uu/nl/src/nl.rs | 17 +++++++++ tests/by-util/test_nl.rs | 40 ++++++++++++++++++++- 3 files changed, 77 insertions(+), 56 deletions(-) diff --git a/src/uu/nl/src/helper.rs b/src/uu/nl/src/helper.rs index a9dbbad79..39d13d565 100644 --- a/src/uu/nl/src/helper.rs +++ b/src/uu/nl/src/helper.rs @@ -2,25 +2,6 @@ use crate::options; -// parse_style parses a style string into a NumberingStyle. -fn parse_style(chars: &[char]) -> Result { - if chars.len() == 1 && chars[0] == 'a' { - Ok(crate::NumberingStyle::All) - } else if chars.len() == 1 && chars[0] == 't' { - Ok(crate::NumberingStyle::NonEmpty) - } else if chars.len() == 1 && chars[0] == 'n' { - Ok(crate::NumberingStyle::None) - } else if chars.len() > 1 && chars[0] == 'p' { - let s: String = chars[1..].iter().cloned().collect(); - match regex::Regex::new(&s) { - Ok(re) => Ok(crate::NumberingStyle::Regex(Box::new(re))), - Err(_) => Err(String::from("Illegal regular expression")), - } - } else { - Err(String::from("Illegal style encountered")) - } -} - // parse_options loads the options into the settings, returning an array of // error messages. #[allow(clippy::cognitive_complexity)] @@ -35,47 +16,32 @@ pub fn parse_options(settings: &mut crate::Settings, opts: &clap::ArgMatches) -> .get_one::(options::NUMBER_FORMAT) .map(Into::into) .unwrap_or_default(); - match opts.get_one::(options::BODY_NUMBERING) { + match opts + .get_one::(options::HEADER_NUMBERING) + .map(String::as_str) + .map(TryInto::try_into) + { None => {} - Some(val) => { - let chars: Vec = val.chars().collect(); - match parse_style(&chars) { - Ok(s) => { - settings.body_numbering = s; - } - Err(message) => { - errs.push(message); - } - } - } + Some(Ok(style)) => settings.header_numbering = style, + Some(Err(message)) => errs.push(message.to_string()), } - match opts.get_one::(options::FOOTER_NUMBERING) { + match opts + .get_one::(options::BODY_NUMBERING) + .map(String::as_str) + .map(TryInto::try_into) + { None => {} - Some(val) => { - let chars: Vec = val.chars().collect(); - match parse_style(&chars) { - Ok(s) => { - settings.footer_numbering = s; - } - Err(message) => { - errs.push(message); - } - } - } + Some(Ok(style)) => settings.body_numbering = style, + Some(Err(message)) => errs.push(message.to_string()), } - match opts.get_one::(options::HEADER_NUMBERING) { + match opts + .get_one::(options::FOOTER_NUMBERING) + .map(String::as_str) + .map(TryInto::try_into) + { None => {} - Some(val) => { - let chars: Vec = val.chars().collect(); - match parse_style(&chars) { - Ok(s) => { - settings.header_numbering = s; - } - Err(message) => { - errs.push(message); - } - } - } + Some(Ok(style)) => settings.footer_numbering = style, + Some(Err(message)) => errs.push(message.to_string()), } match opts.get_one::(options::NUMBER_WIDTH) { None => {} diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 95121eb08..115b4efa9 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -71,6 +71,23 @@ enum NumberingStyle { Regex(Box), } +impl TryFrom<&str> for NumberingStyle { + type Error = String; + + fn try_from(s: &str) -> Result { + match s { + "a" => Ok(Self::All), + "t" => Ok(Self::NonEmpty), + "n" => Ok(Self::None), + _ if s.starts_with('p') => match regex::Regex::new(&s[1..]) { + Ok(re) => Ok(Self::Regex(Box::new(re))), + Err(_) => Err(String::from("invalid regular expression")), + }, + _ => Err(format!("invalid numbering style: '{s}'")), + } + } +} + // NumberFormat specifies how line numbers are output within their allocated // space. They are justified to the left or right, in the latter case with // the option of having all unused space to its left turned into leading zeroes. diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index fb04ba9ae..e178950b3 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -1,4 +1,4 @@ -// spell-checker:ignore iinvalid linvalid ninvalid vinvalid winvalid +// spell-checker:ignore binvalid finvalid hinvalid iinvalid linvalid ninvalid vinvalid winvalid use crate::common::util::TestScenario; #[test] @@ -426,3 +426,41 @@ fn test_numbering_matched_lines() { } } } + +#[test] +fn test_invalid_numbering() { + let invalid_args = [ + "-hinvalid", + "--header-numbering=invalid", + "-binvalid", + "--body-numbering=invalid", + "-finvalid", + "--footer-numbering=invalid", + ]; + + for invalid_arg in invalid_args { + new_ucmd!() + .arg(invalid_arg) + .fails() + .stderr_contains("invalid numbering style: 'invalid'"); + } +} + +#[test] +fn test_invalid_regex_numbering() { + let invalid_args = [ + "-hp[", + "--header-numbering=p[", + "-bp[", + "--body-numbering=p[", + "-fp[", + "--footer-numbering=p[", + ]; + + for invalid_arg in invalid_args { + new_ucmd!() + .arg(invalid_arg) + .fails() + .stderr_contains("invalid regular expression"); + } +} From 946e1bb2d128e57ad23fb78cf180be2659fec3d9 Mon Sep 17 00:00:00 2001 From: Bluelief <33663724+bluelief@users.noreply.github.com> Date: Mon, 14 Aug 2023 22:44:55 +0900 Subject: [PATCH 036/370] fmt: fix panic on width argument --- src/uu/fmt/src/fmt.rs | 2 +- tests/by-util/test_fmt.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index f112d1b07..bf08fbc3e 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -168,7 +168,7 @@ fn parse_arguments(args: impl uucore::Args) -> UResult<(Vec, FmtOptions) )); } }; - if !matches.get_flag(OPT_WIDTH) { + if !matches.contains_id(OPT_WIDTH) { fmt_opts.width = cmp::max( fmt_opts.goal * 100 / DEFAULT_GOAL_TO_WIDTH_RATIO, fmt_opts.goal + 3, diff --git a/tests/by-util/test_fmt.rs b/tests/by-util/test_fmt.rs index afce9acd8..c2f67e136 100644 --- a/tests/by-util/test_fmt.rs +++ b/tests/by-util/test_fmt.rs @@ -43,3 +43,34 @@ fn test_fmt_width_too_big() { .stderr_is("fmt: invalid width: '2501': Numerical result out of range\n"); } } + +#[test] +fn test_fmt_goal() { + for param in ["-g", "--goal"] { + new_ucmd!() + .args(&["one-word-per-line.txt", param, "7"]) + .succeeds() + .stdout_is("this is\na file\nwith one\nword per\nline\n"); + } +} + +#[test] +fn test_fmt_goal_too_big() { + for param in ["-g", "--goal"] { + new_ucmd!() + .args(&["one-word-per-line.txt", "--width=75", param, "76"]) + .fails() + .code_is(1) + .stderr_is("fmt: GOAL cannot be greater than WIDTH.\n"); + } +} + +#[test] +fn test_fmt_set_goal_not_contain_width() { + for param in ["-g", "--goal"] { + new_ucmd!() + .args(&["one-word-per-line.txt", param, "74"]) + .succeeds() + .stdout_is("this is a file with one word per line\n"); + } +} From a7ab660a3859b7b24f3b8a46dc2675a0aa717bf4 Mon Sep 17 00:00:00 2001 From: Bluelief <33663724+bluelief@users.noreply.github.com> Date: Tue, 15 Aug 2023 00:43:32 +0900 Subject: [PATCH 037/370] fmt: change test to ignore and fix test output - fix test to get same result as GNU fmt --- tests/by-util/test_fmt.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/by-util/test_fmt.rs b/tests/by-util/test_fmt.rs index c2f67e136..84a19d34d 100644 --- a/tests/by-util/test_fmt.rs +++ b/tests/by-util/test_fmt.rs @@ -44,13 +44,14 @@ fn test_fmt_width_too_big() { } } +#[ignore] #[test] fn test_fmt_goal() { for param in ["-g", "--goal"] { new_ucmd!() .args(&["one-word-per-line.txt", param, "7"]) .succeeds() - .stdout_is("this is\na file\nwith one\nword per\nline\n"); + .stdout_is("this is a\nfile with one\nword per line\n"); } } From 16bd3f35c1b82265a4400fad8015e0b6f3650ad8 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 15 Aug 2023 08:02:42 +0200 Subject: [PATCH 038/370] Bump windows-targets from 0.48.0 to 0.48.2 --- Cargo.lock | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd15fc341..8ae14a1ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1528,7 +1528,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.0", + "windows-targets 0.48.2", ] [[package]] @@ -3475,7 +3475,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.2", ] [[package]] @@ -3495,17 +3495,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "d1eeca1c172a285ee6c2c84c341ccea837e7c01b12fbb2d0fe3c9e550ce49ec8" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.2", + "windows_aarch64_msvc 0.48.2", + "windows_i686_gnu 0.48.2", + "windows_i686_msvc 0.48.2", + "windows_x86_64_gnu 0.48.2", + "windows_x86_64_gnullvm 0.48.2", + "windows_x86_64_msvc 0.48.2", ] [[package]] @@ -3516,9 +3516,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "b10d0c968ba7f6166195e13d593af609ec2e3d24f916f081690695cf5eaffb2f" [[package]] name = "windows_aarch64_msvc" @@ -3528,9 +3528,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "571d8d4e62f26d4932099a9efe89660e8bd5087775a2ab5cdd8b747b811f1058" [[package]] name = "windows_i686_gnu" @@ -3540,9 +3540,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "2229ad223e178db5fbbc8bd8d3835e51e566b8474bfca58d2e6150c48bb723cd" [[package]] name = "windows_i686_msvc" @@ -3552,9 +3552,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "600956e2d840c194eedfc5d18f8242bc2e17c7775b6684488af3a9fff6fe3287" [[package]] name = "windows_x86_64_gnu" @@ -3564,9 +3564,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "ea99ff3f8b49fb7a8e0d305e5aec485bd068c2ba691b6e277d29eaeac945868a" [[package]] name = "windows_x86_64_gnullvm" @@ -3576,9 +3576,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "8f1a05a1ece9a7a0d5a7ccf30ba2c33e3a61a30e042ffd247567d1de1d94120d" [[package]] name = "windows_x86_64_msvc" @@ -3588,9 +3588,9 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "d419259aba16b663966e29e6d7c6ecfa0bb8425818bb96f6f1f3c3eb71a6e7b9" [[package]] name = "xattr" From 597f51670cc37306f083fccc3d60813e63b1e454 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Wed, 16 Aug 2023 19:04:18 +0200 Subject: [PATCH 039/370] cp: refactor attribute parsing Clean up the parsing of the attributes to preserve. There are several improvements here: Preserve now uses `max` from Ord, the `max` method is now called `union` and does not mutate, the parse loop is extracted into a new function `parse_iter`, the `all` and `none` methods are replaced with const values. Finally all fields of Attributes are now public. --- src/uu/cp/src/cp.rs | 228 +++++++++++++++++++++++--------------------- 1 file changed, 121 insertions(+), 107 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 08ba4f1b3..e0a40d56e 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -13,6 +13,7 @@ use quick_error::quick_error; use std::borrow::Cow; +use std::cmp::Ordering; use std::collections::HashSet; use std::env; #[cfg(not(windows))] @@ -161,49 +162,53 @@ pub enum CopyMode { } /// Preservation settings for various attributes +/// +/// It should be derived from options as follows: +/// +/// - if there is a list of attributes to preserve (i.e. `--preserve=ATTR_LIST`) parse that list with [`Attributes::parse_iter`], +/// - if `-p` or `--preserve` is given without arguments, use [`Attributes::DEFAULT`], +/// - if `-a`/`--archive` is passed, use [`Attributes::ALL`], +/// - if `-d` is passed use [`Attributes::LINKS`], +/// - otherwise, use [`Attributes::NONE`]. +/// +/// For full compatibility with GNU, these options should also combine. We +/// currently only do a best effort imitation of that behavior, because it is +/// difficult to achieve in clap, especially with `--no-preserve`. #[derive(Debug)] pub struct Attributes { #[cfg(unix)] - ownership: Preserve, - mode: Preserve, - timestamps: Preserve, - context: Preserve, - links: Preserve, - xattr: Preserve, + pub ownership: Preserve, + pub mode: Preserve, + pub timestamps: Preserve, + pub context: Preserve, + pub links: Preserve, + pub xattr: Preserve, } -impl Attributes { - pub(crate) fn max(&mut self, other: Self) { - #[cfg(unix)] - { - self.ownership = self.ownership.max(other.ownership); - } - self.mode = self.mode.max(other.mode); - self.timestamps = self.timestamps.max(other.timestamps); - self.context = self.context.max(other.context); - self.links = self.links.max(other.links); - self.xattr = self.xattr.max(other.xattr); - } -} - -#[derive(Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Preserve { No, Yes { required: bool }, } -impl Preserve { - /// Preservation level should only increase, with no preservation being the lowest option, - /// preserve but don't require - middle, and preserve and require - top. - pub(crate) fn max(&self, other: Self) -> Self { +impl PartialOrd for Preserve { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Preserve { + fn cmp(&self, other: &Self) -> Ordering { match (self, other) { - (Self::Yes { required: true }, _) | (_, Self::Yes { required: true }) => { - Self::Yes { required: true } - } - (Self::Yes { required: false }, _) | (_, Self::Yes { required: false }) => { - Self::Yes { required: false } - } - _ => Self::No, + (Self::No, Self::No) => Ordering::Equal, + (Self::Yes { .. }, Self::No) => Ordering::Greater, + (Self::No, Self::Yes { .. }) => Ordering::Less, + ( + Self::Yes { required: req_self }, + Self::Yes { + required: req_other, + }, + ) => req_self.cmp(req_other), } } } @@ -786,67 +791,90 @@ impl CopyMode { } impl Attributes { + pub const ALL: Self = Self { + #[cfg(unix)] + ownership: Preserve::Yes { required: true }, + mode: Preserve::Yes { required: true }, + timestamps: Preserve::Yes { required: true }, + context: { + #[cfg(feature = "feat_selinux")] + { + Preserve::Yes { required: false } + } + #[cfg(not(feature = "feat_selinux"))] + { + Preserve::No + } + }, + links: Preserve::Yes { required: true }, + xattr: Preserve::Yes { required: false }, + }; + + pub const NONE: Self = Self { + #[cfg(unix)] + ownership: Preserve::No, + mode: Preserve::No, + timestamps: Preserve::No, + context: Preserve::No, + links: Preserve::No, + xattr: Preserve::No, + }; + // TODO: ownership is required if the user is root, for non-root users it's not required. - // See: https://github.com/coreutils/coreutils/blob/master/src/copy.c#L3181 + pub const DEFAULT: Self = Self { + #[cfg(unix)] + ownership: Preserve::Yes { required: true }, + mode: Preserve::Yes { required: true }, + timestamps: Preserve::Yes { required: true }, + ..Self::NONE + }; - fn all() -> Self { + pub const LINKS: Self = Self { + links: Preserve::Yes { required: true }, + ..Self::NONE + }; + + pub fn union(self, other: &Self) -> Self { Self { #[cfg(unix)] - ownership: Preserve::Yes { required: true }, - mode: Preserve::Yes { required: true }, - timestamps: Preserve::Yes { required: true }, - context: { - #[cfg(feature = "feat_selinux")] - { - Preserve::Yes { required: false } - } - #[cfg(not(feature = "feat_selinux"))] - { - Preserve::No - } - }, - links: Preserve::Yes { required: true }, - xattr: Preserve::Yes { required: false }, + ownership: self.ownership.max(other.ownership), + context: self.context.max(other.context), + timestamps: self.timestamps.max(other.timestamps), + mode: self.mode.max(other.mode), + links: self.links.max(other.links), + xattr: self.xattr.max(other.xattr), } } - fn default() -> Self { - Self { - #[cfg(unix)] - ownership: Preserve::Yes { required: true }, - mode: Preserve::Yes { required: true }, - timestamps: Preserve::Yes { required: true }, - context: Preserve::No, - links: Preserve::No, - xattr: Preserve::No, - } - } - - fn none() -> Self { - Self { - #[cfg(unix)] - ownership: Preserve::No, - mode: Preserve::No, - timestamps: Preserve::No, - context: Preserve::No, - links: Preserve::No, - xattr: Preserve::No, + pub fn parse_iter(values: impl Iterator) -> Result + where + T: AsRef, + { + let mut new = Self::NONE; + for value in values { + new = new.union(&Self::parse_single_string(value.as_ref())?); } + Ok(new) } /// Tries to match string containing a parameter to preserve with the corresponding entry in the /// Attributes struct. - fn try_set_from_string(&mut self, value: &str) -> Result<(), Error> { - let preserve_yes_required = Preserve::Yes { required: true }; + fn parse_single_string(value: &str) -> Result { + let value = value.to_lowercase(); - match &*value.to_lowercase() { - "mode" => self.mode = preserve_yes_required, + if value == "all" { + return Ok(Self::ALL); + } + + let mut new = Self::NONE; + let attribute = match value.as_ref() { + "mode" => &mut new.mode, #[cfg(unix)] - "ownership" => self.ownership = preserve_yes_required, - "timestamps" => self.timestamps = preserve_yes_required, - "context" => self.context = preserve_yes_required, - "link" | "links" => self.links = preserve_yes_required, - "xattr" => self.xattr = preserve_yes_required, + "ownership" => &mut new.ownership, + "timestamps" => &mut new.timestamps, + "context" => &mut new.context, + "link" | "links" => &mut new.links, + "xattr" => &mut new.xattr, _ => { return Err(Error::InvalidArgument(format!( "invalid attribute {}", @@ -854,7 +882,10 @@ impl Attributes { ))); } }; - Ok(()) + + *attribute = Preserve::Yes { required: true }; + + Ok(new) } } @@ -903,39 +934,22 @@ impl Options { }; // Parse attributes to preserve - let attributes: Attributes = if matches.contains_id(options::PRESERVE) { - match matches.get_many::(options::PRESERVE) { - None => Attributes::default(), - Some(attribute_strs) => { - let mut attributes: Attributes = Attributes::none(); - let mut attributes_empty = true; - for attribute_str in attribute_strs { - attributes_empty = false; - if attribute_str == "all" { - attributes.max(Attributes::all()); - } else { - attributes.try_set_from_string(attribute_str)?; - } - } - // `--preserve` case, use the defaults - if attributes_empty { - Attributes::default() - } else { - attributes - } - } + let attributes = if let Some(attribute_strs) = matches.get_many::(options::PRESERVE) + { + if attribute_strs.len() == 0 { + Attributes::DEFAULT + } else { + Attributes::parse_iter(attribute_strs)? } } else if matches.get_flag(options::ARCHIVE) { // --archive is used. Same as --preserve=all - Attributes::all() + Attributes::ALL } else if matches.get_flag(options::NO_DEREFERENCE_PRESERVE_LINKS) { - let mut attributes = Attributes::none(); - attributes.links = Preserve::Yes { required: true }; - attributes + Attributes::LINKS } else if matches.get_flag(options::PRESERVE_DEFAULT_ATTRIBUTES) { - Attributes::default() + Attributes::DEFAULT } else { - Attributes::none() + Attributes::NONE }; #[cfg(not(feature = "feat_selinux"))] From bdbf7176057266d73e083d292d14da85d6bc23dd Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 17 Aug 2023 10:06:56 +0200 Subject: [PATCH 040/370] Downgrade windows-targets from 0.48.2 to 0.48.0 --- Cargo.lock | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ae14a1ff..bd15fc341 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1528,7 +1528,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.2", + "windows-targets 0.48.0", ] [[package]] @@ -3475,7 +3475,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.2", + "windows-targets 0.48.0", ] [[package]] @@ -3495,17 +3495,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1eeca1c172a285ee6c2c84c341ccea837e7c01b12fbb2d0fe3c9e550ce49ec8" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm 0.48.2", - "windows_aarch64_msvc 0.48.2", - "windows_i686_gnu 0.48.2", - "windows_i686_msvc 0.48.2", - "windows_x86_64_gnu 0.48.2", - "windows_x86_64_gnullvm 0.48.2", - "windows_x86_64_msvc 0.48.2", + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] @@ -3516,9 +3516,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10d0c968ba7f6166195e13d593af609ec2e3d24f916f081690695cf5eaffb2f" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" @@ -3528,9 +3528,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571d8d4e62f26d4932099a9efe89660e8bd5087775a2ab5cdd8b747b811f1058" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" @@ -3540,9 +3540,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2229ad223e178db5fbbc8bd8d3835e51e566b8474bfca58d2e6150c48bb723cd" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" @@ -3552,9 +3552,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "600956e2d840c194eedfc5d18f8242bc2e17c7775b6684488af3a9fff6fe3287" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" @@ -3564,9 +3564,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea99ff3f8b49fb7a8e0d305e5aec485bd068c2ba691b6e277d29eaeac945868a" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" @@ -3576,9 +3576,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1a05a1ece9a7a0d5a7ccf30ba2c33e3a61a30e042ffd247567d1de1d94120d" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" @@ -3588,9 +3588,9 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d419259aba16b663966e29e6d7c6ecfa0bb8425818bb96f6f1f3c3eb71a6e7b9" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "xattr" From f63c87276ccf0de694613879dde6c5cafcd436f1 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 16 Aug 2023 14:40:43 +0200 Subject: [PATCH 041/370] Bump cpp from 0.5.8 to 0.5.9 --- Cargo.lock | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd15fc341..dcc753986 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,15 +8,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - [[package]] name = "aho-corasick" version = "1.0.2" @@ -538,18 +529,18 @@ dependencies = [ [[package]] name = "cpp" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b6a1d47f376a62bbea281408fe331879b9822c1edb8f67320c7cb8d96a02eb" +checksum = "bfa65869ef853e45c60e9828aa08cdd1398cb6e13f3911d9cb2a079b144fcd64" dependencies = [ "cpp_macros", ] [[package]] name = "cpp_build" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8f839b67a3deba30b58b281b5fca61477a90830beb084c58bdb9bebd227a1a" +checksum = "0e361fae2caf9758164b24da3eedd7f7d7451be30d90d8e7b5d2be29a2f0cf5b" dependencies = [ "cc", "cpp_common", @@ -562,9 +553,9 @@ dependencies = [ [[package]] name = "cpp_common" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d2b968b7b2ac412836e8ce1dfc3dfd5648ae7e8a42fcbbf5bc1d33bb795b0d" +checksum = "3e1a2532e4ed4ea13031c13bc7bc0dbca4aae32df48e9d77f0d1e743179f2ea1" dependencies = [ "lazy_static", "proc-macro2", @@ -573,11 +564,11 @@ dependencies = [ [[package]] name = "cpp_macros" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d36d9acb58020380e756d56a8dfc84d0f6ace423bbd4fedf83992b257b7f147" +checksum = "47ec9cc90633446f779ef481a9ce5a0077107dd5b87016440448d908625a83fd" dependencies = [ - "aho-corasick 0.7.20", + "aho-corasick", "byteorder", "cpp_common", "lazy_static", @@ -1771,7 +1762,7 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", "regex-automata", "regex-syntax", @@ -1783,7 +1774,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", "regex-syntax", ] From a756fa3266d3bf64b3f87d962bca533501511da5 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 16 Aug 2023 14:41:47 +0200 Subject: [PATCH 042/370] Bump aho-corasick from 1.0.2 to 1.0.4 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dcc753986..0b5e67fbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" dependencies = [ "memchr", ] From 228a58080d15f562e1279dc3d55dac4902c61dba Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 16 Aug 2023 14:45:31 +0200 Subject: [PATCH 043/370] deny.toml: remove aho-corasick from skip list --- deny.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/deny.toml b/deny.toml index f587f0720..c2e580a4d 100644 --- a/deny.toml +++ b/deny.toml @@ -63,7 +63,7 @@ skip = [ # rustix { name = "linux-raw-sys", version = "0.1.4" }, { name = "linux-raw-sys", version = "0.3.8" }, - # tempfile + # terminal_size { name = "rustix", version = "0.37.23" }, # various crates { name = "windows-sys", version = "0.45.0" }, @@ -83,8 +83,6 @@ skip = [ { name = "windows_x86_64_gnullvm", version = "0.42.2" }, # windows-targets { name = "windows_x86_64_msvc", version = "0.42.2" }, - # cpp_macros - { name = "aho-corasick", version = "0.7.20" }, # various crates { name = "syn", version = "1.0.109" }, # various crates From 8b9509a55bf45a9144ad754b9edce585819234dd Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 18 Aug 2023 16:11:11 +0200 Subject: [PATCH 044/370] chown: remove some duplication in tests --- tests/by-util/test_chown.rs | 250 ++++++------------------------------ 1 file changed, 41 insertions(+), 209 deletions(-) diff --git a/tests/by-util/test_chown.rs b/tests/by-util/test_chown.rs index 7a1a4a6bd..60a1061d1 100644 --- a/tests/by-util/test_chown.rs +++ b/tests/by-util/test_chown.rs @@ -744,7 +744,7 @@ fn test_chown_file_notexisting() { } #[test] -fn test_chown_no_change_to_user_from_user() { +fn test_chown_no_change_to_user() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; @@ -755,99 +755,22 @@ fn test_chown_no_change_to_user_from_user() { let user_name = String::from(result.stdout_str().trim()); assert!(!user_name.is_empty()); - let file = "f"; - at.touch(file); - scene - .ucmd() - .arg("-v") - .arg("--from=42") - .arg("43") - .arg(file) - .succeeds() - .stdout_only(format!("ownership of '{file}' retained as {user_name}\n")); + for (i, from) in ["42", ":42", "42:42"].iter().enumerate() { + let file = i.to_string(); + at.touch(&file); + scene + .ucmd() + .arg("-v") + .arg(format!("--from={from}")) + .arg("43") + .arg(&file) + .succeeds() + .stdout_only(format!("ownership of '{file}' retained as {user_name}\n")); + } } #[test] -fn test_chown_no_change_to_user_from_group() { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - - let result = scene.cmd("whoami").run(); - if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") { - return; - } - let user_name = String::from(result.stdout_str().trim()); - assert!(!user_name.is_empty()); - - let file = "f"; - at.touch(file); - scene - .ucmd() - .arg("-v") - .arg("--from=:42") - .arg("43") - .arg(file) - .succeeds() - .stdout_only(format!("ownership of '{file}' retained as {user_name}\n")); -} - -#[test] -fn test_chown_no_change_to_user_from_user_group() { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - - let result = scene.cmd("whoami").run(); - if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") { - return; - } - let user_name = String::from(result.stdout_str().trim()); - assert!(!user_name.is_empty()); - - let file = "f"; - at.touch(file); - scene - .ucmd() - .arg("-v") - .arg("--from=42:42") - .arg("43") - .arg(file) - .succeeds() - .stdout_only(format!("ownership of '{file}' retained as {user_name}\n")); -} - -#[test] -fn test_chown_no_change_to_group_from_user() { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - - let result = scene.cmd("whoami").run(); - if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") { - return; - } - let user_name = String::from(result.stdout_str().trim()); - assert!(!user_name.is_empty()); - - let result = scene.cmd("id").arg("-ng").run(); - if skipping_test_is_okay(&result, "id: cannot find name for group ID") { - return; - } - let group_name = String::from(result.stdout_str().trim()); - assert!(!group_name.is_empty()); - - let file = "f"; - at.touch(file); - scene - .ucmd() - .arg("-v") - .arg("--from=42") - .arg(":43") - .arg(file) - .succeeds() - .stdout_only(format!("ownership of '{file}' retained as {group_name}\n")); -} - -#[test] -fn test_chown_no_change_to_group_from_group() { +fn test_chown_no_change_to_group() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; @@ -864,20 +787,22 @@ fn test_chown_no_change_to_group_from_group() { let group_name = String::from(result.stdout_str().trim()); assert!(!group_name.is_empty()); - let file = "f"; - at.touch(file); - scene - .ucmd() - .arg("-v") - .arg("--from=:42") - .arg(":43") - .arg(file) - .succeeds() - .stdout_only(format!("ownership of '{file}' retained as {group_name}\n")); + for (i, from) in ["42", ":42", "42:42"].iter().enumerate() { + let file = i.to_string(); + at.touch(&file); + scene + .ucmd() + .arg("-v") + .arg(format!("--from={from}")) + .arg(":43") + .arg(&file) + .succeeds() + .stdout_only(format!("ownership of '{file}' retained as {group_name}\n")); + } } #[test] -fn test_chown_no_change_to_group_from_user_group() { +fn test_chown_no_change_to_user_group() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; @@ -894,111 +819,18 @@ fn test_chown_no_change_to_group_from_user_group() { let group_name = String::from(result.stdout_str().trim()); assert!(!group_name.is_empty()); - let file = "f"; - at.touch(file); - scene - .ucmd() - .arg("-v") - .arg("--from=42:42") - .arg(":43") - .arg(file) - .succeeds() - .stdout_only(format!("ownership of '{file}' retained as {group_name}\n")); -} - -#[test] -fn test_chown_no_change_to_user_group_from_user() { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - - let result = scene.cmd("whoami").run(); - if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") { - return; - } - let user_name = String::from(result.stdout_str().trim()); - assert!(!user_name.is_empty()); - - let result = scene.cmd("id").arg("-ng").run(); - if skipping_test_is_okay(&result, "id: cannot find name for group ID") { - return; - } - let group_name = String::from(result.stdout_str().trim()); - assert!(!group_name.is_empty()); - - let file = "f"; - at.touch(file); - scene - .ucmd() - .arg("-v") - .arg("--from=42") - .arg("43:43") - .arg(file) - .succeeds() - .stdout_only(format!( - "ownership of '{file}' retained as {user_name}:{group_name}\n" - )); -} - -#[test] -fn test_chown_no_change_to_user_group_from_group() { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - - let result = scene.cmd("whoami").run(); - if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") { - return; - } - let user_name = String::from(result.stdout_str().trim()); - assert!(!user_name.is_empty()); - let result = scene.cmd("id").arg("-ng").run(); - if skipping_test_is_okay(&result, "id: cannot find name for group ID") { - return; - } - let group_name = String::from(result.stdout_str().trim()); - assert!(!group_name.is_empty()); - - let file = "f"; - at.touch(file); - scene - .ucmd() - .arg("-v") - .arg("--from=:42") - .arg("43:43") - .arg(file) - .succeeds() - .stdout_only(format!( - "ownership of '{file}' retained as {user_name}:{group_name}\n" - )); -} - -#[test] -fn test_chown_no_change_to_user_group_from_user_group() { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - - let result = scene.cmd("whoami").run(); - if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") { - return; - } - let user_name = String::from(result.stdout_str().trim()); - assert!(!user_name.is_empty()); - let result = scene.cmd("id").arg("-ng").run(); - if skipping_test_is_okay(&result, "id: cannot find name for group ID") { - return; - } - let group_name = String::from(result.stdout_str().trim()); - assert!(!group_name.is_empty()); - - let file = "f"; - at.touch(file); - scene - .ucmd() - .arg("-v") - .arg("--from=42:42") - .arg("43:43") - .arg(file) - .succeeds() - .stdout_only(format!( - "ownership of '{file}' retained as {user_name}:{group_name}\n" - )); + for (i, from) in ["42", ":42", "42:42"].iter().enumerate() { + let file = i.to_string(); + at.touch(&file); + scene + .ucmd() + .arg("-v") + .arg(format!("--from={from}")) + .arg("43:43") + .arg(&file) + .succeeds() + .stdout_only(format!( + "ownership of '{file}' retained as {user_name}:{group_name}\n" + )); + } } From 370920f0bd7f54dec84dc255bfb4c4235c0d14b2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:40:06 +0000 Subject: [PATCH 045/370] chore(deps): update rust crate tempfile to 3.8.0 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b5e67fbf..f25b7c20c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2116,9 +2116,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.7.1" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand", diff --git a/Cargo.toml b/Cargo.toml index c3413d86b..ac5e45088 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -318,7 +318,7 @@ self_cell = "1.0.1" selinux = "0.4" signal-hook = "0.3.17" smallvec = { version = "1.11", features = ["union"] } -tempfile = "3.7.1" +tempfile = "3.8.0" term_grid = "0.1.5" terminal_size = "0.2.6" textwrap = { version = "0.16.0", features = ["terminal_size"] } From d604f709cea04b6ae25b66ee8c192c4262fd0b98 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 15 Aug 2023 13:07:22 +0200 Subject: [PATCH 046/370] nl: handle line number overflow --- src/uu/nl/src/nl.rs | 5 ++++- tests/by-util/test_nl.rs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 115b4efa9..5bb1eb9e4 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -344,7 +344,10 @@ fn nl(reader: &mut BufReader, settings: &Settings) -> UResult<()> { line ); // update line number for the potential next line - line_no += settings.line_increment; + match line_no.checked_add(settings.line_increment) { + Some(new_line_no) => line_no = new_line_no, + None => return Err(USimpleError::new(1, "line number overflow")), + } } else { let spaces = " ".repeat(settings.number_width + 1); println!("{spaces}{line}"); diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index e178950b3..4aa95030b 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -464,3 +464,21 @@ fn test_invalid_regex_numbering() { .stderr_contains("invalid regular expression"); } } + +#[test] +fn test_line_number_overflow() { + new_ucmd!() + .arg(format!("--starting-line-number={}", i64::MAX)) + .pipe_in("a\nb") + .fails() + .stdout_is(format!("{}\ta\n", i64::MAX)) + .stderr_is("nl: line number overflow\n"); + + new_ucmd!() + .arg(format!("--starting-line-number={}", i64::MIN)) + .arg("--line-increment=-1") + .pipe_in("a\nb") + .fails() + .stdout_is(format!("{}\ta\n", i64::MIN)) + .stderr_is("nl: line number overflow\n"); +} From 171f9d660c3a050994ec034719362ef171bc7737 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 19 Aug 2023 18:00:33 +0200 Subject: [PATCH 047/370] docs: add platform support page in the docs --- docs/.gitignore | 1 + docs/src/platforms.md | 45 +++++++++++++++++++++++++++++++++++++++++++ src/bin/uudoc.rs | 45 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 docs/src/platforms.md diff --git a/docs/.gitignore b/docs/.gitignore index c669da8f6..be017dfbe 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -1,4 +1,5 @@ book src/utils src/SUMMARY.md +src/platform_table.md tldr.zip \ No newline at end of file diff --git a/docs/src/platforms.md b/docs/src/platforms.md new file mode 100644 index 000000000..56ec616fc --- /dev/null +++ b/docs/src/platforms.md @@ -0,0 +1,45 @@ +# Platform support + + + +uutils aims to be as "universal" as possible, meaning that we try to support +many platforms. However, it is infeasible for us to guarantee that every +platform works. Just like Rust itself, we therefore have multiple tiers of +platform support, with different guarantees. We support two tiers of platforms: + + - **Tier 1**: All applicable utils are compiled and tested in CI for these + platforms. + - **Tier 2**: These platforms are supported but not actively tested. We do accept + fixes for these platforms. + +> **Note**: The tiers are dictated by our CI. We would happily accept a job +> in the CI for testing more platforms, bumping those platforms to tier 1. + +## Platforms per tier + +The platforms in tier 1 and the platforms that we test in CI are listed below. + +| Operating system | Tested targets | +| ---------------- | -------------- | +| **Linux** | `x86_64-unknown-linux-gnu`
`x86_64-unknown-linux-musl`
`arm-unknown-linux-gnueabihf`
`i686-unknown-linux-gnu`
`aarch64-unknown-linux-gnu` | +| **macOS** | `x86_64-apple-darwin` | +| **Windows** | `i686-pc-windows-msvc`
`x86_64-pc-windows-gnu`
`x86_64-pc-windows-msvc` | +| **FreeBSD** | `x86_64-unknown-freebsd` | +| **Android** | `i686-linux-android` | + +The platforms in tier 2 are more vague, but include: + + - untested variations of the platforms above, + - Redox OS, + - and BSDs such as OpenBSD, NetBSD & DragonFlyBSD. + +## Utility compatibility per platform + +Not all utils work on every platform. For instance, `chgrp` is not supported on +Windows, because Windows does have the concept of groups. Below is a full table +detailing which utilities are supported for the tier 1 platforms. + +Note that for some utilities, not all functionality is supported on each +platform. This is documented per utility. + +{{ #include platform_table.md }} diff --git a/src/bin/uudoc.rs b/src/bin/uudoc.rs index 5ac858226..77c7a2fcf 100644 --- a/src/bin/uudoc.rs +++ b/src/bin/uudoc.rs @@ -42,6 +42,7 @@ fn main() -> io::Result<()> { [Introduction](index.md)\n\ * [Installation](installation.md)\n\ * [Build from source](build.md)\n\ + * [Platform support](platforms.md)\n\ * [Contributing](contributing.md)\n\ * [GNU test coverage](test_coverage.md)\n\ * [Extensions](extensions.md)\n\ @@ -53,7 +54,7 @@ fn main() -> io::Result<()> { println!("Gathering utils per platform"); let utils_per_platform = { let mut map = HashMap::new(); - for platform in ["unix", "macos", "windows"] { + for platform in ["unix", "macos", "windows", "unix_android"] { let platform_utils: Vec = String::from_utf8( std::process::Command::new("./util/show-utils.sh") .arg(format!("--features=feat_os_{}", platform)) @@ -61,6 +62,7 @@ fn main() -> io::Result<()> { .stdout, ) .unwrap() + .trim() .split(' ') .map(ToString::to_string) .collect(); @@ -75,6 +77,7 @@ fn main() -> io::Result<()> { .stdout, ) .unwrap() + .trim() .split(' ') .map(ToString::to_string) .collect(); @@ -83,9 +86,47 @@ fn main() -> io::Result<()> { map }; - println!("Writing to utils"); let mut utils = utils.entries().collect::>(); utils.sort(); + + println!("Writing util per platform table"); + { + let mut platform_table_file = File::create("docs/src/platform_table.md").unwrap(); + + // sum, cksum, b2sum, etc. are all available on all platforms, but not in the data structure + // otherwise, we check the map for the util name. + let check_supported = |name: &str, platform: &str| { + if name.ends_with("sum") || utils_per_platform[platform].iter().any(|u| u == name) { + "✓" + } else { + " " + } + }; + writeln!( + platform_table_file, + "| util | Linux | macOS | Windows | FreeBSD | Android |\n\ + | ---------------- | ----- | ----- | ------- | ------- | ------- |" + )?; + for (&name, _) in &utils { + if name == "[" { + continue; + } + // The alignment is not necessary, but makes the output a bit more + // pretty when viewed as plain markdown. + writeln!( + platform_table_file, + "| {:<16} | {:<5} | {:<5} | {:<7} | {:<7} | {:<7} |", + format!("**{name}**"), + check_supported(name, "linux"), + check_supported(name, "macos"), + check_supported(name, "windows"), + check_supported(name, "unix"), + check_supported(name, "unix_android"), + )?; + } + } + + println!("Writing to utils"); for (&name, (_, command)) in utils { if name == "[" { continue; From 1431fb7ae83b2eeecd9d91e441062a93d4b19f5d Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 19 Aug 2023 18:00:57 +0200 Subject: [PATCH 048/370] docs: remove README.target.md in favor of platform support page in the docs --- README.target.md | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 README.target.md diff --git a/README.target.md b/README.target.md deleted file mode 100644 index b8190ce3e..000000000 --- a/README.target.md +++ /dev/null @@ -1,28 +0,0 @@ -# Targets that compile - -**Note: this list isn't up to date.** - -This is an auto-generated table showing which binaries compile for each target-triple. Note that this **does not** indicate that they are fully implemented, or that the tests pass. - -|######OS######|###ARCH####|arch|base32|base64|basename|cat|chgrp|chmod|chown|chroot|cksum|comm|cp|csplit|cut|date|df|dircolors|dirname|du|echo|env|expand|expr|factor|false|fmt|fold|groups|hashsum|head|hostid|hostname|id|install|join|kill|link|ln|logname|ls|mkdir|mkfifo|mknod|mktemp|more|mv|nice|nl|nohup|nproc|numfmt|od|paste|pathchk|pinky|printenv|printf|ptx|pwd|readlink|realpath|relpath|rm|rmdir|seq|shred|shuf|sleep|sort|split|stat|stdbuf|sum|sync|tac|tail|tee|test|timeout|touch|tr|true|truncate|tsort|tty|uname|unexpand|uniq|unlink|uptime|users|wc|who|whoami|yes|chcon|pr|dir|vdir|dd|basenc|runcon| -|--------------|-----------|----|------|------|--------|---|-----|-----|-----|------|-----|----|--|------|---|----|--|---------|-------|--|----|---|------|----|------|-----|---|----|------|-------|----|------|--------|--|-------|----|----|----|--|-------|--|-----|------|-----|------|----|--|----|--|-----|-----|------|--|-----|-------|-----|--------|------|---|---|--------|--------|-------|--|-----|---|-----|----|-----|----|-----|----|------|---|----|---|----|---|----|-------|-----|--|----|--------|-----|---|-----|--------|----|------|------|-----|--|---|------|---|-----|--|---|----|--|------|------| -|linux-gnu|aarch64|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| -|linux-gnu|i686|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| -|linux-gnu|powerpc64|y|y|y|y|y|y|y|y|y|y|y| |y|y|y|y|y|y|y|y|y|y| |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| -|linux-gnu|riscv64gc| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -|linux-gnu|x86_64|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| |y|y|y|y|y| |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| -|windows-msvc|aarch64|y|y|y|y|y| | | | |y|y|y|y|y|y|y|y|y| |y|y|y| |y|y|y|y| |y|y|y|y| | |y| |y|y|y| |y| | |y|y|y| |y| |y|y|y|y| | |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| | |y|y|y|y|y|y| |y|y|y|y|y| |y|y|y| |y| |y| | |y|y|y|y|y|y|y|y| -|windows-gnu|i686|y|y|y|y|y| | | | |y|y|y|y|y|y|y|y|y| |y|y|y| |y|y|y|y| |y|y|y|y| | |y| |y|y|y|y|y| | |y|y|y| |y| |y|y|y|y| | |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| | |y|y|y|y|y|y| |y|y|y|y|y|y|y|y|y| |y| |y| |y|y|y|y|y|y|y|y|y| -|windows-msvc|i686|y|y|y|y|y| | | | |y|y|y|y|y|y|y|y|y| |y|y|y| |y|y|y|y| |y|y|y|y| | |y| |y|y|y|y|y| | |y|y|y| |y| |y|y|y|y| | |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| | |y|y|y|y|y|y| |y|y|y|y|y| |y|y|y| |y| |y| |y|y|y|y|y|y|y|y|y| -|windows-gnu|x86_64|y|y|y|y|y| | | | |y|y|y|y|y|y|y|y|y| |y|y|y| |y|y|y|y| |y|y|y|y| | |y| |y|y|y|y|y| | |y|y|y| |y| |y|y|y|y| | |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| | |y|y|y|y|y|y| |y|y|y|y|y|y|y|y|y| |y| |y| |y|y|y|y|y|y|y|y|y| -|windows-msvc|x86_64|y|y|y|y|y| | | | |y|y|y|y|y|y|y|y|y| |y|y|y| |y|y|y|y| |y|y|y|y| | |y| |y|y|y|y|y| | |y|y|y| |y| |y|y|y|y| | |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| | |y|y|y|y|y|y| |y|y|y|y|y| |y|y|y| |y| |y| |y|y|y|y|y|y|y|y|y| -|apple MacOS|x86_64|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| -|freebsd|x86_64|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| -|netbsd|x86_64|y|y|y|y|y|y|y|y| |y|y|y|y|y|y| |y|y|y|y|y|y| |y|y|y|y|y|y|y|y|y| |y|y| |y|y|y|y|y|y|y|y|y|y|y|y| |y|y|y|y|y| |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| |y|y|y|y|y|y| |y|y|y| | |y| |y|y|y|y|y|y|y|y|y| -|android|aarch64|y|y|y|y|y|y|y|y| |y|y|y|y|y|y| |y|y|y|y|y|y| |y|y|y|y|y|y|y|y|y| |y|y| |y|y|y|y|y|y|y|y|y|y|y|y| |y|y|y|y|y| |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| |y|y| |y|y|y|y| |y|y|y|y|y|y| |y|y|y| | |y| |y|y|y|y|y|y|y|y|y| -|android|x86_64|y|y|y|y|y|y|y|y| |y|y|y|y|y|y| |y|y|y|y|y|y| |y|y|y|y|y|y|y|y|y| |y|y| |y|y|y|y|y|y|y|y|y|y|y|y| |y|y|y|y|y| |y|y|y|y|y|y|y|y|y|y|y|y|y|y|y| |y|y| |y|y|y|y| |y|y|y|y|y|y| |y|y|y| | |y| |y|y|y|y|y|y|y|y|y| -|solaris|x86_64| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -|wasi|wasm32| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -|redox|x86_64| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -|fuchsia|aarch64| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -|fuchsia|x86_64| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From 872818607f4ef82a30b9ae222980c4c620bca52b Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sun, 20 Aug 2023 10:03:29 +0200 Subject: [PATCH 049/370] Extract uucore::line_ending::LineEnding (#5120) * Extract uucore::line_ending::LineEnding Aims to provide consistent newline/zero terminator handling. * Apply suggestions from code review Co-authored-by: Terts Diepraam * cargo fmt * Use uucore::line_ending::LineEnding * Remove uucore::line_ending::LineEnding::Space * Rename LineEnding::from_zero_flag * Replace LineEnding::None with Option * cargo clippy * assert_eq * cargo clippy * cargo clippy * uucore/line_ending: add more documentation --------- Co-authored-by: Terts Diepraam --- src/uu/basename/src/basename.rs | 5 +- src/uu/comm/src/comm.rs | 38 +------------ src/uu/cut/src/cut.rs | 18 +++--- src/uu/dirname/src/dirname.rs | 9 +-- src/uu/du/src/du.rs | 13 ++--- src/uu/env/src/env.rs | 15 ++--- src/uu/head/src/head.rs | 77 ++++++++++++-------------- src/uu/id/src/id.rs | 9 +-- src/uu/join/src/join.rs | 12 +--- src/uu/ls/src/ls.rs | 23 ++++---- src/uu/paste/src/paste.rs | 24 +------- src/uu/readlink/src/readlink.rs | 19 ++++--- src/uu/realpath/src/realpath.rs | 10 ++-- src/uu/sort/src/check.rs | 6 +- src/uu/sort/src/ext_sort.rs | 6 +- src/uu/sort/src/merge.rs | 6 +- src/uu/sort/src/sort.rs | 18 +++--- src/uucore/src/lib/lib.rs | 1 + src/uucore/src/lib/mods.rs | 1 + src/uucore/src/lib/mods/line_ending.rs | 49 ++++++++++++++++ 20 files changed, 163 insertions(+), 196 deletions(-) create mode 100644 src/uucore/src/lib/mods/line_ending.rs diff --git a/src/uu/basename/src/basename.rs b/src/uu/basename/src/basename.rs index ed7faee65..3fe594c3b 100644 --- a/src/uu/basename/src/basename.rs +++ b/src/uu/basename/src/basename.rs @@ -11,6 +11,7 @@ use clap::{crate_version, Arg, ArgAction, Command}; use std::path::{is_separator, PathBuf}; use uucore::display::Quotable; use uucore::error::{UResult, UUsageError}; +use uucore::line_ending::LineEnding; use uucore::{format_usage, help_about, help_usage}; static ABOUT: &str = help_about!("basename.md"); @@ -54,9 +55,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { return Err(UUsageError::new(1, "missing operand".to_string())); } + let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO)); + let opt_suffix = matches.get_one::(options::SUFFIX).is_some(); let opt_multiple = matches.get_flag(options::MULTIPLE); - let opt_zero = matches.get_flag(options::ZERO); let multiple_paths = opt_suffix || opt_multiple; let name_args_count = matches .get_many::(options::NAME) @@ -105,7 +107,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .collect() }; - let line_ending = if opt_zero { "\0" } else { "\n" }; for path in paths { print!("{}{}", basename(path, suffix), line_ending); } diff --git a/src/uu/comm/src/comm.rs b/src/uu/comm/src/comm.rs index 26e704037..b88087389 100644 --- a/src/uu/comm/src/comm.rs +++ b/src/uu/comm/src/comm.rs @@ -8,11 +8,11 @@ // spell-checker:ignore (ToDO) delim mkdelim use std::cmp::Ordering; -use std::fmt::Display; use std::fs::File; use std::io::{self, stdin, BufRead, BufReader, Stdin}; use std::path::Path; use uucore::error::{FromIo, UResult}; +use uucore::line_ending::LineEnding; use uucore::{format_usage, help_about, help_usage}; use clap::{crate_version, Arg, ArgAction, ArgMatches, Command}; @@ -40,38 +40,6 @@ fn column_width(col: &str, opts: &ArgMatches) -> usize { } } -#[repr(u8)] -#[derive(Clone, Copy)] -enum LineEnding { - Newline = b'\n', - Nul = 0, -} - -impl From for u8 { - fn from(line_ending: LineEnding) -> Self { - line_ending as Self - } -} - -impl From for LineEnding { - fn from(is_zero_terminated: bool) -> Self { - if is_zero_terminated { - Self::Nul - } else { - Self::Newline - } - } -} - -impl Display for LineEnding { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Newline => writeln!(f), - Self::Nul => write!(f, "\0"), - } - } -} - enum Input { Stdin(Stdin), FileIn(BufReader), @@ -168,7 +136,7 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &ArgMatches) { } if opts.get_flag(options::TOTAL) { - let line_ending = LineEnding::from(opts.get_flag(options::ZERO_TERMINATED)); + let line_ending = LineEnding::from_zero_flag(opts.get_flag(options::ZERO_TERMINATED)); print!("{total_col_1}{delim}{total_col_2}{delim}{total_col_3}{delim}total{line_ending}"); } } @@ -190,7 +158,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args.collect_lossy(); let matches = uu_app().try_get_matches_from(args)?; - let line_ending = LineEnding::from(matches.get_flag(options::ZERO_TERMINATED)); + let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO_TERMINATED)); let filename1 = matches.get_one::(options::FILE_1).unwrap(); let filename2 = matches.get_one::(options::FILE_2).unwrap(); let mut f1 = open_file(filename1, line_ending).map_err_context(|| filename1.to_string())?; diff --git a/src/uu/cut/src/cut.rs b/src/uu/cut/src/cut.rs index 68ad566d7..33dd3850d 100644 --- a/src/uu/cut/src/cut.rs +++ b/src/uu/cut/src/cut.rs @@ -15,6 +15,7 @@ use std::io::{stdin, stdout, BufReader, BufWriter, Read, Write}; use std::path::Path; use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError}; +use uucore::line_ending::LineEnding; use self::searcher::Searcher; use matcher::{ExactMatcher, Matcher, WhitespaceMatcher}; @@ -30,7 +31,7 @@ const AFTER_HELP: &str = help_section!("after help", "cut.md"); struct Options { out_delim: Option, - zero_terminated: bool, + line_ending: LineEnding, } enum Delimiter { @@ -42,7 +43,7 @@ struct FieldOptions { delimiter: Delimiter, out_delimiter: Option, only_delimited: bool, - zero_terminated: bool, + line_ending: LineEnding, } enum Mode { @@ -68,7 +69,7 @@ fn list_to_ranges(list: &str, complement: bool) -> Result, String> { } fn cut_bytes(reader: R, ranges: &[Range], opts: &Options) -> UResult<()> { - let newline_char = if opts.zero_terminated { b'\0' } else { b'\n' }; + let newline_char = opts.line_ending.into(); let mut buf_in = BufReader::new(reader); let mut out = stdout_writer(); let delim = opts @@ -259,7 +260,7 @@ fn cut_fields_implicit_out_delim( } fn cut_fields(reader: R, ranges: &[Range], opts: &FieldOptions) -> UResult<()> { - let newline_char = if opts.zero_terminated { b'\0' } else { b'\n' }; + let newline_char = opts.line_ending.into(); match opts.delimiter { Delimiter::String(ref delim) => { let matcher = ExactMatcher::new(delim.as_bytes()); @@ -376,7 +377,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .unwrap_or_default() .to_owned(), ), - zero_terminated: matches.get_flag(options::ZERO_TERMINATED), + line_ending: LineEnding::from_zero_flag(matches.get_flag(options::ZERO_TERMINATED)), }, ) }), @@ -391,7 +392,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .unwrap_or_default() .to_owned(), ), - zero_terminated: matches.get_flag(options::ZERO_TERMINATED), + line_ending: LineEnding::from_zero_flag(matches.get_flag(options::ZERO_TERMINATED)), }, ) }), @@ -411,6 +412,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let only_delimited = matches.get_flag(options::ONLY_DELIMITED); let whitespace_delimited = matches.get_flag(options::WHITESPACE_DELIMITED); let zero_terminated = matches.get_flag(options::ZERO_TERMINATED); + let line_ending = LineEnding::from_zero_flag(zero_terminated); match matches.get_one::(options::DELIMITER).map(|s| s.as_str()) { Some(_) if whitespace_delimited => { @@ -441,7 +443,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { delimiter: Delimiter::String(delim), out_delimiter: out_delim, only_delimited, - zero_terminated, + line_ending, }, )) } @@ -455,7 +457,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { }, out_delimiter: out_delim, only_delimited, - zero_terminated, + line_ending, }, )), } diff --git a/src/uu/dirname/src/dirname.rs b/src/uu/dirname/src/dirname.rs index cecd6aec8..4d9c09cc3 100644 --- a/src/uu/dirname/src/dirname.rs +++ b/src/uu/dirname/src/dirname.rs @@ -9,6 +9,7 @@ use clap::{crate_version, Arg, ArgAction, Command}; use std::path::Path; use uucore::display::print_verbatim; use uucore::error::{UResult, UUsageError}; +use uucore::line_ending::LineEnding; use uucore::{format_usage, help_about, help_section, help_usage}; const ABOUT: &str = help_about!("dirname.md"); @@ -26,11 +27,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?; - let separator = if matches.get_flag(options::ZERO) { - "\0" - } else { - "\n" - }; + let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO)); let dirnames: Vec = matches .get_many::(options::DIR) @@ -59,7 +56,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } } - print!("{separator}"); + print!("{line_ending}"); } } diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index db385c720..14bda4967 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -34,6 +34,7 @@ use std::{error::Error, fmt::Display}; use uucore::display::{print_verbatim, Quotable}; use uucore::error::FromIo; use uucore::error::{set_exit_code, UError, UResult}; +use uucore::line_ending::LineEnding; use uucore::parse_glob; use uucore::parse_size::{parse_size, ParseSizeError}; use uucore::{ @@ -600,11 +601,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let time_format_str = parse_time_style(matches.get_one::("time-style").map(|s| s.as_str()))?; - let line_separator = if matches.get_flag(options::NULL) { - "\0" - } else { - "\n" - }; + let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::NULL)); let excludes = build_exclude_patterns(&matches)?; @@ -656,12 +653,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let time_str = tm.format(time_format_str).to_string(); print!("{}\t{}\t", convert_size(size), time_str); print_verbatim(stat.path).unwrap(); - print!("{line_separator}"); + print!("{line_ending}"); } } else if !summarize || index == len - 1 { print!("{}\t", convert_size(size)); print_verbatim(stat.path).unwrap(); - print!("{line_separator}"); + print!("{line_ending}"); } if options.total && index == (len - 1) { // The last element will be the total size of the the path under @@ -681,7 +678,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { if options.total { print!("{}\ttotal", convert_size(grand_total)); - print!("{line_separator}"); + print!("{line_ending}"); } Ok(()) diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index b293bc9bf..08704f364 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -23,6 +23,7 @@ use std::os::unix::process::ExitStatusExt; use std::process; use uucore::display::Quotable; use uucore::error::{UClapError, UResult, USimpleError, UUsageError}; +use uucore::line_ending::LineEnding; use uucore::{format_usage, help_about, help_section, help_usage, show_warning}; const ABOUT: &str = help_about!("env.md"); @@ -31,7 +32,7 @@ const AFTER_HELP: &str = help_section!("after help", "env.md"); struct Options<'a> { ignore_env: bool, - null: bool, + line_ending: LineEnding, running_directory: Option<&'a str>, files: Vec<&'a str>, unsets: Vec<&'a str>, @@ -41,11 +42,11 @@ struct Options<'a> { // print name=value env pairs on screen // if null is true, separate pairs with a \0, \n otherwise -fn print_env(null: bool) { +fn print_env(line_ending: LineEnding) { let stdout_raw = io::stdout(); let mut stdout = stdout_raw.lock(); for (n, v) in env::vars() { - write!(stdout, "{}={}{}", n, v, if null { '\0' } else { '\n' }).unwrap(); + write!(stdout, "{}={}{}", n, v, line_ending).unwrap(); } } @@ -64,7 +65,7 @@ fn parse_name_value_opt<'a>(opts: &mut Options<'a>, opt: &'a str) -> UResult(opts: &mut Options<'a>, opt: &'a str) -> UResult<()> { - if opts.null { + if opts.line_ending == LineEnding::Nul { Err(UUsageError::new( 125, "cannot specify --null (-0) with command".to_string(), @@ -181,7 +182,7 @@ fn run_env(args: impl uucore::Args) -> UResult<()> { let matches = app.try_get_matches_from(args).with_exit_code(125)?; let ignore_env = matches.get_flag("ignore-environment"); - let null = matches.get_flag("null"); + let line_ending = LineEnding::from_zero_flag(matches.get_flag("null")); let running_directory = matches.get_one::("chdir").map(|s| s.as_str()); let files = match matches.get_many::("file") { Some(v) => v.map(|s| s.as_str()).collect(), @@ -194,7 +195,7 @@ fn run_env(args: impl uucore::Args) -> UResult<()> { let mut opts = Options { ignore_env, - null, + line_ending, running_directory, files, unsets, @@ -302,7 +303,7 @@ fn run_env(args: impl uucore::Args) -> UResult<()> { if opts.program.is_empty() { // no program provided, so just dump all env vars to stdout - print_env(opts.null); + print_env(opts.line_ending); } else { // we need to execute a command let (prog, args) = build_command(&mut opts.program); diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index 2517a98ea..931f8a652 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -10,6 +10,7 @@ use std::ffi::OsString; use std::io::{self, BufWriter, ErrorKind, Read, Seek, SeekFrom, Write}; use uucore::display::Quotable; use uucore::error::{FromIo, UError, UResult, USimpleError}; +use uucore::line_ending::LineEnding; use uucore::lines::lines; use uucore::{format_usage, help_about, help_usage, show}; @@ -184,7 +185,7 @@ fn arg_iterate<'a>( struct HeadOptions { pub quiet: bool, pub verbose: bool, - pub zeroed: bool, + pub line_ending: LineEnding, pub presume_input_pipe: bool, pub mode: Mode, pub files: Vec, @@ -197,7 +198,7 @@ impl HeadOptions { options.quiet = matches.get_flag(options::QUIET_NAME); options.verbose = matches.get_flag(options::VERBOSE_NAME); - options.zeroed = matches.get_flag(options::ZERO_NAME); + options.line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO_NAME)); options.presume_input_pipe = matches.get_flag(options::PRESUME_INPUT_PIPE); options.mode = Mode::from(matches)?; @@ -227,9 +228,8 @@ where Ok(()) } -fn read_n_lines(input: &mut impl std::io::BufRead, n: u64, zero: bool) -> std::io::Result<()> { +fn read_n_lines(input: &mut impl std::io::BufRead, n: u64, separator: u8) -> std::io::Result<()> { // Read the first `n` lines from the `input` reader. - let separator = if zero { b'\0' } else { b'\n' }; let mut reader = take_lines(input, n, separator); // Write those bytes to `stdout`. @@ -293,20 +293,12 @@ fn read_but_last_n_bytes(input: &mut impl std::io::BufRead, n: usize) -> std::io fn read_but_last_n_lines( input: impl std::io::BufRead, n: usize, - zero: bool, + separator: u8, ) -> std::io::Result<()> { - if zero { - let stdout = std::io::stdout(); - let mut stdout = stdout.lock(); - for bytes in take_all_but(lines(input, b'\0'), n) { - stdout.write_all(&bytes?)?; - } - } else { - let stdout = std::io::stdout(); - let mut stdout = stdout.lock(); - for bytes in take_all_but(lines(input, b'\n'), n) { - stdout.write_all(&bytes?)?; - } + let stdout = std::io::stdout(); + let mut stdout = stdout.lock(); + for bytes in take_all_but(lines(input, separator), n) { + stdout.write_all(&bytes?)?; } Ok(()) } @@ -350,7 +342,7 @@ fn read_but_last_n_lines( /// assert_eq!(find_nth_line_from_end(&mut input, 4, false).unwrap(), 0); /// assert_eq!(find_nth_line_from_end(&mut input, 1000, false).unwrap(), 0); /// ``` -fn find_nth_line_from_end(input: &mut R, n: u64, zeroed: bool) -> std::io::Result +fn find_nth_line_from_end(input: &mut R, n: u64, separator: u8) -> std::io::Result where R: Read + Seek, { @@ -370,14 +362,8 @@ where ))?; input.read_exact(buffer)?; for byte in buffer.iter().rev() { - match byte { - b'\n' if !zeroed => { - lines += 1; - } - 0u8 if zeroed => { - lines += 1; - } - _ => {} + if byte == &separator { + lines += 1; } // if it were just `n`, if lines == n + 1 { @@ -407,7 +393,7 @@ fn head_backwards_file(input: &mut std::fs::File, options: &HeadOptions) -> std: } } Mode::AllButLastLines(n) => { - let found = find_nth_line_from_end(input, n, options.zeroed)?; + let found = find_nth_line_from_end(input, n, options.line_ending.into())?; read_n_bytes( &mut std::io::BufReader::with_capacity(BUF_SIZE, input), found, @@ -426,7 +412,7 @@ fn head_file(input: &mut std::fs::File, options: &HeadOptions) -> std::io::Resul Mode::FirstLines(n) => read_n_lines( &mut std::io::BufReader::with_capacity(BUF_SIZE, input), n, - options.zeroed, + options.line_ending.into(), ), Mode::AllButLastBytes(_) | Mode::AllButLastLines(_) => head_backwards_file(input, options), } @@ -466,11 +452,13 @@ fn uu_head(options: &HeadOptions) -> UResult<()> { Mode::AllButLastBytes(n) => { read_but_last_n_bytes(&mut stdin, n.try_into().unwrap()) } - Mode::FirstLines(n) => read_n_lines(&mut stdin, n, options.zeroed), + Mode::FirstLines(n) => read_n_lines(&mut stdin, n, options.line_ending.into()), // unwrap is guaranteed to succeed because we checked the value of n above - Mode::AllButLastLines(n) => { - read_but_last_n_lines(&mut stdin, n.try_into().unwrap(), options.zeroed) - } + Mode::AllButLastLines(n) => read_but_last_n_lines( + &mut stdin, + n.try_into().unwrap(), + options.line_ending.into(), + ), } } (name, false) => { @@ -541,7 +529,7 @@ mod tests { #[test] fn test_args_modes() { let args = options("-n -10M -vz").unwrap(); - assert!(args.zeroed); + assert_eq!(args.line_ending, LineEnding::Nul); assert!(args.verbose); assert_eq!(args.mode, Mode::AllButLastLines(10 * 1024 * 1024)); } @@ -561,8 +549,11 @@ mod tests { assert!(options("-q").unwrap().quiet); assert!(options("--verbose").unwrap().verbose); assert!(options("-v").unwrap().verbose); - assert!(options("--zero-terminated").unwrap().zeroed); - assert!(options("-z").unwrap().zeroed); + assert_eq!( + options("--zero-terminated").unwrap().line_ending, + LineEnding::Nul + ); + assert_eq!(options("-z").unwrap().line_ending, LineEnding::Nul); assert_eq!(options("--lines 15").unwrap().mode, Mode::FirstLines(15)); assert_eq!(options("-n 15").unwrap().mode, Mode::FirstLines(15)); assert_eq!(options("--bytes 15").unwrap().mode, Mode::FirstBytes(15)); @@ -579,7 +570,7 @@ mod tests { assert!(!opts.verbose); assert!(!opts.quiet); - assert!(!opts.zeroed); + assert_eq!(opts.line_ending, LineEnding::Newline); assert_eq!(opts.mode, Mode::FirstLines(10)); assert!(opts.files.is_empty()); } @@ -631,17 +622,17 @@ mod tests { fn read_early_exit() { let mut empty = std::io::BufReader::new(std::io::Cursor::new(Vec::new())); assert!(read_n_bytes(&mut empty, 0).is_ok()); - assert!(read_n_lines(&mut empty, 0, false).is_ok()); + assert!(read_n_lines(&mut empty, 0, b'\n').is_ok()); } #[test] fn test_find_nth_line_from_end() { let mut input = Cursor::new("x\ny\nz\n"); - assert_eq!(find_nth_line_from_end(&mut input, 0, false).unwrap(), 6); - assert_eq!(find_nth_line_from_end(&mut input, 1, false).unwrap(), 4); - assert_eq!(find_nth_line_from_end(&mut input, 2, false).unwrap(), 2); - assert_eq!(find_nth_line_from_end(&mut input, 3, false).unwrap(), 0); - assert_eq!(find_nth_line_from_end(&mut input, 4, false).unwrap(), 0); - assert_eq!(find_nth_line_from_end(&mut input, 1000, false).unwrap(), 0); + assert_eq!(find_nth_line_from_end(&mut input, 0, b'\n').unwrap(), 6); + assert_eq!(find_nth_line_from_end(&mut input, 1, b'\n').unwrap(), 4); + assert_eq!(find_nth_line_from_end(&mut input, 2, b'\n').unwrap(), 2); + assert_eq!(find_nth_line_from_end(&mut input, 3, b'\n').unwrap(), 0); + assert_eq!(find_nth_line_from_end(&mut input, 4, b'\n').unwrap(), 0); + assert_eq!(find_nth_line_from_end(&mut input, 1000, b'\n').unwrap(), 0); } } diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 7a8e40059..9f4849f90 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -44,6 +44,7 @@ use uucore::error::UResult; use uucore::error::{set_exit_code, USimpleError}; pub use uucore::libc; use uucore::libc::{getlogin, uid_t}; +use uucore::line_ending::LineEnding; use uucore::process::{getegid, geteuid, getgid, getuid}; use uucore::{format_usage, help_about, help_section, help_usage, show_error}; @@ -174,13 +175,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { " ".to_string() } }; - let line_ending = { - if state.zflag { - '\0' - } else { - '\n' - } - }; + let line_ending = LineEnding::from_zero_flag(state.zflag); if state.cflag { if state.selinux_supported { diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index de1a9181b..afcb4d7d2 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -22,6 +22,7 @@ use std::num::IntErrorKind; use std::os::unix::ffi::OsStrExt; use uucore::display::Quotable; use uucore::error::{set_exit_code, UError, UResult, USimpleError}; +use uucore::line_ending::LineEnding; use uucore::{crash, crash_if_err, format_usage, help_about, help_usage}; const ABOUT: &str = help_about!("join.md"); @@ -62,13 +63,6 @@ enum FileNum { File2, } -#[repr(u8)] -#[derive(Copy, Clone)] -enum LineEnding { - Nul = 0, - Newline = b'\n', -} - #[derive(Copy, Clone, PartialEq)] enum Sep { Char(u8), @@ -683,9 +677,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { settings.headers = true; } - if matches.get_flag("z") { - settings.line_ending = LineEnding::Nul; - } + settings.line_ending = LineEnding::from_zero_flag(matches.get_flag("z")); let file1 = matches.get_one::("file1").unwrap(); let file2 = matches.get_one::("file2").unwrap(); diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index cead745cd..34d3b76f2 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -54,6 +54,7 @@ use unicode_width::UnicodeWidthStr; use uucore::libc::{dev_t, major, minor}; #[cfg(unix)] use uucore::libc::{S_IXGRP, S_IXOTH, S_IXUSR}; +use uucore::line_ending::LineEnding; use uucore::quoting_style::{escape_name, QuotingStyle}; use uucore::{ display::Quotable, @@ -408,7 +409,7 @@ pub struct Config { context: bool, selinux_supported: bool, group_directories_first: bool, - eol: char, + line_ending: LineEnding, } // Fields that can be removed or added to the long format @@ -1005,11 +1006,7 @@ impl Config { } }, group_directories_first: options.get_flag(options::GROUP_DIRECTORIES_FIRST), - eol: if options.get_flag(options::ZERO) { - '\0' - } else { - '\n' - }, + line_ending: LineEnding::from_zero_flag(options.get_flag(options::ZERO)), }) } } @@ -2173,7 +2170,7 @@ fn display_total(items: &[PathData], config: &Config, out: &mut BufWriter 0 { - write!(out, "{}", config.eol)?; + write!(out, "{}", config.line_ending)?; } } _ => { for name in names { - write!(out, "{}{}", name.contents, config.eol)?; + write!(out, "{}{}", name.contents, config.line_ending)?; } } }; @@ -2491,7 +2488,13 @@ fn display_item_long( let dfn = display_file_name(item, config, None, String::new(), out).contents; - write!(out, " {} {}{}", display_date(md, config), dfn, config.eol)?; + write!( + out, + " {} {}{}", + display_date(md, config), + dfn, + config.line_ending + )?; } else { #[cfg(unix)] let leading_char = { diff --git a/src/uu/paste/src/paste.rs b/src/uu/paste/src/paste.rs index 6e52727f7..45ba2d8dc 100644 --- a/src/uu/paste/src/paste.rs +++ b/src/uu/paste/src/paste.rs @@ -8,11 +8,11 @@ // spell-checker:ignore (ToDO) delim use clap::{crate_version, Arg, ArgAction, Command}; -use std::fmt::Display; use std::fs::File; use std::io::{stdin, stdout, BufRead, BufReader, Read, Write}; use std::path::Path; use uucore::error::{FromIo, UResult, USimpleError}; +use uucore::line_ending::LineEnding; use uucore::{format_usage, help_about, help_usage}; const ABOUT: &str = help_about!("paste.md"); @@ -25,22 +25,6 @@ mod options { pub const ZERO_TERMINATED: &str = "zero-terminated"; } -#[repr(u8)] -#[derive(Clone, Copy)] -enum LineEnding { - Newline = b'\n', - Nul = 0, -} - -impl Display for LineEnding { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Newline => writeln!(f), - Self::Nul => write!(f, "\0"), - } - } -} - // Wraps BufReader and stdin fn read_until( reader: Option<&mut BufReader>, @@ -64,11 +48,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .unwrap() .map(|s| s.to_owned()) .collect(); - let line_ending = if matches.get_flag(options::ZERO_TERMINATED) { - LineEnding::Nul - } else { - LineEnding::Newline - }; + let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO_TERMINATED)); paste(files, serial, delimiters, line_ending) } diff --git a/src/uu/readlink/src/readlink.rs b/src/uu/readlink/src/readlink.rs index e247c6146..7e9f7be15 100644 --- a/src/uu/readlink/src/readlink.rs +++ b/src/uu/readlink/src/readlink.rs @@ -14,6 +14,7 @@ use std::path::{Path, PathBuf}; use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; use uucore::fs::{canonicalize, MissingHandling, ResolveMode}; +use uucore::line_ending::LineEnding; use uucore::{format_usage, help_about, help_usage, show_error}; const ABOUT: &str = help_about!("readlink.md"); @@ -67,6 +68,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { show_error!("ignoring --no-newline with multiple arguments"); no_trailing_delimiter = false; } + let line_ending = if no_trailing_delimiter { + None + } else { + Some(LineEnding::from_zero_flag(use_zero)) + }; for f in &files { let p = PathBuf::from(f); @@ -77,7 +83,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { }; match path_result { Ok(path) => { - show(&path, no_trailing_delimiter, use_zero).map_err_context(String::new)?; + show(&path, line_ending).map_err_context(String::new)?; } Err(err) => { if verbose { @@ -173,14 +179,11 @@ pub fn uu_app() -> Command { ) } -fn show(path: &Path, no_trailing_delimiter: bool, use_zero: bool) -> std::io::Result<()> { +fn show(path: &Path, line_ending: Option) -> std::io::Result<()> { let path = path.to_str().unwrap(); - if no_trailing_delimiter { - print!("{path}"); - } else if use_zero { - print!("{path}\0"); - } else { - println!("{path}"); + print!("{path}"); + if let Some(line_ending) = line_ending { + print!("{line_ending}"); } stdout().flush() } diff --git a/src/uu/realpath/src/realpath.rs b/src/uu/realpath/src/realpath.rs index cb7a09a41..e2b7d7557 100644 --- a/src/uu/realpath/src/realpath.rs +++ b/src/uu/realpath/src/realpath.rs @@ -21,6 +21,7 @@ use uucore::{ format_usage, fs::{canonicalize, MissingHandling, ResolveMode}, help_about, help_usage, + line_ending::LineEnding, }; use uucore::{error::UClapError, show, show_if_err}; @@ -52,7 +53,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .collect(); let strip = matches.get_flag(OPT_STRIP); - let zero = matches.get_flag(OPT_ZERO); + let line_ending = LineEnding::from_zero_flag(matches.get_flag(OPT_ZERO)); let quiet = matches.get_flag(OPT_QUIET); let logical = matches.get_flag(OPT_LOGICAL); let can_mode = if matches.get_flag(OPT_CANONICALIZE_EXISTING) { @@ -73,7 +74,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { for path in &paths { let result = resolve_path( path, - zero, + line_ending, resolve_mode, can_mode, relative_to.as_deref(), @@ -249,19 +250,18 @@ fn canonicalize_relative( /// symbolic links. fn resolve_path( p: &Path, - zero: bool, + line_ending: LineEnding, resolve: ResolveMode, can_mode: MissingHandling, relative_to: Option<&Path>, relative_base: Option<&Path>, ) -> std::io::Result<()> { let abs = canonicalize(p, can_mode, resolve)?; - let line_ending = if zero { b'\0' } else { b'\n' }; let abs = process_relative(abs, relative_base, relative_to); print_verbatim(abs)?; - stdout().write_all(&[line_ending])?; + stdout().write_all(&[line_ending.into()])?; Ok(()) } diff --git a/src/uu/sort/src/check.rs b/src/uu/sort/src/check.rs index 3f02a4c31..700e3681c 100644 --- a/src/uu/sort/src/check.rs +++ b/src/uu/sort/src/check.rs @@ -115,11 +115,7 @@ fn reader( &mut carry_over, &mut file, &mut iter::empty(), - if settings.zero_terminated { - b'\0' - } else { - b'\n' - }, + settings.line_ending.into(), settings, )?; if !should_continue { diff --git a/src/uu/sort/src/ext_sort.rs b/src/uu/sort/src/ext_sort.rs index 27cb12d0b..a8f4b2590 100644 --- a/src/uu/sort/src/ext_sort.rs +++ b/src/uu/sort/src/ext_sort.rs @@ -84,11 +84,7 @@ fn reader_writer< output: Output, tmp_dir: &mut TmpDirWrapper, ) -> UResult<()> { - let separator = if settings.zero_terminated { - b'\0' - } else { - b'\n' - }; + let separator = settings.line_ending.into(); // Heuristically chosen: Dividing by 10 seems to keep our memory usage roughly // around settings.buffer_size as a whole. diff --git a/src/uu/sort/src/merge.rs b/src/uu/sort/src/merge.rs index 7c682d88f..1a987fb4e 100644 --- a/src/uu/sort/src/merge.rs +++ b/src/uu/sort/src/merge.rs @@ -169,11 +169,7 @@ fn merge_without_limit>>( &request_receiver, &mut reader_files, &settings, - if settings.zero_terminated { - b'\0' - } else { - b'\n' - }, + settings.line_ending.into(), ) } }); diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 80c2275e9..b40eb05c1 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -45,6 +45,7 @@ use std::str::Utf8Error; use unicode_width::UnicodeWidthStr; use uucore::display::Quotable; use uucore::error::{set_exit_code, strip_errno, UError, UResult, USimpleError, UUsageError}; +use uucore::line_ending::LineEnding; use uucore::parse_size::{ParseSizeError, Parser}; use uucore::version_cmp::version_cmp; use uucore::{format_usage, help_about, help_section, help_usage}; @@ -306,7 +307,7 @@ pub struct GlobalSettings { selectors: Vec, separator: Option, threads: String, - zero_terminated: bool, + line_ending: LineEnding, buffer_size: usize, compress_prog: Option, merge_batch_size: usize, @@ -383,7 +384,7 @@ impl Default for GlobalSettings { selectors: vec![], separator: None, threads: String::new(), - zero_terminated: false, + line_ending: LineEnding::Newline, buffer_size: DEFAULT_BUF_SIZE, compress_prog: None, merge_batch_size: 32, @@ -526,14 +527,11 @@ impl<'a> Line<'a> { } fn print(&self, writer: &mut impl Write, settings: &GlobalSettings) { - if settings.zero_terminated && !settings.debug { - writer.write_all(self.line.as_bytes()).unwrap(); - writer.write_all(b"\0").unwrap(); - } else if !settings.debug { - writer.write_all(self.line.as_bytes()).unwrap(); - writer.write_all(b"\n").unwrap(); - } else { + if settings.debug { self.print_debug(settings, writer).unwrap(); + } else { + writer.write_all(self.line.as_bytes()).unwrap(); + writer.write_all(&[settings.line_ending.into()]).unwrap(); } } @@ -1169,7 +1167,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { })?; } - settings.zero_terminated = matches.get_flag(options::ZERO_TERMINATED); + settings.line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO_TERMINATED)); settings.merge = matches.get_flag(options::MERGE); settings.check = matches.contains_id(options::check::CHECK); diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 02724e1bf..110939b7d 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -22,6 +22,7 @@ pub use uucore_procs::*; pub use crate::mods::backup_control; pub use crate::mods::display; pub use crate::mods::error; +pub use crate::mods::line_ending; pub use crate::mods::os; pub use crate::mods::panic; pub use crate::mods::quoting_style; diff --git a/src/uucore/src/lib/mods.rs b/src/uucore/src/lib/mods.rs index 71d288c69..52da2788a 100644 --- a/src/uucore/src/lib/mods.rs +++ b/src/uucore/src/lib/mods.rs @@ -3,6 +3,7 @@ pub mod backup_control; pub mod display; pub mod error; +pub mod line_ending; pub mod os; pub mod panic; pub mod ranges; diff --git a/src/uucore/src/lib/mods/line_ending.rs b/src/uucore/src/lib/mods/line_ending.rs new file mode 100644 index 000000000..073743fc5 --- /dev/null +++ b/src/uucore/src/lib/mods/line_ending.rs @@ -0,0 +1,49 @@ +//! Provides consistent newline/zero terminator handling for `-z`/`--zero` flags. +//! +//! See the [`LineEnding`] struct for more information. +use std::fmt::Display; + +/// Line ending of either `\n` or `\0` +/// +/// Used by various utilities that have the option to separate lines by nul +/// characters instead of `\n`. Usually, this is specified with the `-z` or +/// `--zero` flag. +/// +/// The [`Display`] implementation writes the character corresponding to the +/// variant to the formatter. +#[repr(u8)] +#[derive(Clone, Copy, Debug, Default, PartialEq)] +pub enum LineEnding { + #[default] + Newline = b'\n', + Nul = 0, +} + +impl Display for LineEnding { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Newline => writeln!(f), + Self::Nul => write!(f, "\0"), + } + } +} + +impl From for u8 { + fn from(line_ending: LineEnding) -> Self { + line_ending as Self + } +} + +impl LineEnding { + /// Create a [`LineEnding`] from a `-z`/`--zero` flag + /// + /// If `is_zero_terminated` is true, [`LineEnding::Nul`] is returned, + /// otherwise [`LineEnding::Newline`]. + pub fn from_zero_flag(is_zero_terminated: bool) -> Self { + if is_zero_terminated { + Self::Nul + } else { + Self::Newline + } + } +} From c41ccbfcad91cf3696742099fbb36cc2ba1a4388 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sun, 20 Aug 2023 11:49:58 +0200 Subject: [PATCH 050/370] website: fix path_prefix --- oranda.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/oranda.json b/oranda.json index b0a93c19a..7c52ddc27 100644 --- a/oranda.json +++ b/oranda.json @@ -2,6 +2,9 @@ "project": { "name": "uutils coreutils" }, + "build": { + "path_prefix": "coreutils" + }, "components": { "changelog": true }, From 2e27305261863985c61225fa611f2f6514a3eb5f Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 20 Aug 2023 14:49:22 +0200 Subject: [PATCH 051/370] docs: add missing "not" --- docs/src/platforms.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/platforms.md b/docs/src/platforms.md index 56ec616fc..b84516e3f 100644 --- a/docs/src/platforms.md +++ b/docs/src/platforms.md @@ -36,7 +36,7 @@ The platforms in tier 2 are more vague, but include: ## Utility compatibility per platform Not all utils work on every platform. For instance, `chgrp` is not supported on -Windows, because Windows does have the concept of groups. Below is a full table +Windows, because Windows does not have the concept of groups. Below is a full table detailing which utilities are supported for the tier 1 platforms. Note that for some utilities, not all functionality is supported on each From 6c5274512d6ff85b6804ae71e5e507155b8338e1 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sun, 20 Aug 2023 15:06:08 +0200 Subject: [PATCH 052/370] Cargo.toml: add feat_require_unix_hostid to feat_os_unix --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index ac5e45088..71c04d355 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -152,6 +152,7 @@ feat_os_unix = [ "feat_require_crate_cpp", "feat_require_unix", "feat_require_unix_utmpx", + "feat_require_unix_hostid", ] # "feat_os_windows" == set of utilities which can be built/run on modern/usual windows platforms feat_os_windows = [ From b5746f794cd74abd1c73ab354f7d9c045d570f4c Mon Sep 17 00:00:00 2001 From: tommady Date: Sun, 20 Aug 2023 22:55:38 +0800 Subject: [PATCH 053/370] date: fix panic when input will cause overflow (#5160) * fix issue 5149 * fix clippy style issue * fix spell issue * address comment * address comments * fix cspell --- src/uu/date/src/date.rs | 16 ++++++++++++++-- tests/by-util/test_date.rs | 9 +++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index adfb74128..7ec28e491 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -227,8 +227,20 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { DateSource::Human(relative_time) => { // Get the current DateTime for things like "1 year ago" let current_time = DateTime::::from(Local::now()); - let iter = std::iter::once(Ok(current_time + relative_time)); - Box::new(iter) + // double check the result is overflow or not of the current_time + relative_time + // it may cause a panic of chrono::datetime::DateTime add + match current_time.checked_add_signed(relative_time) { + Some(date) => { + let iter = std::iter::once(Ok(date)); + Box::new(iter) + } + None => { + return Err(USimpleError::new( + 1, + format!("invalid date {}", relative_time), + )); + } + } } DateSource::File(ref path) => { if path.is_dir() { diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index 669f02e33..efd16d5c7 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -395,3 +395,12 @@ fn test_invalid_date_string() { .no_stdout() .stderr_contains("invalid date"); } + +#[test] +fn test_date_overflow() { + new_ucmd!() + .arg("-d68888888888888sms") + .fails() + .no_stdout() + .stderr_contains("invalid date"); +} From 7c9f4ba92ab90a664563ee099c9231b42f432ebe Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 21 Aug 2023 08:11:38 +0200 Subject: [PATCH 054/370] Fix some clippy warnings --- src/uu/cat/src/cat.rs | 6 +++--- src/uu/chmod/src/chmod.rs | 16 ++++++++-------- src/uu/dircolors/src/dircolors.rs | 4 +--- src/uu/id/src/id.rs | 2 +- src/uu/install/src/install.rs | 2 +- src/uu/mknod/src/mknod.rs | 10 ++++------ src/uu/mv/src/mv.rs | 2 +- src/uu/od/src/prn_char.rs | 2 +- src/uu/sort/src/check.rs | 4 ++-- src/uu/sort/src/merge.rs | 2 +- src/uu/stdbuf/src/stdbuf.rs | 2 +- src/uu/sum/src/sum.rs | 4 ++-- src/uu/sync/src/sync.rs | 2 +- src/uu/tail/src/chunks.rs | 2 +- src/uu/wc/src/wc.rs | 2 +- src/uucore/src/lib/features/fs.rs | 6 +++--- tests/by-util/test_cp.rs | 8 ++++---- tests/by-util/test_factor.rs | 3 +-- tests/by-util/test_link.rs | 2 +- tests/by-util/test_mv.rs | 2 +- tests/by-util/test_rm.rs | 2 +- tests/by-util/test_shuf.rs | 4 ++-- tests/common/util.rs | 16 ++++++++-------- 23 files changed, 50 insertions(+), 55 deletions(-) diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index 2c4117a32..2b5917f35 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -192,7 +192,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { NumberingMode::None }; - let show_nonprint = vec![ + let show_nonprint = [ options::SHOW_ALL.to_owned(), options::SHOW_NONPRINTING_ENDS.to_owned(), options::SHOW_NONPRINTING_TABS.to_owned(), @@ -201,7 +201,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .iter() .any(|v| matches.get_flag(v)); - let show_ends = vec![ + let show_ends = [ options::SHOW_ENDS.to_owned(), options::SHOW_ALL.to_owned(), options::SHOW_NONPRINTING_ENDS.to_owned(), @@ -209,7 +209,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .iter() .any(|v| matches.get_flag(v)); - let show_tabs = vec![ + let show_tabs = [ options::SHOW_ALL.to_owned(), options::SHOW_TABS.to_owned(), options::SHOW_NONPRINTING_TABS.to_owned(), diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index a79886037..a8e3aa6c6 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -438,25 +438,25 @@ mod tests { fn test_extract_negative_modes() { // "chmod -w -r file" becomes "chmod -w,-r file". clap does not accept "-w,-r" as MODE. // Therefore, "w" is added as pseudo mode to pass clap. - let (c, a) = extract_negative_modes(vec!["-w", "-r", "file"].iter().map(OsString::from)); + let (c, a) = extract_negative_modes(["-w", "-r", "file"].iter().map(OsString::from)); assert_eq!(c, Some("-w,-r".to_string())); - assert_eq!(a, vec!["w", "file"]); + assert_eq!(a, ["w", "file"]); // "chmod -w file -r" becomes "chmod -w,-r file". clap does not accept "-w,-r" as MODE. // Therefore, "w" is added as pseudo mode to pass clap. - let (c, a) = extract_negative_modes(vec!["-w", "file", "-r"].iter().map(OsString::from)); + let (c, a) = extract_negative_modes(["-w", "file", "-r"].iter().map(OsString::from)); assert_eq!(c, Some("-w,-r".to_string())); - assert_eq!(a, vec!["w", "file"]); + assert_eq!(a, ["w", "file"]); // "chmod -w -- -r file" becomes "chmod -w -r file", where "-r" is interpreted as file. // Again, "w" is needed as pseudo mode. - let (c, a) = extract_negative_modes(vec!["-w", "--", "-r", "f"].iter().map(OsString::from)); + let (c, a) = extract_negative_modes(["-w", "--", "-r", "f"].iter().map(OsString::from)); assert_eq!(c, Some("-w".to_string())); - assert_eq!(a, vec!["w", "--", "-r", "f"]); + assert_eq!(a, ["w", "--", "-r", "f"]); // "chmod -- -r file" becomes "chmod -r file". - let (c, a) = extract_negative_modes(vec!["--", "-r", "file"].iter().map(OsString::from)); + let (c, a) = extract_negative_modes(["--", "-r", "file"].iter().map(OsString::from)); assert_eq!(c, None); - assert_eq!(a, vec!["--", "-r", "file"]); + assert_eq!(a, ["--", "-r", "file"]); } } diff --git a/src/uu/dircolors/src/dircolors.rs b/src/uu/dircolors/src/dircolors.rs index 19c3f7e31..5207858c2 100644 --- a/src/uu/dircolors/src/dircolors.rs +++ b/src/uu/dircolors/src/dircolors.rs @@ -168,9 +168,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { println!("{s}"); Ok(()) } - Err(s) => { - return Err(USimpleError::new(1, s)); - } + Err(s) => Err(USimpleError::new(1, s)), } } diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 9f4849f90..10e1e8f03 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -550,7 +550,7 @@ fn auditid() { println!("asid={}", auditinfo.ai_asid); } -fn id_print(state: &mut State, groups: &[u32]) { +fn id_print(state: &State, groups: &[u32]) { let uid = state.ids.as_ref().unwrap().uid; let gid = state.ids.as_ref().unwrap().gid; let euid = state.ids.as_ref().unwrap().euid; diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index e0307fe34..8aca020af 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -619,7 +619,7 @@ fn copy_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> UR if !target_dir.is_dir() { return Err(InstallError::TargetDirIsntDir(target_dir.to_path_buf()).into()); } - for sourcepath in files.iter() { + for sourcepath in files { if let Err(err) = sourcepath .metadata() .map_err_context(|| format!("cannot stat {}", sourcepath.quote())) diff --git a/src/uu/mknod/src/mknod.rs b/src/uu/mknod/src/mknod.rs index ad7618cc8..788309073 100644 --- a/src/uu/mknod/src/mknod.rs +++ b/src/uu/mknod/src/mknod.rs @@ -101,12 +101,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { matches.get_one::("major"), matches.get_one::("minor"), ) { - (_, None) | (None, _) => { - return Err(UUsageError::new( - 1, - "Special files require major and minor device numbers.", - )); - } + (_, None) | (None, _) => Err(UUsageError::new( + 1, + "Special files require major and minor device numbers.", + )), (Some(&major), Some(&minor)) => { let dev = makedev(major, minor); let exit_code = match file_type { diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 03d3881b1..518850578 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -364,7 +364,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> UR None }; - for sourcepath in files.iter() { + for sourcepath in files { if let Some(ref pb) = count_progress { pb.set_message(sourcepath.to_string_lossy().to_string()); } diff --git a/src/uu/od/src/prn_char.rs b/src/uu/od/src/prn_char.rs index 7ae6f084c..3d7682073 100644 --- a/src/uu/od/src/prn_char.rs +++ b/src/uu/od/src/prn_char.rs @@ -82,7 +82,7 @@ pub fn format_ascii_dump(bytes: &[u8]) -> String { let mut result = String::new(); result.push('>'); - for c in bytes.iter() { + for c in bytes { if *c >= 0x20 && *c <= 0x7e { result.push_str(C_CHARS[*c as usize]); } else { diff --git a/src/uu/sort/src/check.rs b/src/uu/sort/src/check.rs index 700e3681c..cc687aafc 100644 --- a/src/uu/sort/src/check.rs +++ b/src/uu/sort/src/check.rs @@ -54,7 +54,7 @@ pub fn check(path: &OsStr, settings: &GlobalSettings) -> UResult<()> { let mut prev_chunk: Option = None; let mut line_idx = 0; - for chunk in loaded_receiver.iter() { + for chunk in loaded_receiver { line_idx += 1; if let Some(prev_chunk) = prev_chunk.take() { // Check if the first element of the new chunk is greater than the last @@ -107,7 +107,7 @@ fn reader( settings: &GlobalSettings, ) -> UResult<()> { let mut carry_over = vec![]; - for recycled_chunk in receiver.iter() { + for recycled_chunk in receiver { let should_continue = chunks::read( sender, recycled_chunk, diff --git a/src/uu/sort/src/merge.rs b/src/uu/sort/src/merge.rs index 1a987fb4e..6f7f8d3b2 100644 --- a/src/uu/sort/src/merge.rs +++ b/src/uu/sort/src/merge.rs @@ -211,7 +211,7 @@ fn reader( settings: &GlobalSettings, separator: u8, ) -> UResult<()> { - for (file_idx, recycled_chunk) in recycled_receiver.iter() { + for (file_idx, recycled_chunk) in recycled_receiver { if let Some(ReaderFile { file, sender, diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index e02dd28bc..fc51ee6f7 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -130,7 +130,7 @@ fn set_command_env(command: &mut process::Command, buffer_name: &str, buffer_typ } } -fn get_preload_env(tmp_dir: &mut TempDir) -> io::Result<(String, PathBuf)> { +fn get_preload_env(tmp_dir: &TempDir) -> io::Result<(String, PathBuf)> { let (preload, extension) = preload_strings(); let inject_path = tmp_dir.path().join("libstdbuf").with_extension(extension); diff --git a/src/uu/sum/src/sum.rs b/src/uu/sum/src/sum.rs index e9b5a8e07..6a17a630d 100644 --- a/src/uu/sum/src/sum.rs +++ b/src/uu/sum/src/sum.rs @@ -33,7 +33,7 @@ fn bsd_sum(mut reader: Box) -> (usize, u16) { match reader.read(&mut buf) { Ok(n) if n != 0 => { bytes_read += n; - for &byte in buf[..n].iter() { + for &byte in &buf[..n] { checksum = checksum.rotate_right(1); checksum = checksum.wrapping_add(u16::from(byte)); } @@ -56,7 +56,7 @@ fn sysv_sum(mut reader: Box) -> (usize, u16) { match reader.read(&mut buf) { Ok(n) if n != 0 => { bytes_read += n; - for &byte in buf[..n].iter() { + for &byte in &buf[..n] { ret = ret.wrapping_add(u32::from(byte)); } } diff --git a/src/uu/sync/src/sync.rs b/src/uu/sync/src/sync.rs index 821ad639b..e135fbe7f 100644 --- a/src/uu/sync/src/sync.rs +++ b/src/uu/sync/src/sync.rs @@ -173,7 +173,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let path = Path::new(&f); if let Err(e) = open(path, OFlag::O_NONBLOCK, Mode::empty()) { if e != Errno::EACCES || (e == Errno::EACCES && path.is_dir()) { - return e.map_err_context(|| format!("error opening {}", f.quote()))?; + e.map_err_context(|| format!("error opening {}", f.quote()))?; } } } diff --git a/src/uu/tail/src/chunks.rs b/src/uu/tail/src/chunks.rs index 3aa380e20..7a1e5bc34 100644 --- a/src/uu/tail/src/chunks.rs +++ b/src/uu/tail/src/chunks.rs @@ -495,7 +495,7 @@ impl LinesChunk { fn calculate_bytes_offset_from(&self, offset: usize) -> usize { let mut lines_offset = offset; let mut bytes_offset = 0; - for byte in self.get_buffer().iter() { + for byte in self.get_buffer() { if lines_offset == 0 { break; } diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index 9fb8ca7a6..b79559b29 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -686,7 +686,7 @@ fn compute_number_width(inputs: &Inputs, settings: &Settings) -> usize { let mut minimum_width = 1; let mut total: u64 = 0; - for input in inputs.iter() { + for input in inputs { match input { Input::Stdin(_) => minimum_width = MINIMUM_WIDTH, Input::Path(path) => { diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index 5804a2235..f7aa157a0 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -845,7 +845,7 @@ mod tests { let path1 = temp_file.path(); let path2 = temp_file.path(); - assert_eq!(are_hardlinks_to_same_file(&path1, &path2), true); + assert!(are_hardlinks_to_same_file(&path1, &path2)); } #[cfg(unix)] @@ -860,7 +860,7 @@ mod tests { let path1 = temp_file1.path(); let path2 = temp_file2.path(); - assert_eq!(are_hardlinks_to_same_file(&path1, &path2), false); + assert!(are_hardlinks_to_same_file(&path1, &path2)); } #[cfg(unix)] @@ -873,6 +873,6 @@ mod tests { let path2 = temp_file.path().with_extension("hardlink"); fs::hard_link(&path1, &path2).unwrap(); - assert_eq!(are_hardlinks_to_same_file(&path1, &path2), true); + assert!(are_hardlinks_to_same_file(&path1, &path2)); } } diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 18f3829a2..6c07da22e 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -2022,12 +2022,12 @@ fn test_cp_reflink_always_override() { const USERDIR: &str = "dir/"; const MOUNTPOINT: &str = "mountpoint/"; - let src1_path: &str = &vec![MOUNTPOINT, USERDIR, "src1"].concat(); - let src2_path: &str = &vec![MOUNTPOINT, USERDIR, "src2"].concat(); - let dst_path: &str = &vec![MOUNTPOINT, USERDIR, "dst"].concat(); + let src1_path: &str = &[MOUNTPOINT, USERDIR, "src1"].concat(); + let src2_path: &str = &[MOUNTPOINT, USERDIR, "src2"].concat(); + let dst_path: &str = &[MOUNTPOINT, USERDIR, "dst"].concat(); scene.fixtures.mkdir(ROOTDIR); - scene.fixtures.mkdir(vec![ROOTDIR, USERDIR].concat()); + scene.fixtures.mkdir([ROOTDIR, USERDIR].concat()); // Setup: // Because neither `mkfs.btrfs` not btrfs `mount` options allow us to have a mountpoint owned diff --git a/tests/by-util/test_factor.rs b/tests/by-util/test_factor.rs index cf3744964..381b45484 100644 --- a/tests/by-util/test_factor.rs +++ b/tests/by-util/test_factor.rs @@ -173,7 +173,6 @@ fn test_random() { break; } } - let factor = factor; match product.checked_mul(factor) { Some(p) => { @@ -317,7 +316,7 @@ fn run(input_string: &[u8], output_string: &[u8]) { fn test_primes_with_exponents() { let mut input_string = String::new(); let mut output_string = String::new(); - for primes in PRIMES_BY_BITS.iter() { + for primes in PRIMES_BY_BITS { for &prime in *primes { input_string.push_str(&(format!("{prime} "))[..]); output_string.push_str(&(format!("{prime}: {prime}\n"))[..]); diff --git a/tests/by-util/test_link.rs b/tests/by-util/test_link.rs index 3c068af93..7e422cb55 100644 --- a/tests/by-util/test_link.rs +++ b/tests/by-util/test_link.rs @@ -58,7 +58,7 @@ fn test_link_one_argument() { #[test] fn test_link_three_arguments() { let (_, mut ucmd) = at_and_ucmd!(); - let arguments = vec![ + let arguments = [ "test_link_argument1", "test_link_argument2", "test_link_argument3", diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index ceaa4ba22..afbe28578 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -1278,7 +1278,7 @@ fn test_mv_verbose() { #[test] #[cfg(any(target_os = "linux", target_os = "android"))] // mkdir does not support -m on windows. Freebsd doesn't return a permission error either. -#[cfg(features = "mkdir")] +#[cfg(feature = "mkdir")] fn test_mv_permission_error() { let scene = TestScenario::new("mkdir"); let folder1 = "bar"; diff --git a/tests/by-util/test_rm.rs b/tests/by-util/test_rm.rs index 737c4fa79..ae8fcfe99 100644 --- a/tests/by-util/test_rm.rs +++ b/tests/by-util/test_rm.rs @@ -478,7 +478,7 @@ fn test_rm_prompts() { // Needed for talking with stdin on platforms where CRLF or LF matters const END_OF_LINE: &str = if cfg!(windows) { "\r\n" } else { "\n" }; - let mut answers = vec![ + let mut answers = [ "rm: descend into directory 'a'?", "rm: remove write-protected regular empty file 'a/empty-no-write'?", "rm: remove symbolic link 'a/slink'?", diff --git a/tests/by-util/test_shuf.rs b/tests/by-util/test_shuf.rs index 44282b8a3..b56fbe7d9 100644 --- a/tests/by-util/test_shuf.rs +++ b/tests/by-util/test_shuf.rs @@ -71,7 +71,7 @@ fn test_echo() { #[test] fn test_head_count() { let repeat_limit = 5; - let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + let input_seq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let input = input_seq .iter() .map(ToString::to_string) @@ -102,7 +102,7 @@ fn test_head_count() { #[test] fn test_repeat() { let repeat_limit = 15000; - let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + let input_seq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let input = input_seq .iter() .map(ToString::to_string) diff --git a/tests/common/util.rs b/tests/common/util.rs index 995312f08..8ef5f517a 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -541,7 +541,7 @@ impl CmdResult { let contents = String::from_utf8(read_scenario_fixture(&self.tmpd, file_rel_path)).unwrap(); let possible_values = template_vars.iter().map(|vars| { let mut contents = contents.clone(); - for kv in vars.iter() { + for kv in vars { contents = contents.replace(&kv.0, &kv.1); } contents @@ -2211,12 +2211,12 @@ impl UChild { let join_handle = thread::spawn(move || { let mut writer = BufWriter::new(stdin); - match writer.write_all(&content).and_then(|_| writer.flush()) { + match writer.write_all(&content).and_then(|()| writer.flush()) { Err(error) if !ignore_stdin_write_error => Err(io::Error::new( io::ErrorKind::Other, format!("failed to write to stdin of child: {error}"), )), - Ok(_) | Err(_) => Ok(()), + Ok(()) | Err(_) => Ok(()), } }); @@ -2263,12 +2263,12 @@ impl UChild { pub fn try_write_in>>(&mut self, data: T) -> io::Result<()> { let stdin = self.raw.stdin.as_mut().unwrap(); - match stdin.write_all(&data.into()).and_then(|_| stdin.flush()) { + match stdin.write_all(&data.into()).and_then(|()| stdin.flush()) { Err(error) if !self.ignore_stdin_write_error => Err(io::Error::new( io::ErrorKind::Other, format!("failed to write to stdin of child: {error}"), )), - Ok(_) | Err(_) => Ok(()), + Ok(()) | Err(_) => Ok(()), } } @@ -2505,11 +2505,11 @@ pub fn expected_result(ts: &TestScenario, args: &[&str]) -> std::result::Result< /// This is a convenience wrapper to run a ucmd with root permissions. /// It can be used to test programs when being root is needed -/// This runs 'sudo -E --non-interactive target/debug/coreutils util_name args` +/// This runs `sudo -E --non-interactive target/debug/coreutils util_name args` /// This is primarily designed to run in an environment where whoami is in $path /// and where non-interactive sudo is possible. /// To check if i) non-interactive sudo is possible and ii) if sudo works, this runs: -/// 'sudo -E --non-interactive whoami' first. +/// `sudo -E --non-interactive whoami` first. /// /// This return an `Err()` if run inside CICD because there's no 'sudo'. /// @@ -3279,7 +3279,7 @@ mod tests { std::assert_eq!(error.to_string(), "kill: Timeout of '0s' reached"); } Err(error) => panic!("Assertion failed: Expected error with timeout but was: {error}"), - Ok(_) => panic!("Assertion failed: Expected timeout of `try_kill`."), + Ok(()) => panic!("Assertion failed: Expected timeout of `try_kill`."), } } From 9aa59ef9150d613d8ce481445f7477539ebd4632 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 21 Aug 2023 08:33:57 +0200 Subject: [PATCH 055/370] Don't warn too_many_lines for generated map --- build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/build.rs b/build.rs index 09b33fa91..d210e2a2e 100644 --- a/build.rs +++ b/build.rs @@ -40,6 +40,7 @@ pub fn main() { mf.write_all( "type UtilityMap = phf::OrderedMap<&'static str, (fn(T) -> i32, fn() -> Command)>;\n\ \n\ + #[allow(clippy::too_many_lines)] fn util_map() -> UtilityMap {\n" .as_bytes(), ) From 57a2a8323cc1b54f0f0c09d4d91dc179bf00a187 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 21 Aug 2023 07:34:45 +0200 Subject: [PATCH 056/370] fuzz the test command --- .github/workflows/CICD.yml | 7 + fuzz/Cargo.toml | 15 +- fuzz/fuzz_targets/fuzz_test.rs | 291 +++++++++++++++++++++++++++++++++ 3 files changed, 309 insertions(+), 4 deletions(-) create mode 100644 fuzz/fuzz_targets/fuzz_test.rs diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 589126b6f..78b1faa55 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -142,6 +142,13 @@ jobs: ## Run it cd fuzz cargo +nightly fuzz run fuzz_date -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 + - name: Run fuzz_test for XX seconds + continue-on-error: true + shell: bash + run: | + ## Run it + cd fuzz + cargo +nightly fuzz run fuzz_test -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - name: Run fuzz_parse_glob for XX seconds shell: bash run: | diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index c8565d691..91a85b45a 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -9,12 +9,13 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.4" +libc = "0.2" +rand = { version = "0.8", features = ["small_rng"] } -[dependencies.uucore] -path = "../src/uucore/" +uucore = { path = "../src/uucore/" } +uu_date = { path = "../src/uu/date/" } +uu_test = { path = "../src/uu/test/" } -[dependencies.uu_date] -path = "../src/uu/date/" # Prevent this from interfering with workspaces [workspace] @@ -26,6 +27,12 @@ path = "fuzz_targets/fuzz_date.rs" test = false doc = false +[[bin]] +name = "fuzz_test" +path = "fuzz_targets/fuzz_test.rs" +test = false +doc = false + [[bin]] name = "fuzz_parse_glob" path = "fuzz_targets/fuzz_parse_glob.rs" diff --git a/fuzz/fuzz_targets/fuzz_test.rs b/fuzz/fuzz_targets/fuzz_test.rs new file mode 100644 index 000000000..537e21abd --- /dev/null +++ b/fuzz/fuzz_targets/fuzz_test.rs @@ -0,0 +1,291 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. +// spell-checker:ignore STRINGSTRING INTEGERINTEGER FILEFILE + +#![no_main] +use libfuzzer_sys::fuzz_target; +use uu_test::uumain; + +use rand::seq::SliceRandom; +use rand::Rng; +use std::ffi::OsString; + +use libc::{dup, dup2, STDOUT_FILENO}; +use std::process::Command; + +#[derive(PartialEq, Debug, Clone)] +enum ArgType { + STRING, + STRINGSTRING, + INTEGER, + INTEGERINTEGER, + FILE, + FILEFILE, + // Add any other types as needed +} + +fn run_gnu_test(args: &[OsString]) -> Result<(String, i32), std::io::Error> { + let mut command = Command::new("test"); + for arg in args { + command.arg(arg); + } + let output = command.output()?; + let exit_status = output.status.code().unwrap_or(-1); // Capture the exit status code + Ok(( + String::from_utf8_lossy(&output.stdout).to_string(), + exit_status, + )) +} + +fn generate_random_string(max_length: usize) -> String { + let mut rng = rand::thread_rng(); + let valid_utf8: Vec = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + .chars() + .collect(); + let invalid_utf8 = [0xC3, 0x28]; // Invalid UTF-8 sequence + let mut result = String::new(); + + for _ in 0..rng.gen_range(1..=max_length) { + if rng.gen_bool(0.9) { + let ch = valid_utf8.choose(&mut rng).unwrap(); + result.push(*ch); + } else { + let ch = invalid_utf8.choose(&mut rng).unwrap(); + if let Some(c) = char::from_u32(*ch as u32) { + result.push(c); + } + } + } + + result +} + +#[derive(Debug, Clone)] +struct TestArg { + arg: String, + arg_type: ArgType, +} + +fn generate_random_path(rng: &mut dyn rand::RngCore) -> &'static str { + match rng.gen_range(0..=3) { + 0 => "/dev/null", + 1 => "/dev/random", + 2 => "/tmp", + _ => "/dev/urandom", + } +} + +fn generate_test_args() -> Vec { + vec![ + TestArg { + arg: "-z".to_string(), + arg_type: ArgType::STRING, + }, + TestArg { + arg: "-n".to_string(), + arg_type: ArgType::STRING, + }, + TestArg { + arg: "=".to_string(), + arg_type: ArgType::STRINGSTRING, + }, + TestArg { + arg: "!=".to_string(), + arg_type: ArgType::STRINGSTRING, + }, + TestArg { + arg: "-eq".to_string(), + arg_type: ArgType::INTEGERINTEGER, + }, + TestArg { + arg: "-ne".to_string(), + arg_type: ArgType::INTEGERINTEGER, + }, + TestArg { + arg: "-gt".to_string(), + arg_type: ArgType::INTEGERINTEGER, + }, + TestArg { + arg: "-ge".to_string(), + arg_type: ArgType::INTEGERINTEGER, + }, + TestArg { + arg: "-lt".to_string(), + arg_type: ArgType::INTEGERINTEGER, + }, + TestArg { + arg: "-le".to_string(), + arg_type: ArgType::INTEGERINTEGER, + }, + TestArg { + arg: "-f".to_string(), + arg_type: ArgType::FILE, + }, + TestArg { + arg: "-d".to_string(), + arg_type: ArgType::FILE, + }, + TestArg { + arg: "-e".to_string(), + arg_type: ArgType::FILE, + }, + TestArg { + arg: "-ef".to_string(), + arg_type: ArgType::FILEFILE, + }, + TestArg { + arg: "-nt".to_string(), + arg_type: ArgType::FILEFILE, + }, + ] +} + +fn generate_test_arg() -> String { + let mut rng = rand::thread_rng(); + let test_args = generate_test_args(); + let mut arg = String::new(); + + let choice = rng.gen_range(0..=5); + + match choice { + 0 => { + arg.push_str(&rng.gen_range(-100..=100).to_string()); + } + 1 | 2 | 3 => { + let test_arg = test_args + .choose(&mut rng) + .expect("Failed to choose a random test argument"); + if test_arg.arg_type == ArgType::INTEGER { + arg.push_str(&format!( + "{} {} {}", + &rng.gen_range(-100..=100).to_string(), + test_arg.arg, + &rng.gen_range(-100..=100).to_string() + )); + } else if test_arg.arg_type == ArgType::STRINGSTRING { + let random_str = generate_random_string(rng.gen_range(1..=10)); + let random_str2 = generate_random_string(rng.gen_range(1..=10)); + + arg.push_str(&format!( + "{} {} {}", + &random_str, test_arg.arg, &random_str2 + )); + } else if test_arg.arg_type == ArgType::STRING { + let random_str = generate_random_string(rng.gen_range(1..=10)); + arg.push_str(&format!("{} {}", test_arg.arg, &random_str)); + } else if test_arg.arg_type == ArgType::FILEFILE { + let path = generate_random_path(&mut rng); + let path2 = generate_random_path(&mut rng); + arg.push_str(&format!("{} {} {}", path, test_arg.arg, path2)); + } else if test_arg.arg_type == ArgType::FILE { + let path = generate_random_path(&mut rng); + arg.push_str(&format!("{} {}", test_arg.arg, path)); + } + } + 4 => { + let random_str = generate_random_string(rng.gen_range(1..=10)); + arg.push_str(&random_str); + } + _ => { + let path = generate_random_path(&mut rng); + + let file_test_args: Vec = test_args + .iter() + .filter(|ta| ta.arg_type == ArgType::FILE) + .cloned() + .collect(); + + if let Some(test_arg) = file_test_args.choose(&mut rng) { + arg.push_str(&format!("{}{}", test_arg.arg, path)); + } + } + } + + arg +} + +fuzz_target!(|_data: &[u8]| { + let mut rng = rand::thread_rng(); + let max_args = rng.gen_range(1..=6); + let mut args = vec![OsString::from("test")]; + let uumain_exit_status; + + for _ in 0..max_args { + args.push(OsString::from(generate_test_arg())); + } + + // Save the original stdout file descriptor + let original_stdout_fd = unsafe { dup(STDOUT_FILENO) }; + println!("Running test {:?}", &args[1..]); + // Create a pipe to capture stdout + let mut pipe_fds = [-1; 2]; + unsafe { libc::pipe(pipe_fds.as_mut_ptr()) }; + + { + // Redirect stdout to the write end of the pipe + unsafe { dup2(pipe_fds[1], STDOUT_FILENO) }; + + // Run uumain with the provided arguments + uumain_exit_status = uumain(args.clone().into_iter()); + + // Restore original stdout + unsafe { dup2(original_stdout_fd, STDOUT_FILENO) }; + unsafe { libc::close(original_stdout_fd) }; + } + // Close the write end of the pipe + unsafe { libc::close(pipe_fds[1]) }; + + // Read captured output from the read end of the pipe + let mut captured_output = Vec::new(); + let mut read_buffer = [0; 1024]; + loop { + let bytes_read = unsafe { + libc::read( + pipe_fds[0], + read_buffer.as_mut_ptr() as *mut libc::c_void, + read_buffer.len(), + ) + }; + if bytes_read <= 0 { + break; + } + captured_output.extend_from_slice(&read_buffer[..bytes_read as usize]); + } + + // Close the read end of the pipe + unsafe { libc::close(pipe_fds[0]) }; + + // Convert captured output to a string + let my_output = String::from_utf8_lossy(&captured_output) + .to_string() + .trim() + .to_owned(); + + // Run GNU test with the provided arguments and compare the output + match run_gnu_test(&args[1..]) { + Ok((gnu_output, gnu_exit_status)) => { + let gnu_output = gnu_output.trim().to_owned(); + println!("gnu_exit_status {}", gnu_exit_status); + println!("uumain_exit_status {}", uumain_exit_status); + if my_output != gnu_output || uumain_exit_status != gnu_exit_status { + println!("Discrepancy detected!"); + println!("Test: {:?}", &args[1..]); + println!("My output: {}", my_output); + println!("GNU output: {}", gnu_output); + println!("My exit status: {}", uumain_exit_status); + println!("GNU exit status: {}", gnu_exit_status); + panic!(); + } else { + println!( + "Outputs and exit statuses matched for expression {:?}", + &args[1..] + ); + } + } + Err(_) => { + println!("GNU test execution failed for expression {:?}", &args[1..]); + } + } +}); From bfca6bf70f0e6e52136fa4034a351700c8fec5a9 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 21 Aug 2023 10:49:27 +0200 Subject: [PATCH 057/370] Add license headers on all files --- src/uu/cat/src/splice.rs | 4 ++++ src/uu/chcon/src/chcon.rs | 4 ++++ src/uu/chcon/src/errors.rs | 4 ++++ src/uu/chcon/src/fts.rs | 4 ++++ src/uu/csplit/src/csplit.rs | 4 ++++ src/uu/csplit/src/csplit_error.rs | 4 ++++ src/uu/csplit/src/patterns.rs | 4 ++++ src/uu/csplit/src/split_name.rs | 4 ++++ src/uu/dd/src/parseargs/unit_tests.rs | 4 ++++ src/uu/dircolors/src/colors.rs | 4 ++++ src/uu/head/src/take.rs | 4 ++++ src/uu/install/src/mode.rs | 4 ++++ src/uu/mknod/src/parsemode.rs | 4 ++++ src/uu/nl/src/helper.rs | 4 ++++ src/uu/numfmt/src/format.rs | 4 ++++ src/uu/numfmt/src/options.rs | 4 ++++ src/uu/numfmt/src/units.rs | 4 ++++ src/uu/od/src/byteorder_io.rs | 4 ++++ src/uu/od/src/formatteriteminfo.rs | 4 ++++ src/uu/od/src/inputdecoder.rs | 4 ++++ src/uu/od/src/inputoffset.rs | 4 ++++ src/uu/od/src/mockstream.rs | 4 ++++ src/uu/od/src/multifilereader.rs | 4 ++++ src/uu/od/src/output_info.rs | 4 ++++ src/uu/od/src/parse_formats.rs | 4 ++++ src/uu/od/src/parse_inputs.rs | 4 ++++ src/uu/od/src/parse_nrofbytes.rs | 4 ++++ src/uu/od/src/partialreader.rs | 4 ++++ src/uu/od/src/peekreader.rs | 4 ++++ src/uu/od/src/prn_char.rs | 4 ++++ src/uu/od/src/prn_float.rs | 4 ++++ src/uu/od/src/prn_int.rs | 4 ++++ src/uu/printf/src/mod.rs | 4 ++++ src/uu/printf/src/printf.rs | 4 ++++ src/uu/runcon/src/errors.rs | 4 ++++ src/uu/runcon/src/runcon.rs | 4 ++++ src/uu/seq/src/extendedbigdecimal.rs | 4 ++++ src/uu/seq/src/extendedbigint.rs | 4 ++++ src/uu/seq/src/number.rs | 4 ++++ src/uu/seq/src/numberparse.rs | 4 ++++ src/uu/shuf/src/rand_read_adapter.rs | 4 ++++ src/uu/sort/src/merge.rs | 4 ++++ src/uu/sort/src/tmp_dir.rs | 4 ++++ src/uu/split/src/platform/mod.rs | 4 ++++ src/uu/split/src/platform/unix.rs | 4 ++++ src/uu/split/src/platform/windows.rs | 4 ++++ src/uu/stdbuf/build.rs | 4 ++++ src/uu/stdbuf/src/libstdbuf/build.rs | 4 ++++ src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs | 4 ++++ src/uu/test/src/error.rs | 4 ++++ src/uu/wc/src/count_fast.rs | 4 ++++ src/uu/wc/src/countable.rs | 4 ++++ src/uu/wc/src/utf8/mod.rs | 4 ++++ src/uu/wc/src/utf8/read.rs | 4 ++++ src/uu/wc/src/word_count.rs | 4 ++++ src/uu/yes/src/splice.rs | 4 ++++ src/uucore/src/lib/features.rs | 4 ++++ src/uucore/src/lib/features/memo.rs | 4 ++++ src/uucore/src/lib/features/pipes.rs | 4 ++++ src/uucore/src/lib/features/ringbuffer.rs | 4 ++++ src/uucore/src/lib/features/tokenize/mod.rs | 4 ++++ .../src/lib/features/tokenize/num_format/format_field.rs | 4 ++++ src/uucore/src/lib/features/tokenize/num_format/formatter.rs | 4 ++++ .../features/tokenize/num_format/formatters/base_conv/mod.rs | 4 ++++ .../tokenize/num_format/formatters/base_conv/tests.rs | 4 ++++ .../tokenize/num_format/formatters/cninetyninehexfloatf.rs | 4 ++++ .../src/lib/features/tokenize/num_format/formatters/decf.rs | 4 ++++ .../features/tokenize/num_format/formatters/float_common.rs | 4 ++++ .../src/lib/features/tokenize/num_format/formatters/floatf.rs | 4 ++++ .../src/lib/features/tokenize/num_format/formatters/intf.rs | 4 ++++ .../src/lib/features/tokenize/num_format/formatters/mod.rs | 4 ++++ .../src/lib/features/tokenize/num_format/formatters/scif.rs | 4 ++++ src/uucore/src/lib/features/tokenize/num_format/mod.rs | 4 ++++ src/uucore/src/lib/features/tokenize/num_format/num_format.rs | 4 ++++ src/uucore/src/lib/features/tokenize/sub.rs | 4 ++++ src/uucore/src/lib/features/tokenize/token.rs | 4 ++++ src/uucore/src/lib/features/tokenize/unescaped_text.rs | 4 ++++ src/uucore/src/lib/lib.rs | 4 ++++ src/uucore/src/lib/mods.rs | 4 ++++ src/uucore/src/lib/mods/backup_control.rs | 4 ++++ src/uucore/src/lib/mods/display.rs | 4 ++++ src/uucore/src/lib/mods/error.rs | 4 ++++ src/uucore/src/lib/mods/line_ending.rs | 4 ++++ src/uucore/src/lib/mods/os.rs | 4 ++++ src/uucore/src/lib/mods/panic.rs | 4 ++++ src/uucore/src/lib/mods/quoting_style.rs | 4 ++++ src/uucore/src/lib/mods/version_cmp.rs | 4 ++++ src/uucore/src/lib/parser.rs | 4 ++++ src/uucore/src/lib/parser/parse_glob.rs | 4 ++++ src/uucore/src/lib/parser/shortcut_value_parser.rs | 4 ++++ src/uucore_procs/src/lib.rs | 4 ++++ tests/benches/factor/benches/gcd.rs | 4 ++++ tests/benches/factor/benches/table.rs | 4 ++++ tests/by-util/test_arch.rs | 4 ++++ tests/by-util/test_base64.rs | 4 ++++ tests/by-util/test_basename.rs | 4 ++++ tests/by-util/test_basenc.rs | 4 ++++ tests/by-util/test_cat.rs | 4 ++++ tests/by-util/test_chcon.rs | 4 ++++ tests/by-util/test_chgrp.rs | 4 ++++ tests/by-util/test_chmod.rs | 4 ++++ tests/by-util/test_chown.rs | 4 ++++ tests/by-util/test_chroot.rs | 4 ++++ tests/by-util/test_cksum.rs | 4 ++++ tests/by-util/test_comm.rs | 4 ++++ tests/by-util/test_cp.rs | 4 ++++ tests/by-util/test_csplit.rs | 4 ++++ tests/by-util/test_cut.rs | 4 ++++ tests/by-util/test_date.rs | 4 ++++ tests/by-util/test_dd.rs | 4 ++++ tests/by-util/test_df.rs | 4 ++++ tests/by-util/test_dir.rs | 4 ++++ tests/by-util/test_dircolors.rs | 4 ++++ tests/by-util/test_dirname.rs | 4 ++++ tests/by-util/test_echo.rs | 4 ++++ tests/by-util/test_env.rs | 4 ++++ tests/by-util/test_expand.rs | 4 ++++ tests/by-util/test_expr.rs | 4 ++++ tests/by-util/test_false.rs | 4 ++++ tests/by-util/test_fmt.rs | 4 ++++ tests/by-util/test_fold.rs | 4 ++++ tests/by-util/test_hashsum.rs | 4 ++++ tests/by-util/test_hostid.rs | 4 ++++ tests/by-util/test_hostname.rs | 4 ++++ tests/by-util/test_install.rs | 4 ++++ tests/by-util/test_join.rs | 4 ++++ tests/by-util/test_kill.rs | 4 ++++ tests/by-util/test_link.rs | 4 ++++ tests/by-util/test_ln.rs | 4 ++++ tests/by-util/test_logname.rs | 4 ++++ tests/by-util/test_ls.rs | 4 ++++ tests/by-util/test_mkdir.rs | 4 ++++ tests/by-util/test_mkfifo.rs | 4 ++++ tests/by-util/test_mknod.rs | 4 ++++ tests/by-util/test_mktemp.rs | 4 ++++ tests/by-util/test_more.rs | 4 ++++ tests/by-util/test_mv.rs | 4 ++++ tests/by-util/test_nice.rs | 4 ++++ tests/by-util/test_nl.rs | 4 ++++ tests/by-util/test_nohup.rs | 4 ++++ tests/by-util/test_nproc.rs | 4 ++++ tests/by-util/test_numfmt.rs | 4 ++++ tests/by-util/test_paste.rs | 4 ++++ tests/by-util/test_pathchk.rs | 4 ++++ tests/by-util/test_pr.rs | 4 ++++ tests/by-util/test_printenv.rs | 4 ++++ tests/by-util/test_printf.rs | 4 ++++ tests/by-util/test_ptx.rs | 4 ++++ tests/by-util/test_pwd.rs | 4 ++++ tests/by-util/test_readlink.rs | 4 ++++ tests/by-util/test_realpath.rs | 4 ++++ tests/by-util/test_relpath.rs | 4 ++++ tests/by-util/test_rm.rs | 4 ++++ tests/by-util/test_rmdir.rs | 4 ++++ tests/by-util/test_runcon.rs | 4 ++++ tests/by-util/test_seq.rs | 4 ++++ tests/by-util/test_shred.rs | 4 ++++ tests/by-util/test_shuf.rs | 4 ++++ tests/by-util/test_sleep.rs | 4 ++++ tests/by-util/test_stdbuf.rs | 4 ++++ tests/by-util/test_stty.rs | 4 ++++ tests/by-util/test_sum.rs | 4 ++++ tests/by-util/test_sync.rs | 4 ++++ tests/by-util/test_tac.rs | 4 ++++ tests/by-util/test_tee.rs | 4 ++++ tests/by-util/test_timeout.rs | 4 ++++ tests/by-util/test_touch.rs | 4 ++++ tests/by-util/test_tr.rs | 4 ++++ tests/by-util/test_true.rs | 4 ++++ tests/by-util/test_tsort.rs | 4 ++++ tests/by-util/test_tty.rs | 4 ++++ tests/by-util/test_uname.rs | 4 ++++ tests/by-util/test_unexpand.rs | 4 ++++ tests/by-util/test_uniq.rs | 4 ++++ tests/by-util/test_unlink.rs | 4 ++++ tests/by-util/test_uptime.rs | 4 ++++ tests/by-util/test_users.rs | 4 ++++ tests/by-util/test_vdir.rs | 4 ++++ tests/by-util/test_wc.rs | 4 ++++ tests/by-util/test_yes.rs | 4 ++++ tests/common/mod.rs | 4 ++++ tests/fixtures/install/helloworld.rs | 4 ++++ tests/test_util_name.rs | 4 ++++ tests/tests.rs | 4 ++++ 184 files changed, 736 insertions(+) diff --git a/src/uu/cat/src/splice.rs b/src/uu/cat/src/splice.rs index 26802c7e6..5a9e8738e 100644 --- a/src/uu/cat/src/splice.rs +++ b/src/uu/cat/src/splice.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use super::{CatResult, FdReadable, InputHandle}; use nix::unistd; diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index 63ae3abea..ec111c853 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) RFILE #![allow(clippy::upper_case_acronyms)] diff --git a/src/uu/chcon/src/errors.rs b/src/uu/chcon/src/errors.rs index 0bd61ec4a..10d5735a0 100644 --- a/src/uu/chcon/src/errors.rs +++ b/src/uu/chcon/src/errors.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::ffi::OsString; use std::fmt::Write; use std::io; diff --git a/src/uu/chcon/src/fts.rs b/src/uu/chcon/src/fts.rs index 89dd6184d..a81cb39b6 100644 --- a/src/uu/chcon/src/fts.rs +++ b/src/uu/chcon/src/fts.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::ffi::{CStr, CString, OsStr}; use std::marker::PhantomData; use std::os::raw::{c_int, c_long, c_short}; diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs index d1925308e..6c9a776c3 100644 --- a/src/uu/csplit/src/csplit.rs +++ b/src/uu/csplit/src/csplit.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #![crate_name = "uu_csplit"] // spell-checker:ignore rustdoc #![allow(rustdoc::private_intra_doc_links)] diff --git a/src/uu/csplit/src/csplit_error.rs b/src/uu/csplit/src/csplit_error.rs index b81a331a2..1559a29f8 100644 --- a/src/uu/csplit/src/csplit_error.rs +++ b/src/uu/csplit/src/csplit_error.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::io; use thiserror::Error; diff --git a/src/uu/csplit/src/patterns.rs b/src/uu/csplit/src/patterns.rs index 652b024d8..fd96fd9fb 100644 --- a/src/uu/csplit/src/patterns.rs +++ b/src/uu/csplit/src/patterns.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (regex) SKIPTO UPTO ; (vars) ntimes use crate::csplit_error::CsplitError; diff --git a/src/uu/csplit/src/split_name.rs b/src/uu/csplit/src/split_name.rs index 19e3ac9c2..4d94b56a9 100644 --- a/src/uu/csplit/src/split_name.rs +++ b/src/uu/csplit/src/split_name.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (regex) diuox use regex::Regex; diff --git a/src/uu/dd/src/parseargs/unit_tests.rs b/src/uu/dd/src/parseargs/unit_tests.rs index 54e17b882..a190fd75b 100644 --- a/src/uu/dd/src/parseargs/unit_tests.rs +++ b/src/uu/dd/src/parseargs/unit_tests.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// 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, 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, oconv use super::*; diff --git a/src/uu/dircolors/src/colors.rs b/src/uu/dircolors/src/colors.rs index d864a23b3..c0a981db8 100644 --- a/src/uu/dircolors/src/colors.rs +++ b/src/uu/dircolors/src/colors.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) EIGHTBIT ETERM MULTIHARDLINK cpio dtterm jfbterm konsole kterm mlterm rmvb rxvt stat'able svgz tmux webm xspf COLORTERM tzst avif tzst mjpg mjpeg webp dpkg rpmnew rpmorig rpmsave pub const INTERNAL_DB: &str = r#"# Configuration file for dircolors, a utility to help you set the diff --git a/src/uu/head/src/take.rs b/src/uu/head/src/take.rs index 47beba8a4..da48afd6a 100644 --- a/src/uu/head/src/take.rs +++ b/src/uu/head/src/take.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Take all but the last elements of an iterator. use std::io::Read; diff --git a/src/uu/install/src/mode.rs b/src/uu/install/src/mode.rs index 6c76dd016..f9018e16f 100644 --- a/src/uu/install/src/mode.rs +++ b/src/uu/install/src/mode.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::fs; use std::path::Path; #[cfg(not(windows))] diff --git a/src/uu/mknod/src/parsemode.rs b/src/uu/mknod/src/parsemode.rs index 2767cb303..0ec80c6b4 100644 --- a/src/uu/mknod/src/parsemode.rs +++ b/src/uu/mknod/src/parsemode.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (path) osrelease use libc::{mode_t, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR}; diff --git a/src/uu/nl/src/helper.rs b/src/uu/nl/src/helper.rs index 39d13d565..fe550e6a0 100644 --- a/src/uu/nl/src/helper.rs +++ b/src/uu/nl/src/helper.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) conv use crate::options; diff --git a/src/uu/numfmt/src/format.rs b/src/uu/numfmt/src/format.rs index eb75f7554..08bb0c2e7 100644 --- a/src/uu/numfmt/src/format.rs +++ b/src/uu/numfmt/src/format.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore powf use uucore::display::Quotable; diff --git a/src/uu/numfmt/src/options.rs b/src/uu/numfmt/src/options.rs index bef4a8ce3..07b364f18 100644 --- a/src/uu/numfmt/src/options.rs +++ b/src/uu/numfmt/src/options.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::str::FromStr; use crate::units::Unit; diff --git a/src/uu/numfmt/src/units.rs b/src/uu/numfmt/src/units.rs index 08c7e4d3b..585bae461 100644 --- a/src/uu/numfmt/src/units.rs +++ b/src/uu/numfmt/src/units.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::fmt; pub const SI_BASES: [f64; 10] = [1., 1e3, 1e6, 1e9, 1e12, 1e15, 1e18, 1e21, 1e24, 1e27]; diff --git a/src/uu/od/src/byteorder_io.rs b/src/uu/od/src/byteorder_io.rs index c22097da2..545016ff3 100644 --- a/src/uu/od/src/byteorder_io.rs +++ b/src/uu/od/src/byteorder_io.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) byteorder // workaround until https://github.com/BurntSushi/byteorder/issues/41 has been fixed diff --git a/src/uu/od/src/formatteriteminfo.rs b/src/uu/od/src/formatteriteminfo.rs index 00ee2ee20..9e3c2e836 100644 --- a/src/uu/od/src/formatteriteminfo.rs +++ b/src/uu/od/src/formatteriteminfo.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) formatteriteminfo use std::fmt; diff --git a/src/uu/od/src/inputdecoder.rs b/src/uu/od/src/inputdecoder.rs index 318571cf3..6f08eba12 100644 --- a/src/uu/od/src/inputdecoder.rs +++ b/src/uu/od/src/inputdecoder.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use half::f16; use std::io; diff --git a/src/uu/od/src/inputoffset.rs b/src/uu/od/src/inputoffset.rs index ddaf747f1..a19600055 100644 --- a/src/uu/od/src/inputoffset.rs +++ b/src/uu/od/src/inputoffset.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Radix { Decimal, diff --git a/src/uu/od/src/mockstream.rs b/src/uu/od/src/mockstream.rs index a1ce0dd68..925d52f7e 100644 --- a/src/uu/od/src/mockstream.rs +++ b/src/uu/od/src/mockstream.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // https://github.com/lazy-bitfield/rust-mockstream/pull/2 use std::io::{Cursor, Error, ErrorKind, Read, Result}; diff --git a/src/uu/od/src/multifilereader.rs b/src/uu/od/src/multifilereader.rs index 38e192588..f7575e975 100644 --- a/src/uu/od/src/multifilereader.rs +++ b/src/uu/od/src/multifilereader.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) multifile curr fnames fname xfrd fillloop mockstream use std::fs::File; diff --git a/src/uu/od/src/output_info.rs b/src/uu/od/src/output_info.rs index 211574a61..96c01f906 100644 --- a/src/uu/od/src/output_info.rs +++ b/src/uu/od/src/output_info.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore formatteriteminfo blocksize thisblock use std::cmp; diff --git a/src/uu/od/src/parse_formats.rs b/src/uu/od/src/parse_formats.rs index c414abebe..2bb876d2b 100644 --- a/src/uu/od/src/parse_formats.rs +++ b/src/uu/od/src/parse_formats.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore formatteriteminfo docopt fvox fvoxw vals acdx use uucore::display::Quotable; diff --git a/src/uu/od/src/parse_inputs.rs b/src/uu/od/src/parse_inputs.rs index 3093843d4..74dc5a13a 100644 --- a/src/uu/od/src/parse_inputs.rs +++ b/src/uu/od/src/parse_inputs.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use super::options; use clap::ArgMatches; diff --git a/src/uu/od/src/parse_nrofbytes.rs b/src/uu/od/src/parse_nrofbytes.rs index 7d3bca03d..a5c81f68b 100644 --- a/src/uu/od/src/parse_nrofbytes.rs +++ b/src/uu/od/src/parse_nrofbytes.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use uucore::parse_size::{parse_size, ParseSizeError}; pub fn parse_number_of_bytes(s: &str) -> Result { diff --git a/src/uu/od/src/partialreader.rs b/src/uu/od/src/partialreader.rs index 8b51d8dee..24918f5cf 100644 --- a/src/uu/od/src/partialreader.rs +++ b/src/uu/od/src/partialreader.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore mockstream abcdefgh bcdefgh use std::cmp; diff --git a/src/uu/od/src/peekreader.rs b/src/uu/od/src/peekreader.rs index 45cd554d0..239faab92 100644 --- a/src/uu/od/src/peekreader.rs +++ b/src/uu/od/src/peekreader.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) tempbuffer abcdefgh abcdefghij //! Contains the trait `PeekRead` and type `PeekReader` implementing it. diff --git a/src/uu/od/src/prn_char.rs b/src/uu/od/src/prn_char.rs index 7ae6f084c..21f8073ea 100644 --- a/src/uu/od/src/prn_char.rs +++ b/src/uu/od/src/prn_char.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::str::from_utf8; use crate::formatteriteminfo::{FormatWriter, FormatterItemInfo}; diff --git a/src/uu/od/src/prn_float.rs b/src/uu/od/src/prn_float.rs index 496275574..af632d66b 100644 --- a/src/uu/od/src/prn_float.rs +++ b/src/uu/od/src/prn_float.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use half::f16; use std::f32; use std::f64; diff --git a/src/uu/od/src/prn_int.rs b/src/uu/od/src/prn_int.rs index 0946824c1..c214b7525 100644 --- a/src/uu/od/src/prn_int.rs +++ b/src/uu/od/src/prn_int.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::formatteriteminfo::*; /// format string to print octal using `int_writer_unsigned` diff --git a/src/uu/printf/src/mod.rs b/src/uu/printf/src/mod.rs index 26710c101..759b823cc 100644 --- a/src/uu/printf/src/mod.rs +++ b/src/uu/printf/src/mod.rs @@ -1 +1,5 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. mod cli; diff --git a/src/uu/printf/src/printf.rs b/src/uu/printf/src/printf.rs index bf79369cc..a6205f7cb 100644 --- a/src/uu/printf/src/printf.rs +++ b/src/uu/printf/src/printf.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #![allow(dead_code)] // spell-checker:ignore (change!) each's // spell-checker:ignore (ToDO) LONGHELP FORMATSTRING templating parameterizing formatstr diff --git a/src/uu/runcon/src/errors.rs b/src/uu/runcon/src/errors.rs index b96cc8743..5b6282940 100644 --- a/src/uu/runcon/src/errors.rs +++ b/src/uu/runcon/src/errors.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::ffi::OsString; use std::fmt::{Display, Formatter, Write}; use std::io; diff --git a/src/uu/runcon/src/runcon.rs b/src/uu/runcon/src/runcon.rs index a22bff470..a802542b2 100644 --- a/src/uu/runcon/src/runcon.rs +++ b/src/uu/runcon/src/runcon.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) RFILE use clap::builder::ValueParser; diff --git a/src/uu/seq/src/extendedbigdecimal.rs b/src/uu/seq/src/extendedbigdecimal.rs index 253fadfd5..388046ba3 100644 --- a/src/uu/seq/src/extendedbigdecimal.rs +++ b/src/uu/seq/src/extendedbigdecimal.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore bigdecimal extendedbigdecimal extendedbigint //! An arbitrary precision float that can also represent infinity, NaN, etc. //! diff --git a/src/uu/seq/src/extendedbigint.rs b/src/uu/seq/src/extendedbigint.rs index 46153bb7d..6828fba2d 100644 --- a/src/uu/seq/src/extendedbigint.rs +++ b/src/uu/seq/src/extendedbigint.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore bigint extendedbigint extendedbigdecimal //! An arbitrary precision integer that can also represent infinity, NaN, etc. //! diff --git a/src/uu/seq/src/number.rs b/src/uu/seq/src/number.rs index 1bab62b14..85bc327ff 100644 --- a/src/uu/seq/src/number.rs +++ b/src/uu/seq/src/number.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore extendedbigdecimal extendedbigint //! A type to represent the possible start, increment, and end values for seq. //! diff --git a/src/uu/seq/src/numberparse.rs b/src/uu/seq/src/numberparse.rs index 23d94ea2b..b22cf90c0 100644 --- a/src/uu/seq/src/numberparse.rs +++ b/src/uu/seq/src/numberparse.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore extendedbigdecimal extendedbigint bigdecimal numberparse //! Parsing numbers for use in `seq`. //! diff --git a/src/uu/shuf/src/rand_read_adapter.rs b/src/uu/shuf/src/rand_read_adapter.rs index 9cf0ee8a4..728bc0cfb 100644 --- a/src/uu/shuf/src/rand_read_adapter.rs +++ b/src/uu/shuf/src/rand_read_adapter.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // Copyright 2018 Developers of the Rand project. // Copyright 2013 The Rust Project Developers. // diff --git a/src/uu/sort/src/merge.rs b/src/uu/sort/src/merge.rs index 1a987fb4e..b4f084d50 100644 --- a/src/uu/sort/src/merge.rs +++ b/src/uu/sort/src/merge.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Merge already sorted files. //! //! We achieve performance by splitting the tasks of sorting and writing, and reading and parsing between two threads. diff --git a/src/uu/sort/src/tmp_dir.rs b/src/uu/sort/src/tmp_dir.rs index ff14442b5..14e17a0d6 100644 --- a/src/uu/sort/src/tmp_dir.rs +++ b/src/uu/sort/src/tmp_dir.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::{ fs::File, path::{Path, PathBuf}, diff --git a/src/uu/split/src/platform/mod.rs b/src/uu/split/src/platform/mod.rs index cf5d8d384..5afc43eeb 100644 --- a/src/uu/split/src/platform/mod.rs +++ b/src/uu/split/src/platform/mod.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #[cfg(unix)] pub use self::unix::instantiate_current_writer; #[cfg(unix)] diff --git a/src/uu/split/src/platform/unix.rs b/src/uu/split/src/platform/unix.rs index fedd66dc8..f4adb8188 100644 --- a/src/uu/split/src/platform/unix.rs +++ b/src/uu/split/src/platform/unix.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::env; use std::io::Write; use std::io::{BufWriter, Error, ErrorKind, Result}; diff --git a/src/uu/split/src/platform/windows.rs b/src/uu/split/src/platform/windows.rs index a2711fd3a..8b9078989 100644 --- a/src/uu/split/src/platform/windows.rs +++ b/src/uu/split/src/platform/windows.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::io::Write; use std::io::{BufWriter, Error, ErrorKind, Result}; use std::path::Path; diff --git a/src/uu/stdbuf/build.rs b/src/uu/stdbuf/build.rs index a8472243a..7483aeacf 100644 --- a/src/uu/stdbuf/build.rs +++ b/src/uu/stdbuf/build.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) dylib libstdbuf deps liblibstdbuf use std::env; diff --git a/src/uu/stdbuf/src/libstdbuf/build.rs b/src/uu/stdbuf/src/libstdbuf/build.rs index fc8ddeac8..6dcd6a869 100644 --- a/src/uu/stdbuf/src/libstdbuf/build.rs +++ b/src/uu/stdbuf/src/libstdbuf/build.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) libstdbuf use cpp_build::Config; diff --git a/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs b/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs index ec99c3864..a29d01b78 100644 --- a/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs +++ b/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) IOFBF IOLBF IONBF cstdio setvbuf use cpp::cpp; diff --git a/src/uu/test/src/error.rs b/src/uu/test/src/error.rs index ced4b216a..48238fa13 100644 --- a/src/uu/test/src/error.rs +++ b/src/uu/test/src/error.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /// Represents an error encountered while parsing a test expression #[derive(Debug)] pub enum ParseError { diff --git a/src/uu/wc/src/count_fast.rs b/src/uu/wc/src/count_fast.rs index d151c9c90..863625921 100644 --- a/src/uu/wc/src/count_fast.rs +++ b/src/uu/wc/src/count_fast.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::word_count::WordCount; use super::WordCountable; diff --git a/src/uu/wc/src/countable.rs b/src/uu/wc/src/countable.rs index b86b96fa2..643974464 100644 --- a/src/uu/wc/src/countable.rs +++ b/src/uu/wc/src/countable.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Traits and implementations for iterating over lines in a file-like object. //! //! This module provides a [`WordCountable`] trait and implementations diff --git a/src/uu/wc/src/utf8/mod.rs b/src/uu/wc/src/utf8/mod.rs index 31638e758..ea4f19392 100644 --- a/src/uu/wc/src/utf8/mod.rs +++ b/src/uu/wc/src/utf8/mod.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore Sapin mod read; diff --git a/src/uu/wc/src/utf8/read.rs b/src/uu/wc/src/utf8/read.rs index 1b5bbbe7f..4a92d85e6 100644 --- a/src/uu/wc/src/utf8/read.rs +++ b/src/uu/wc/src/utf8/read.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore bytestream use super::*; use std::error::Error; diff --git a/src/uu/wc/src/word_count.rs b/src/uu/wc/src/word_count.rs index cf839175f..3c18d692b 100644 --- a/src/uu/wc/src/word_count.rs +++ b/src/uu/wc/src/word_count.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::cmp::max; use std::ops::{Add, AddAssign}; diff --git a/src/uu/yes/src/splice.rs b/src/uu/yes/src/splice.rs index a0d41e06f..a95fc35af 100644 --- a/src/uu/yes/src/splice.rs +++ b/src/uu/yes/src/splice.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! On Linux we can use vmsplice() to write data more efficiently. //! //! This does not always work. We're not allowed to splice to some targets, diff --git a/src/uucore/src/lib/features.rs b/src/uucore/src/lib/features.rs index f8a8d2d10..8abccee26 100644 --- a/src/uucore/src/lib/features.rs +++ b/src/uucore/src/lib/features.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // features ~ feature-gated modules (core/bundler file) #[cfg(feature = "encoding")] diff --git a/src/uucore/src/lib/features/memo.rs b/src/uucore/src/lib/features/memo.rs index 47d04f5b8..0603b01c5 100644 --- a/src/uucore/src/lib/features/memo.rs +++ b/src/uucore/src/lib/features/memo.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Main entry point for our implementation of printf. //! //! The [`printf`] and [`sprintf`] closely match the behavior of the diff --git a/src/uucore/src/lib/features/pipes.rs b/src/uucore/src/lib/features/pipes.rs index a76322de8..75749f721 100644 --- a/src/uucore/src/lib/features/pipes.rs +++ b/src/uucore/src/lib/features/pipes.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /// Thin pipe-related wrappers around functions from the `nix` crate. use std::fs::File; #[cfg(any(target_os = "linux", target_os = "android"))] diff --git a/src/uucore/src/lib/features/ringbuffer.rs b/src/uucore/src/lib/features/ringbuffer.rs index 08073fae0..d58c8c498 100644 --- a/src/uucore/src/lib/features/ringbuffer.rs +++ b/src/uucore/src/lib/features/ringbuffer.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! A fixed-size ring buffer. use std::collections::VecDeque; diff --git a/src/uucore/src/lib/features/tokenize/mod.rs b/src/uucore/src/lib/features/tokenize/mod.rs index dfe44a0e5..49611bbca 100644 --- a/src/uucore/src/lib/features/tokenize/mod.rs +++ b/src/uucore/src/lib/features/tokenize/mod.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #[allow(clippy::module_inception)] mod num_format; pub mod sub; diff --git a/src/uucore/src/lib/features/tokenize/num_format/format_field.rs b/src/uucore/src/lib/features/tokenize/num_format/format_field.rs index 02998cde5..036ee286d 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/format_field.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/format_field.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety //! Primitives used by Sub Tokenizer diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatter.rs b/src/uucore/src/lib/features/tokenize/num_format/formatter.rs index ed7d5a0f6..2a3fd1013 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatter.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatter.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Primitives used by num_format and sub_modules. //! never dealt with above (e.g. Sub Tokenizer never uses these) diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs b/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs index 3df9f7129..f8b5da86c 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) arrnum arr_num mult basenum bufferval refd vals arrfloat conv intermed addl pub fn arrnum_int_mult(arr_num: &[u8], basenum: u8, base_ten_int_fact: u8) -> Vec { diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/tests.rs b/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/tests.rs index 903a3faf1..bf3747e18 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/tests.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/tests.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) arrnum mult #[cfg(test)] diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatters/cninetyninehexfloatf.rs b/src/uucore/src/lib/features/tokenize/num_format/formatters/cninetyninehexfloatf.rs index a5c51153e..91a854f26 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatters/cninetyninehexfloatf.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatters/cninetyninehexfloatf.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety // spell-checker:ignore (ToDO) arrnum 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 2ee53882e..35b981b4f 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 @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety //! formatter for %g %G decimal subs diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatters/float_common.rs b/src/uucore/src/lib/features/tokenize/num_format/formatters/float_common.rs index e0a29217c..1cf25b32f 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatters/float_common.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatters/float_common.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety // spell-checker:ignore (ToDO) arrnum diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatters/floatf.rs b/src/uucore/src/lib/features/tokenize/num_format/formatters/floatf.rs index cca2750dc..59f2cb408 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatters/floatf.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatters/floatf.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety // spell-checker:ignore (ToDO) arrnum diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatters/intf.rs b/src/uucore/src/lib/features/tokenize/num_format/formatters/intf.rs index 0f6e78de6..11070113c 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatters/intf.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatters/intf.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety // spell-checker:ignore (ToDO) arrnum diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatters/mod.rs b/src/uucore/src/lib/features/tokenize/num_format/formatters/mod.rs index e23230071..959089171 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatters/mod.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatters/mod.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) charf cninetyninehexfloatf decf floatf intf scif strf Cninety mod base_conv; diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatters/scif.rs b/src/uucore/src/lib/features/tokenize/num_format/formatters/scif.rs index c871dc4e5..a0dfa86c1 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatters/scif.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatters/scif.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) charf cninetyninehexfloatf decf floatf intf scif strf Cninety //! formatter for %e %E scientific notation subs diff --git a/src/uucore/src/lib/features/tokenize/num_format/mod.rs b/src/uucore/src/lib/features/tokenize/num_format/mod.rs index d40cf92de..d2ce686ff 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/mod.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/mod.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. pub mod format_field; mod formatter; mod formatters; diff --git a/src/uucore/src/lib/features/tokenize/num_format/num_format.rs b/src/uucore/src/lib/features/tokenize/num_format/num_format.rs index c9b1178b6..e9b676a80 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/num_format.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/num_format.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) charf cninetyninehexfloatf decf floatf intf scif strf Cninety //! handles creating printed output for numeric substitutions diff --git a/src/uucore/src/lib/features/tokenize/sub.rs b/src/uucore/src/lib/features/tokenize/sub.rs index 5bdb24dc6..4651dc8d8 100644 --- a/src/uucore/src/lib/features/tokenize/sub.rs +++ b/src/uucore/src/lib/features/tokenize/sub.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) charf decf floatf intf scif strf Cninety //! Sub is a token that represents a diff --git a/src/uucore/src/lib/features/tokenize/token.rs b/src/uucore/src/lib/features/tokenize/token.rs index b522c99a4..c4f7bd6ac 100644 --- a/src/uucore/src/lib/features/tokenize/token.rs +++ b/src/uucore/src/lib/features/tokenize/token.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Traits and enums dealing with Tokenization of printf Format String use std::io::Write; use std::iter::Peekable; diff --git a/src/uucore/src/lib/features/tokenize/unescaped_text.rs b/src/uucore/src/lib/features/tokenize/unescaped_text.rs index 29c657ed8..8ec6fd576 100644 --- a/src/uucore/src/lib/features/tokenize/unescaped_text.rs +++ b/src/uucore/src/lib/features/tokenize/unescaped_text.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! UnescapedText is a tokenizer impl //! for tokenizing character literals, //! and escaped character literals (of allowed escapes), diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 110939b7d..1d97522c7 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // library ~ (core/bundler file) // Copyright (C) ~ Alex Lyon diff --git a/src/uucore/src/lib/mods.rs b/src/uucore/src/lib/mods.rs index 52da2788a..cb66c0041 100644 --- a/src/uucore/src/lib/mods.rs +++ b/src/uucore/src/lib/mods.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // mods ~ cross-platforms modules (core/bundler file) pub mod backup_control; diff --git a/src/uucore/src/lib/mods/backup_control.rs b/src/uucore/src/lib/mods/backup_control.rs index 9998c7560..86c7cd72b 100644 --- a/src/uucore/src/lib/mods/backup_control.rs +++ b/src/uucore/src/lib/mods/backup_control.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Implement GNU-style backup functionality. //! //! This module implements the backup functionality as described in the [GNU diff --git a/src/uucore/src/lib/mods/display.rs b/src/uucore/src/lib/mods/display.rs index 95288973a..db92c4887 100644 --- a/src/uucore/src/lib/mods/display.rs +++ b/src/uucore/src/lib/mods/display.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /// Utilities for printing paths, with special attention paid to special /// characters and invalid unicode. /// diff --git a/src/uucore/src/lib/mods/error.rs b/src/uucore/src/lib/mods/error.rs index f0f62569d..82644ae8a 100644 --- a/src/uucore/src/lib/mods/error.rs +++ b/src/uucore/src/lib/mods/error.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // TODO fix broken links #![allow(rustdoc::broken_intra_doc_links)] //! All utils return exit with an exit code. Usually, the following scheme is used: diff --git a/src/uucore/src/lib/mods/line_ending.rs b/src/uucore/src/lib/mods/line_ending.rs index 073743fc5..6fe608e7d 100644 --- a/src/uucore/src/lib/mods/line_ending.rs +++ b/src/uucore/src/lib/mods/line_ending.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Provides consistent newline/zero terminator handling for `-z`/`--zero` flags. //! //! See the [`LineEnding`] struct for more information. diff --git a/src/uucore/src/lib/mods/os.rs b/src/uucore/src/lib/mods/os.rs index dd06f4739..55bf844b5 100644 --- a/src/uucore/src/lib/mods/os.rs +++ b/src/uucore/src/lib/mods/os.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /// Test if the program is running under WSL // ref: @@ diff --git a/src/uucore/src/lib/mods/panic.rs b/src/uucore/src/lib/mods/panic.rs index 5a1e20d80..f42b29581 100644 --- a/src/uucore/src/lib/mods/panic.rs +++ b/src/uucore/src/lib/mods/panic.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Custom panic hooks that allow silencing certain types of errors. //! //! Use the [`mute_sigpipe_panic`] function to silence panics caused by diff --git a/src/uucore/src/lib/mods/quoting_style.rs b/src/uucore/src/lib/mods/quoting_style.rs index a6efb2898..1b9a76aae 100644 --- a/src/uucore/src/lib/mods/quoting_style.rs +++ b/src/uucore/src/lib/mods/quoting_style.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::char::from_digit; use std::ffi::OsStr; diff --git a/src/uucore/src/lib/mods/version_cmp.rs b/src/uucore/src/lib/mods/version_cmp.rs index 828b7f2a6..d881a73a1 100644 --- a/src/uucore/src/lib/mods/version_cmp.rs +++ b/src/uucore/src/lib/mods/version_cmp.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::cmp::Ordering; /// Compares the non-digit parts of a version. diff --git a/src/uucore/src/lib/parser.rs b/src/uucore/src/lib/parser.rs index fc3e46b5c..a0de6c0d4 100644 --- a/src/uucore/src/lib/parser.rs +++ b/src/uucore/src/lib/parser.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. pub mod parse_glob; pub mod parse_size; pub mod parse_time; diff --git a/src/uucore/src/lib/parser/parse_glob.rs b/src/uucore/src/lib/parser/parse_glob.rs index a321d470b..9215dd7bf 100644 --- a/src/uucore/src/lib/parser/parse_glob.rs +++ b/src/uucore/src/lib/parser/parse_glob.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Parsing a glob Pattern from a string. //! //! Use the [`from_str`] function to parse a [`Pattern`] from a string. diff --git a/src/uucore/src/lib/parser/shortcut_value_parser.rs b/src/uucore/src/lib/parser/shortcut_value_parser.rs index 07ed49cb3..49bb2b62b 100644 --- a/src/uucore/src/lib/parser/shortcut_value_parser.rs +++ b/src/uucore/src/lib/parser/shortcut_value_parser.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore abcdefgh use clap::{ builder::{PossibleValue, TypedValueParser}, diff --git a/src/uucore_procs/src/lib.rs b/src/uucore_procs/src/lib.rs index b78da7822..ef1ba87cf 100644 --- a/src/uucore_procs/src/lib.rs +++ b/src/uucore_procs/src/lib.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // Copyright (C) ~ Roy Ivy III ; MIT license // spell-checker:ignore backticks uuhelp diff --git a/tests/benches/factor/benches/gcd.rs b/tests/benches/factor/benches/gcd.rs index a9d2a8c55..61545145f 100644 --- a/tests/benches/factor/benches/gcd.rs +++ b/tests/benches/factor/benches/gcd.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use uu_factor::numeric; diff --git a/tests/benches/factor/benches/table.rs b/tests/benches/factor/benches/table.rs index 59e8db1f3..f666d72d5 100644 --- a/tests/benches/factor/benches/table.rs +++ b/tests/benches/factor/benches/table.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use array_init::array_init; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; use uu_factor::{table::*, Factors}; diff --git a/tests/by-util/test_arch.rs b/tests/by-util/test_arch.rs index 603e1bc49..daf4e32f5 100644 --- a/tests/by-util/test_arch.rs +++ b/tests/by-util/test_arch.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_base64.rs b/tests/by-util/test_base64.rs index 7cd44eefd..b46507fae 100644 --- a/tests/by-util/test_base64.rs +++ b/tests/by-util/test_base64.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_basename.rs b/tests/by-util/test_basename.rs index 88b0c71c8..73b44ff75 100644 --- a/tests/by-util/test_basename.rs +++ b/tests/by-util/test_basename.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) reallylongexecutable use crate::common::util::TestScenario; diff --git a/tests/by-util/test_basenc.rs b/tests/by-util/test_basenc.rs index 401c23d45..6c71b63f7 100644 --- a/tests/by-util/test_basenc.rs +++ b/tests/by-util/test_basenc.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_cat.rs b/tests/by-util/test_cat.rs index c32828a83..27f40356d 100644 --- a/tests/by-util/test_cat.rs +++ b/tests/by-util/test_cat.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore NOFILE #[cfg(not(windows))] diff --git a/tests/by-util/test_chcon.rs b/tests/by-util/test_chcon.rs index bea5462b4..71405e451 100644 --- a/tests/by-util/test_chcon.rs +++ b/tests/by-util/test_chcon.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (jargon) xattributes #![cfg(feature = "feat_selinux")] diff --git a/tests/by-util/test_chgrp.rs b/tests/by-util/test_chgrp.rs index cf6c62ff7..07966b67b 100644 --- a/tests/by-util/test_chgrp.rs +++ b/tests/by-util/test_chgrp.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) nosuchgroup groupname use crate::common::util::TestScenario; diff --git a/tests/by-util/test_chmod.rs b/tests/by-util/test_chmod.rs index 9e3c7d2da..be730a8c0 100644 --- a/tests/by-util/test_chmod.rs +++ b/tests/by-util/test_chmod.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::{AtPath, TestScenario, UCommand}; use once_cell::sync::Lazy; use std::fs::{metadata, set_permissions, OpenOptions, Permissions}; diff --git a/tests/by-util/test_chown.rs b/tests/by-util/test_chown.rs index 7a1a4a6bd..40c63cefd 100644 --- a/tests/by-util/test_chown.rs +++ b/tests/by-util/test_chown.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) agroupthatdoesntexist auserthatdoesntexist cuuser groupname notexisting passgrp use crate::common::util::{is_ci, run_ucmd_as_root, CmdResult, TestScenario}; diff --git a/tests/by-util/test_chroot.rs b/tests/by-util/test_chroot.rs index 697be8775..1fc2231d5 100644 --- a/tests/by-util/test_chroot.rs +++ b/tests/by-util/test_chroot.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) araba newroot userspec chdir pwd's isroot #[cfg(not(target_os = "android"))] diff --git a/tests/by-util/test_cksum.rs b/tests/by-util/test_cksum.rs index 41ddc2ee0..a9d9b272b 100644 --- a/tests/by-util/test_cksum.rs +++ b/tests/by-util/test_cksum.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) asdf algo algos use crate::common::util::TestScenario; diff --git a/tests/by-util/test_comm.rs b/tests/by-util/test_comm.rs index 42c8358bb..e2bcc1c44 100644 --- a/tests/by-util/test_comm.rs +++ b/tests/by-util/test_comm.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) defaultcheck nocheck use crate::common::util::TestScenario; diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 18f3829a2..635f24c51 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs ROOTDIR USERDIR procfs outfile use crate::common::util::TestScenario; diff --git a/tests/by-util/test_csplit.rs b/tests/by-util/test_csplit.rs index eecaccfaf..b83d5e0ee 100644 --- a/tests/by-util/test_csplit.rs +++ b/tests/by-util/test_csplit.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use glob::glob; diff --git a/tests/by-util/test_cut.rs b/tests/by-util/test_cut.rs index a82950beb..7f86c803e 100644 --- a/tests/by-util/test_cut.rs +++ b/tests/by-util/test_cut.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; static INPUT: &str = "lists.txt"; diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index efd16d5c7..a65f02fa4 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use regex::Regex; #[cfg(all(unix, not(target_os = "macos")))] diff --git a/tests/by-util/test_dd.rs b/tests/by-util/test_dd.rs index b43f32c24..fe38acca4 100644 --- a/tests/by-util/test_dd.rs +++ b/tests/by-util/test_dd.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// 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, 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::TestScenario; diff --git a/tests/by-util/test_df.rs b/tests/by-util/test_df.rs index 926d1be5d..227121ef4 100644 --- a/tests/by-util/test_df.rs +++ b/tests/by-util/test_df.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore udev pcent iuse itotal iused ipcent use std::collections::HashSet; diff --git a/tests/by-util/test_dir.rs b/tests/by-util/test_dir.rs index fd94f3a8f..3d16f8a67 100644 --- a/tests/by-util/test_dir.rs +++ b/tests/by-util/test_dir.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use regex::Regex; diff --git a/tests/by-util/test_dircolors.rs b/tests/by-util/test_dircolors.rs index 2d83c76b5..d4fa0a3b0 100644 --- a/tests/by-util/test_dircolors.rs +++ b/tests/by-util/test_dircolors.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore overridable use crate::common::util::TestScenario; diff --git a/tests/by-util/test_dirname.rs b/tests/by-util/test_dirname.rs index ae689041b..8471b48c4 100644 --- a/tests/by-util/test_dirname.rs +++ b/tests/by-util/test_dirname.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_echo.rs b/tests/by-util/test_echo.rs index 1c07a6737..3a8e7f86b 100644 --- a/tests/by-util/test_echo.rs +++ b/tests/by-util/test_echo.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) araba merci use crate::common::util::TestScenario; diff --git a/tests/by-util/test_env.rs b/tests/by-util/test_env.rs index bd206c8e5..8ce55a1d3 100644 --- a/tests/by-util/test_env.rs +++ b/tests/by-util/test_env.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) bamf chdir rlimit prlimit COMSPEC use crate::common::util::TestScenario; diff --git a/tests/by-util/test_expand.rs b/tests/by-util/test_expand.rs index 88c1b1670..f6802358c 100644 --- a/tests/by-util/test_expand.rs +++ b/tests/by-util/test_expand.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use uucore::display::Quotable; // spell-checker:ignore (ToDO) taaaa tbbbb tcccc diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index 235a91120..665f89615 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore αbcdef ; (people) kkos use crate::common::util::TestScenario; diff --git a/tests/by-util/test_false.rs b/tests/by-util/test_false.rs index c6c663404..01916ec62 100644 --- a/tests/by-util/test_false.rs +++ b/tests/by-util/test_false.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))] use std::fs::OpenOptions; diff --git a/tests/by-util/test_fmt.rs b/tests/by-util/test_fmt.rs index 84a19d34d..7d23cbd52 100644 --- a/tests/by-util/test_fmt.rs +++ b/tests/by-util/test_fmt.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_fold.rs b/tests/by-util/test_fold.rs index b61d9f5ed..6895f51b6 100644 --- a/tests/by-util/test_fold.rs +++ b/tests/by-util/test_fold.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_hashsum.rs b/tests/by-util/test_hashsum.rs index 3650047b2..4bf06308d 100644 --- a/tests/by-util/test_hashsum.rs +++ b/tests/by-util/test_hashsum.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; // spell-checker:ignore checkfile, nonames, testf, ntestf macro_rules! get_hash( diff --git a/tests/by-util/test_hostid.rs b/tests/by-util/test_hostid.rs index b42ec211d..e9336116b 100644 --- a/tests/by-util/test_hostid.rs +++ b/tests/by-util/test_hostid.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use regex::Regex; diff --git a/tests/by-util/test_hostname.rs b/tests/by-util/test_hostname.rs index 3c01a1197..84cb73e2e 100644 --- a/tests/by-util/test_hostname.rs +++ b/tests/by-util/test_hostname.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_install.rs b/tests/by-util/test_install.rs index d76ce1e01..7387748c6 100644 --- a/tests/by-util/test_install.rs +++ b/tests/by-util/test_install.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) helloworld nodir objdump n'source use crate::common::util::{is_ci, TestScenario}; diff --git a/tests/by-util/test_join.rs b/tests/by-util/test_join.rs index f6fbe14c3..e2e5dc868 100644 --- a/tests/by-util/test_join.rs +++ b/tests/by-util/test_join.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) autoformat nocheck use crate::common::util::TestScenario; diff --git a/tests/by-util/test_kill.rs b/tests/by-util/test_kill.rs index d36023298..a9094ecf6 100644 --- a/tests/by-util/test_kill.rs +++ b/tests/by-util/test_kill.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use regex::Regex; use std::os::unix::process::ExitStatusExt; diff --git a/tests/by-util/test_link.rs b/tests/by-util/test_link.rs index 3c068af93..f0135983d 100644 --- a/tests/by-util/test_link.rs +++ b/tests/by-util/test_link.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_ln.rs b/tests/by-util/test_ln.rs index 3be07c4d7..dc31f7261 100644 --- a/tests/by-util/test_ln.rs +++ b/tests/by-util/test_ln.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use std::path::PathBuf; diff --git a/tests/by-util/test_logname.rs b/tests/by-util/test_logname.rs index b0cda1a9d..883397555 100644 --- a/tests/by-util/test_logname.rs +++ b/tests/by-util/test_logname.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::{is_ci, TestScenario}; use std::env; diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 15ded8e6b..f18150358 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc neee naaaaa nbcdef nfffff #[cfg(any(unix, feature = "feat_selinux"))] diff --git a/tests/by-util/test_mkdir.rs b/tests/by-util/test_mkdir.rs index 11a860d5a..8a6eae27b 100644 --- a/tests/by-util/test_mkdir.rs +++ b/tests/by-util/test_mkdir.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[cfg(not(windows))] use libc::{mode_t, umask}; diff --git a/tests/by-util/test_mkfifo.rs b/tests/by-util/test_mkfifo.rs index d4ebab640..731b6c1d5 100644 --- a/tests/by-util/test_mkfifo.rs +++ b/tests/by-util/test_mkfifo.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_mknod.rs b/tests/by-util/test_mknod.rs index deea8bb4e..2d83d250d 100644 --- a/tests/by-util/test_mknod.rs +++ b/tests/by-util/test_mknod.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_mktemp.rs b/tests/by-util/test_mktemp.rs index 4544b6b30..611a42e43 100644 --- a/tests/by-util/test_mktemp.rs +++ b/tests/by-util/test_mktemp.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) gpghome use crate::common::util::TestScenario; diff --git a/tests/by-util/test_more.rs b/tests/by-util/test_more.rs index d94a92185..b6ded2298 100644 --- a/tests/by-util/test_more.rs +++ b/tests/by-util/test_more.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use is_terminal::IsTerminal; diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index ceaa4ba22..932019a34 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use filetime::FileTime; use std::thread::sleep; diff --git a/tests/by-util/test_nice.rs b/tests/by-util/test_nice.rs index 4e8d5a2ee..994b0e856 100644 --- a/tests/by-util/test_nice.rs +++ b/tests/by-util/test_nice.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore libc's use crate::common::util::TestScenario; diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index 4aa95030b..b58c0c206 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore binvalid finvalid hinvalid iinvalid linvalid ninvalid vinvalid winvalid use crate::common::util::TestScenario; diff --git a/tests/by-util/test_nohup.rs b/tests/by-util/test_nohup.rs index c14a2e494..b014c31aa 100644 --- a/tests/by-util/test_nohup.rs +++ b/tests/by-util/test_nohup.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use std::thread::sleep; diff --git a/tests/by-util/test_nproc.rs b/tests/by-util/test_nproc.rs index 2e3c5c603..22523352b 100644 --- a/tests/by-util/test_nproc.rs +++ b/tests/by-util/test_nproc.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore incorrectnumber use crate::common::util::TestScenario; diff --git a/tests/by-util/test_numfmt.rs b/tests/by-util/test_numfmt.rs index 561752db3..2c2e95d0b 100644 --- a/tests/by-util/test_numfmt.rs +++ b/tests/by-util/test_numfmt.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (paths) gnutest use crate::common::util::TestScenario; diff --git a/tests/by-util/test_paste.rs b/tests/by-util/test_paste.rs index da92daa32..0fbdb75d2 100644 --- a/tests/by-util/test_paste.rs +++ b/tests/by-util/test_paste.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; struct TestData<'b> { diff --git a/tests/by-util/test_pathchk.rs b/tests/by-util/test_pathchk.rs index 771fbd0a9..f497cfe89 100644 --- a/tests/by-util/test_pathchk.rs +++ b/tests/by-util/test_pathchk.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_pr.rs b/tests/by-util/test_pr.rs index b62fa4a96..195d40567 100644 --- a/tests/by-util/test_pr.rs +++ b/tests/by-util/test_pr.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) Sdivide use crate::common::util::{TestScenario, UCommand}; diff --git a/tests/by-util/test_printenv.rs b/tests/by-util/test_printenv.rs index fa7d420e1..c9eb3c60e 100644 --- a/tests/by-util/test_printenv.rs +++ b/tests/by-util/test_printenv.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index e9b25954f..d7ba5679e 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_ptx.rs b/tests/by-util/test_ptx.rs index db4a4f3cc..a106972ac 100644 --- a/tests/by-util/test_ptx.rs +++ b/tests/by-util/test_ptx.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_pwd.rs b/tests/by-util/test_pwd.rs index 1e43f5be6..89341c0c3 100644 --- a/tests/by-util/test_pwd.rs +++ b/tests/by-util/test_pwd.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) symdir somefakedir use std::path::PathBuf; diff --git a/tests/by-util/test_readlink.rs b/tests/by-util/test_readlink.rs index f08671583..973e30a35 100644 --- a/tests/by-util/test_readlink.rs +++ b/tests/by-util/test_readlink.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore regfile use crate::common::util::{get_root_path, TestScenario}; diff --git a/tests/by-util/test_realpath.rs b/tests/by-util/test_realpath.rs index 707378c97..c3a15fba4 100644 --- a/tests/by-util/test_realpath.rs +++ b/tests/by-util/test_realpath.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::{get_root_path, TestScenario}; #[cfg(windows)] diff --git a/tests/by-util/test_relpath.rs b/tests/by-util/test_relpath.rs index 65cbd391e..8a3c91802 100644 --- a/tests/by-util/test_relpath.rs +++ b/tests/by-util/test_relpath.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use std::borrow::Cow; use std::path::Path; diff --git a/tests/by-util/test_rm.rs b/tests/by-util/test_rm.rs index 737c4fa79..82a9362dd 100644 --- a/tests/by-util/test_rm.rs +++ b/tests/by-util/test_rm.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::process::Stdio; use crate::common::util::TestScenario; diff --git a/tests/by-util/test_rmdir.rs b/tests/by-util/test_rmdir.rs index 56e801d7e..086d43748 100644 --- a/tests/by-util/test_rmdir.rs +++ b/tests/by-util/test_rmdir.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; const DIR: &str = "dir"; diff --git a/tests/by-util/test_runcon.rs b/tests/by-util/test_runcon.rs index dd4445625..7635fea49 100644 --- a/tests/by-util/test_runcon.rs +++ b/tests/by-util/test_runcon.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (jargon) xattributes #![cfg(feature = "feat_selinux")] diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index de0781912..8f879263b 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore lmnop xlmnop use crate::common::util::TestScenario; use std::process::Stdio; diff --git a/tests/by-util/test_shred.rs b/tests/by-util/test_shred.rs index d98b840c4..83d2890ed 100644 --- a/tests/by-util/test_shred.rs +++ b/tests/by-util/test_shred.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_shuf.rs b/tests/by-util/test_shuf.rs index 44282b8a3..9841f028b 100644 --- a/tests/by-util/test_shuf.rs +++ b/tests/by-util/test_shuf.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_sleep.rs b/tests/by-util/test_sleep.rs index 76e98e012..dd99c7406 100644 --- a/tests/by-util/test_sleep.rs +++ b/tests/by-util/test_sleep.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use rstest::rstest; // spell-checker:ignore dont diff --git a/tests/by-util/test_stdbuf.rs b/tests/by-util/test_stdbuf.rs index 334715706..e31c532e2 100644 --- a/tests/by-util/test_stdbuf.rs +++ b/tests/by-util/test_stdbuf.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #[cfg(not(target_os = "windows"))] use crate::common::util::TestScenario; diff --git a/tests/by-util/test_stty.rs b/tests/by-util/test_stty.rs index e85c11082..a9a9209b0 100644 --- a/tests/by-util/test_stty.rs +++ b/tests/by-util/test_stty.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore parenb parmrk ixany iuclc onlcr ofdel icanon noflsh use crate::common::util::TestScenario; diff --git a/tests/by-util/test_sum.rs b/tests/by-util/test_sum.rs index 0a43a3043..13f453ba1 100644 --- a/tests/by-util/test_sum.rs +++ b/tests/by-util/test_sum.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_sync.rs b/tests/by-util/test_sync.rs index 9cae3b8a0..9a824cd48 100644 --- a/tests/by-util/test_sync.rs +++ b/tests/by-util/test_sync.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use std::fs; use tempfile::tempdir; diff --git a/tests/by-util/test_tac.rs b/tests/by-util/test_tac.rs index cc98ec616..fa5f67f13 100644 --- a/tests/by-util/test_tac.rs +++ b/tests/by-util/test_tac.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore axxbxx bxxaxx axxx axxxx xxaxx xxax xxxxa axyz zyax zyxa use crate::common::util::TestScenario; diff --git a/tests/by-util/test_tee.rs b/tests/by-util/test_tee.rs index 51d552d67..6f04edfc3 100644 --- a/tests/by-util/test_tee.rs +++ b/tests/by-util/test_tee.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; // tests for basic tee functionality. diff --git a/tests/by-util/test_timeout.rs b/tests/by-util/test_timeout.rs index 8e6e5db55..6c4a00eb5 100644 --- a/tests/by-util/test_timeout.rs +++ b/tests/by-util/test_timeout.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore dont use crate::common::util::TestScenario; diff --git a/tests/by-util/test_touch.rs b/tests/by-util/test_touch.rs index 0ebbee1d7..942446a33 100644 --- a/tests/by-util/test_touch.rs +++ b/tests/by-util/test_touch.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (formats) cymdhm cymdhms mdhm mdhms ymdhm ymdhms datetime mktime use crate::common::util::{AtPath, TestScenario}; diff --git a/tests/by-util/test_tr.rs b/tests/by-util/test_tr.rs index 4e437609e..7c475a492 100644 --- a/tests/by-util/test_tr.rs +++ b/tests/by-util/test_tr.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore aabbaa aabbcc aabc abbb abcc abcdefabcdef abcdefghijk abcdefghijklmn abcdefghijklmnop ABCDEFGHIJKLMNOPQRS abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFZZ abcxyz ABCXYZ abcxyzabcxyz ABCXYZABCXYZ acbdef alnum amzamz AMZXAMZ bbbd cclass cefgm cntrl compl dabcdef dncase Gzabcdefg PQRST upcase wxyzz xdigit xycde xyyye xyyz xyzzzzxyzzzz ZABCDEF Zamz Cdefghijkl Cdefghijklmn use crate::common::util::TestScenario; diff --git a/tests/by-util/test_true.rs b/tests/by-util/test_true.rs index 1675b3903..750c60132 100644 --- a/tests/by-util/test_true.rs +++ b/tests/by-util/test_true.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))] use std::fs::OpenOptions; diff --git a/tests/by-util/test_tsort.rs b/tests/by-util/test_tsort.rs index 62a74c31d..188894516 100644 --- a/tests/by-util/test_tsort.rs +++ b/tests/by-util/test_tsort.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_tty.rs b/tests/by-util/test_tty.rs index 87dcbac85..0f2c58806 100644 --- a/tests/by-util/test_tty.rs +++ b/tests/by-util/test_tty.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::fs::File; use crate::common::util::TestScenario; diff --git a/tests/by-util/test_uname.rs b/tests/by-util/test_uname.rs index 5076334e5..3676eefba 100644 --- a/tests/by-util/test_uname.rs +++ b/tests/by-util/test_uname.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_unexpand.rs b/tests/by-util/test_unexpand.rs index c833c93e4..ddbe3343e 100644 --- a/tests/by-util/test_unexpand.rs +++ b/tests/by-util/test_unexpand.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_uniq.rs b/tests/by-util/test_uniq.rs index 57f0ec111..97a829b9f 100644 --- a/tests/by-util/test_uniq.rs +++ b/tests/by-util/test_uniq.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::io::Write; // spell-checker:ignore nabcd diff --git a/tests/by-util/test_unlink.rs b/tests/by-util/test_unlink.rs index 5313c9eab..055f47f10 100644 --- a/tests/by-util/test_unlink.rs +++ b/tests/by-util/test_unlink.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_uptime.rs b/tests/by-util/test_uptime.rs index 628f4cead..3967d0252 100644 --- a/tests/by-util/test_uptime.rs +++ b/tests/by-util/test_uptime.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use regex::Regex; diff --git a/tests/by-util/test_users.rs b/tests/by-util/test_users.rs index 6a54aa8d2..766378a9d 100644 --- a/tests/by-util/test_users.rs +++ b/tests/by-util/test_users.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; #[test] diff --git a/tests/by-util/test_vdir.rs b/tests/by-util/test_vdir.rs index f6498567f..97d5b847f 100644 --- a/tests/by-util/test_vdir.rs +++ b/tests/by-util/test_vdir.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::TestScenario; use regex::Regex; diff --git a/tests/by-util/test_wc.rs b/tests/by-util/test_wc.rs index aba5ed350..6417470c5 100644 --- a/tests/by-util/test_wc.rs +++ b/tests/by-util/test_wc.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::{vec_of_size, TestScenario}; // spell-checker:ignore (flags) lwmcL clmwL ; (path) bogusfile emptyfile manyemptylines moby notrailingnewline onelongemptyline onelongword weirdchars diff --git a/tests/by-util/test_yes.rs b/tests/by-util/test_yes.rs index a674f8245..f40d6d5b8 100644 --- a/tests/by-util/test_yes.rs +++ b/tests/by-util/test_yes.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::ffi::OsStr; use std::process::{ExitStatus, Stdio}; diff --git a/tests/common/mod.rs b/tests/common/mod.rs index f73cd42af..05e2b1382 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #[macro_use] pub mod macros; pub mod random; diff --git a/tests/fixtures/install/helloworld.rs b/tests/fixtures/install/helloworld.rs index 47ad8c634..bb2a816fc 100644 --- a/tests/fixtures/install/helloworld.rs +++ b/tests/fixtures/install/helloworld.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. fn main() { println!("Hello World!"); } diff --git a/tests/test_util_name.rs b/tests/test_util_name.rs index bf0ea2fa3..45edc7dc7 100644 --- a/tests/test_util_name.rs +++ b/tests/test_util_name.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #![allow(unused_imports)] mod common; diff --git a/tests/tests.rs b/tests/tests.rs index 02c3bfdab..8d4a6855c 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,3 +1,7 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #[macro_use] mod common; From 808f9e2fd699918aea455c8f2490f68b1b3bc10c Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 21 Aug 2023 10:37:48 +0200 Subject: [PATCH 058/370] uucore: add missing "!" --- src/uucore/src/lib/features/fs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index f7aa157a0..9126768d1 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -860,7 +860,7 @@ mod tests { let path1 = temp_file1.path(); let path2 = temp_file2.path(); - assert!(are_hardlinks_to_same_file(&path1, &path2)); + assert!(!are_hardlinks_to_same_file(&path1, &path2)); } #[cfg(unix)] From ba8e9366f6773be725e66d5f5fecb9196d05445b Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 21 Aug 2023 10:36:40 +0200 Subject: [PATCH 059/370] stdbuf: fix `get_preload_env` doesn't need a mutable reference --- src/uu/stdbuf/src/stdbuf.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index fc51ee6f7..85dddbddd 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -152,8 +152,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let mut command = process::Command::new(command_values.next().unwrap()); let command_params: Vec<&str> = command_values.map(|s| s.as_ref()).collect(); - let mut tmp_dir = tempdir().unwrap(); - let (preload_env, libstdbuf) = get_preload_env(&mut tmp_dir).map_err_context(String::new)?; + let tmp_dir = tempdir().unwrap(); + let (preload_env, libstdbuf) = get_preload_env(&tmp_dir).map_err_context(String::new)?; command.env(preload_env, libstdbuf); set_command_env(&mut command, "_STDBUF_I", &options.stdin); set_command_env(&mut command, "_STDBUF_O", &options.stdout); From 675db9186e8a07364110c681bfdc347b2ca46849 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 21 Aug 2023 11:39:18 +0200 Subject: [PATCH 060/370] id: remove mutable reference when calling id_print --- src/uu/id/src/id.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 10e1e8f03..8669bdac9 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -308,7 +308,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } if default_format { - id_print(&mut state, &groups); + id_print(&state, &groups); } print!("{line_ending}"); From bf5b765cbab8f96ca8448dc561efe2386e396cbd Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 21 Aug 2023 12:23:18 +0200 Subject: [PATCH 061/370] Remove the author copyright notices (#5184) * Remove the author copyright notices Rational: * not maintained * does not reflect reality * don't provide any value (the info can be found in the git log) * we don't have rules to update them (ex: should you update it after one line, two lines, etc) Co-authored-by: Daniel Hofstetter --- src/bin/coreutils.rs | 2 -- src/uu/arch/src/arch.rs | 3 --- src/uu/base32/src/base32.rs | 2 -- src/uu/base32/src/base_common.rs | 4 ---- src/uu/base64/src/base64.rs | 3 --- src/uu/basename/src/basename.rs | 2 -- src/uu/basenc/src/basenc.rs | 3 --- src/uu/cat/src/cat.rs | 5 ----- src/uu/chgrp/src/chgrp.rs | 2 -- src/uu/chmod/src/chmod.rs | 2 -- src/uu/chown/src/chown.rs | 2 -- src/uu/chroot/src/chroot.rs | 3 --- src/uu/cksum/src/cksum.rs | 2 -- src/uu/comm/src/comm.rs | 2 -- src/uu/cp/src/cp.rs | 3 --- src/uu/cut/src/cut.rs | 2 -- src/uu/cut/src/searcher.rs | 2 -- src/uu/date/src/date.rs | 3 --- src/uu/dd/src/conversion_tables.rs | 2 -- src/uu/dd/src/datastructures.rs | 2 -- src/uu/dd/src/dd.rs | 2 -- src/uu/dd/src/parseargs.rs | 2 -- src/uu/df/src/df.rs | 3 --- src/uu/dircolors/src/dircolors.rs | 3 --- src/uu/dirname/src/dirname.rs | 2 -- src/uu/echo/src/echo.rs | 3 --- src/uu/env/src/env.rs | 3 --- src/uu/expand/src/expand.rs | 3 --- src/uu/groups/src/groups.rs | 3 --- src/uu/id/src/id.rs | 3 --- src/uu/ls/src/ls.rs | 2 -- src/uu/mknod/src/mknod.rs | 2 -- src/uu/mktemp/src/mktemp.rs | 3 --- src/uu/mv/src/mv.rs | 3 --- src/uu/pinky/src/pinky.rs | 2 -- src/uu/stat/src/stat.rs | 2 -- src/uu/test/src/parser.rs | 2 -- src/uu/test/src/test.rs | 3 --- src/uu/touch/src/touch.rs | 3 --- src/uu/uname/src/uname.rs | 3 --- src/uu/who/src/who.rs | 2 -- src/uucore/src/lib/features/encoding.rs | 2 -- src/uucore/src/lib/features/entries.rs | 2 -- src/uucore/src/lib/features/fs.rs | 3 --- src/uucore/src/lib/features/fsext.rs | 4 ---- src/uucore/src/lib/features/mode.rs | 2 -- src/uucore/src/lib/features/process.rs | 3 --- src/uucore/src/lib/features/signals.rs | 2 -- src/uucore/src/lib/features/sum.rs | 2 -- src/uucore/src/lib/features/utmpx.rs | 2 -- src/uucore/src/lib/features/wide.rs | 2 -- src/uucore/src/lib/macros.rs | 2 -- src/uucore/src/lib/mods/ranges.rs | 2 -- src/uucore/src/lib/mods/update_control.rs | 2 -- src/uucore/src/lib/parser/parse_time.rs | 2 -- tests/by-util/test_base32.rs | 2 -- tests/by-util/test_factor.rs | 2 -- tests/by-util/test_test.rs | 3 --- 58 files changed, 144 deletions(-) diff --git a/src/bin/coreutils.rs b/src/bin/coreutils.rs index d6487dc49..fc2cd16ad 100644 --- a/src/bin/coreutils.rs +++ b/src/bin/coreutils.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Michael Gehring -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/arch/src/arch.rs b/src/uu/arch/src/arch.rs index 96eba1ef9..0d71a8183 100644 --- a/src/uu/arch/src/arch.rs +++ b/src/uu/arch/src/arch.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Smigle00 -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/base32/src/base32.rs b/src/uu/base32/src/base32.rs index 740e2d70b..2ef63fbc0 100644 --- a/src/uu/base32/src/base32.rs +++ b/src/uu/base32/src/base32.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uu/base32/src/base_common.rs b/src/uu/base32/src/base_common.rs index 78698e8b9..ba2ef9229 100644 --- a/src/uu/base32/src/base_common.rs +++ b/src/uu/base32/src/base_common.rs @@ -1,9 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jordy Dickinson -// (c) Jian Zeng -// (c) Alex Lyon -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uu/base64/src/base64.rs b/src/uu/base64/src/base64.rs index e502482e3..4e4a3c293 100644 --- a/src/uu/base64/src/base64.rs +++ b/src/uu/base64/src/base64.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jordy Dickinson -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uu/basename/src/basename.rs b/src/uu/basename/src/basename.rs index 3fe594c3b..6c9baca6f 100644 --- a/src/uu/basename/src/basename.rs +++ b/src/uu/basename/src/basename.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jimmy Lu -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/basenc/src/basenc.rs b/src/uu/basenc/src/basenc.rs index 3ec8cede0..0ee8a816b 100644 --- a/src/uu/basenc/src/basenc.rs +++ b/src/uu/basenc/src/basenc.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jordy Dickinson -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index 2c4117a32..cd7f77fb5 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -1,10 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jordi Boggiano -// (c) Evgeniy Klyuchikov -// (c) Joshua S. Miller -// (c) Árni Dagur -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/chgrp/src/chgrp.rs b/src/uu/chgrp/src/chgrp.rs index bd01e132b..fba2cef16 100644 --- a/src/uu/chgrp/src/chgrp.rs +++ b/src/uu/chgrp/src/chgrp.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index a79886037..07fe9bdf9 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Alex Lyon -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs index 67e71b815..8e97d5652 100644 --- a/src/uu/chown/src/chown.rs +++ b/src/uu/chown/src/chown.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 2d1c3703e..6366775c3 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Vsevolod Velichko -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index a46f69302..83d48ec1a 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Michael Gehring -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/comm/src/comm.rs b/src/uu/comm/src/comm.rs index b88087389..1bb0020d5 100644 --- a/src/uu/comm/src/comm.rs +++ b/src/uu/comm/src/comm.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Michael Gehring -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index e0a40d56e..ce16357c6 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -3,9 +3,6 @@ // This file is part of the uutils coreutils package. // -// (c) Jordy Dickinson -// (c) Joshua S. Miller -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uu/cut/src/cut.rs b/src/uu/cut/src/cut.rs index 33dd3850d..891281753 100644 --- a/src/uu/cut/src/cut.rs +++ b/src/uu/cut/src/cut.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Rolf Morel -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/cut/src/searcher.rs b/src/uu/cut/src/searcher.rs index 95d85c020..21424790e 100644 --- a/src/uu/cut/src/searcher.rs +++ b/src/uu/cut/src/searcher.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Rolf Morel -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index 7ec28e491..745fd5423 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Anthony Deschamps -// (c) Sylvestre Ledru -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/dd/src/conversion_tables.rs b/src/uu/dd/src/conversion_tables.rs index aca2ef9bc..bdf6398ac 100644 --- a/src/uu/dd/src/conversion_tables.rs +++ b/src/uu/dd/src/conversion_tables.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Tyler Steele -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/dd/src/datastructures.rs b/src/uu/dd/src/datastructures.rs index 6830df63e..c0da8c67c 100644 --- a/src/uu/dd/src/datastructures.rs +++ b/src/uu/dd/src/datastructures.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Tyler Steele -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore ctable, outfile, iseek, oseek diff --git a/src/uu/dd/src/dd.rs b/src/uu/dd/src/dd.rs index 4e1287939..4ac2aa780 100644 --- a/src/uu/dd/src/dd.rs +++ b/src/uu/dd/src/dd.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Tyler Steele -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/dd/src/parseargs.rs b/src/uu/dd/src/parseargs.rs index 20a8da1ee..bccf98f82 100644 --- a/src/uu/dd/src/parseargs.rs +++ b/src/uu/dd/src/parseargs.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Tyler Steele -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore ctty, ctable, iseek, oseek, iconvflags, oconvflags parseargs outfile oconv diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index ef1584323..9a3eeac65 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Fangxu Hu -// (c) Sylvestre Ledru -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. // spell-checker:ignore itotal iused iavail ipcent pcent tmpfs squashfs lofs diff --git a/src/uu/dircolors/src/dircolors.rs b/src/uu/dircolors/src/dircolors.rs index 19c3f7e31..4961cccf5 100644 --- a/src/uu/dircolors/src/dircolors.rs +++ b/src/uu/dircolors/src/dircolors.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// (c) Mitchell Mebane -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/dirname/src/dirname.rs b/src/uu/dirname/src/dirname.rs index 4d9c09cc3..9a56e9f5b 100644 --- a/src/uu/dirname/src/dirname.rs +++ b/src/uu/dirname/src/dirname.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Derek Chiang -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index 659dc836c..cd9467714 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Derek Chiang -// (c) Christopher Brown -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index 08704f364..e031e39e3 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jordi Boggiano -// (c) Thomas Queiroz -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/expand/src/expand.rs b/src/uu/expand/src/expand.rs index 98b292771..fb73ce4b5 100644 --- a/src/uu/expand/src/expand.rs +++ b/src/uu/expand/src/expand.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Virgile Andreani -// (c) kwantam -// * 2015-04-28 ~ updated to work with both UTF-8 and non-UTF-8 encodings // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/groups/src/groups.rs b/src/uu/groups/src/groups.rs index dd1cd9b04..0f0dfce80 100644 --- a/src/uu/groups/src/groups.rs +++ b/src/uu/groups/src/groups.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Alan Andrade -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 9f4849f90..724ea8d8b 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Alan Andrade -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 34d3b76f2..792768153 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jeremiah Peschka -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uu/mknod/src/mknod.rs b/src/uu/mknod/src/mknod.rs index ad7618cc8..0d4709914 100644 --- a/src/uu/mknod/src/mknod.rs +++ b/src/uu/mknod/src/mknod.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index 9c0860d92..f99136810 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Sunrin SHIMURA -// Collaborator: Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 03d3881b1..3aacab300 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Orvar Segerström -// (c) Sokovikov Evgeniy -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uu/pinky/src/pinky.rs b/src/uu/pinky/src/pinky.rs index 172a9e138..8ac8f6c84 100644 --- a/src/uu/pinky/src/pinky.rs +++ b/src/uu/pinky/src/pinky.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 9ffa064b8..b3c9dc513 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uu/test/src/parser.rs b/src/uu/test/src/parser.rs index db90098a1..2b847fa15 100644 --- a/src/uu/test/src/parser.rs +++ b/src/uu/test/src/parser.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Daniel Rocco -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/test/src/test.rs b/src/uu/test/src/test.rs index b0a8fc613..7e778f9b5 100644 --- a/src/uu/test/src/test.rs +++ b/src/uu/test/src/test.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) mahkoh (ju.orth [at] gmail [dot] com) -// (c) Daniel Rocco -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index baa28890c..135d119bd 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Nick Platt -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uu/uname/src/uname.rs b/src/uu/uname/src/uname.rs index 8b8679234..73ab07a63 100644 --- a/src/uu/uname/src/uname.rs +++ b/src/uu/uname/src/uname.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Joao Oliveira -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/who/src/who.rs b/src/uu/who/src/who.rs index fbfff80d7..29929b138 100644 --- a/src/uu/who/src/who.rs +++ b/src/uu/who/src/who.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uucore/src/lib/features/encoding.rs b/src/uucore/src/lib/features/encoding.rs index a42044eea..14fdbb38e 100644 --- a/src/uucore/src/lib/features/encoding.rs +++ b/src/uucore/src/lib/features/encoding.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uucore/src/lib/features/entries.rs b/src/uucore/src/lib/features/entries.rs index c0229aa3e..c06c5116e 100644 --- a/src/uucore/src/lib/features/entries.rs +++ b/src/uucore/src/lib/features/entries.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index 5804a2235..e4c5e84de 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Joseph Crail -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uucore/src/lib/features/fsext.rs b/src/uucore/src/lib/features/fsext.rs index 6f831fb92..f526e7fde 100644 --- a/src/uucore/src/lib/features/fsext.rs +++ b/src/uucore/src/lib/features/fsext.rs @@ -1,9 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// (c) Fangxu Hu -// (c) Sylvestre Ledru -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uucore/src/lib/features/mode.rs b/src/uucore/src/lib/features/mode.rs index 9435e3201..cbaea71bf 100644 --- a/src/uucore/src/lib/features/mode.rs +++ b/src/uucore/src/lib/features/mode.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Alex Lyon -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uucore/src/lib/features/process.rs b/src/uucore/src/lib/features/process.rs index 4a52f0fc4..8e7e46479 100644 --- a/src/uucore/src/lib/features/process.rs +++ b/src/uucore/src/lib/features/process.rs @@ -1,8 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Maciej Dziardziel -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uucore/src/lib/features/signals.rs b/src/uucore/src/lib/features/signals.rs index c9f7295ee..423eb19c9 100644 --- a/src/uucore/src/lib/features/signals.rs +++ b/src/uucore/src/lib/features/signals.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Maciej Dziardziel -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uucore/src/lib/features/sum.rs b/src/uucore/src/lib/features/sum.rs index c1cfaf5f8..d4945421e 100644 --- a/src/uucore/src/lib/features/sum.rs +++ b/src/uucore/src/lib/features/sum.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Yuan YangHao -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. diff --git a/src/uucore/src/lib/features/utmpx.rs b/src/uucore/src/lib/features/utmpx.rs index 35c5ac5b0..1b6ecbcf5 100644 --- a/src/uucore/src/lib/features/utmpx.rs +++ b/src/uucore/src/lib/features/utmpx.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // diff --git a/src/uucore/src/lib/features/wide.rs b/src/uucore/src/lib/features/wide.rs index 6b9368f50..68341cd68 100644 --- a/src/uucore/src/lib/features/wide.rs +++ b/src/uucore/src/lib/features/wide.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Peter Atashian -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uucore/src/lib/macros.rs b/src/uucore/src/lib/macros.rs index cc8bdafd8..d1893dd9a 100644 --- a/src/uucore/src/lib/macros.rs +++ b/src/uucore/src/lib/macros.rs @@ -36,8 +36,6 @@ use std::sync::atomic::AtomicBool; // This file is part of the uutils coreutils package. // -// (c) Alex Lyon -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uucore/src/lib/mods/ranges.rs b/src/uucore/src/lib/mods/ranges.rs index 76a61b9a6..29f402183 100644 --- a/src/uucore/src/lib/mods/ranges.rs +++ b/src/uucore/src/lib/mods/ranges.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Rolf Morel -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uucore/src/lib/mods/update_control.rs b/src/uucore/src/lib/mods/update_control.rs index e46afd185..bd4292514 100644 --- a/src/uucore/src/lib/mods/update_control.rs +++ b/src/uucore/src/lib/mods/update_control.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) John Shin -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uucore/src/lib/parser/parse_time.rs b/src/uucore/src/lib/parser/parse_time.rs index 1a7b66e90..727ee28b1 100644 --- a/src/uucore/src/lib/parser/parse_time.rs +++ b/src/uucore/src/lib/parser/parse_time.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Alex Lyon -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/tests/by-util/test_base32.rs b/tests/by-util/test_base32.rs index 395c96c2c..b8e72cb04 100644 --- a/tests/by-util/test_base32.rs +++ b/tests/by-util/test_base32.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) Jian Zeng -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. // diff --git a/tests/by-util/test_factor.rs b/tests/by-util/test_factor.rs index cf3744964..9154f57cf 100644 --- a/tests/by-util/test_factor.rs +++ b/tests/by-util/test_factor.rs @@ -1,7 +1,5 @@ // This file is part of the uutils coreutils package. // -// (c) kwantam -// // For the full copyright and license information, please view the LICENSE file // that was distributed with this source code. #![allow(clippy::unreadable_literal)] diff --git a/tests/by-util/test_test.rs b/tests/by-util/test_test.rs index bf5c50b7f..91af9033a 100644 --- a/tests/by-util/test_test.rs +++ b/tests/by-util/test_test.rs @@ -1,9 +1,6 @@ // // This file is part of the uutils coreutils package. // -// (c) mahkoh (ju.orth [at] gmail [dot] com) -// (c) Daniel Rocco -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // From 93a5b161ae9c61d1d91ce1c16ae93c0058f42082 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Mon, 21 Aug 2023 14:51:06 +0200 Subject: [PATCH 062/370] docs: add conda installer --- docs/src/installation.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/src/installation.md b/docs/src/installation.md index e5fcb6220..da124ead9 100644 --- a/docs/src/installation.md +++ b/docs/src/installation.md @@ -1,4 +1,4 @@ - + # Installation @@ -139,6 +139,16 @@ pkg install rust-coreutils scoop install uutils-coreutils ``` +## Alternative installers + +### Conda + +[Conda package](https://anaconda.org/conda-forge/uutils-coreutils) + +``` +conda install -c conda-forge uutils-coreutils +``` + ## Non-standard packages ### `coreutils-hybrid` (AUR) From 76eea583b43d47110d76c637a6f744cfe9eb8993 Mon Sep 17 00:00:00 2001 From: Ben Schofield Date: Mon, 21 Aug 2023 12:10:31 -0700 Subject: [PATCH 063/370] Add benchmarking for `rm` Add benchmarking script and guide for `rm`, mostly copied from `ls` benchmarking guide. Tested `rm` using `jwalk` instead of `walkdir`, and saw a slight performance regression, if any change. --- src/uu/rm/BENCHMARKING.md | 52 +++++++++++++++++++++++++++++++++++++++ src/uu/rm/benchmark.sh | 8 ++++++ 2 files changed, 60 insertions(+) create mode 100644 src/uu/rm/BENCHMARKING.md create mode 100755 src/uu/rm/benchmark.sh diff --git a/src/uu/rm/BENCHMARKING.md b/src/uu/rm/BENCHMARKING.md new file mode 100644 index 000000000..ee524cb24 --- /dev/null +++ b/src/uu/rm/BENCHMARKING.md @@ -0,0 +1,52 @@ +# Benchmarking rm + +Run `cargo build --release` before benchmarking after you make a change! + +## Simple recursive rm + +- Get a large tree, for example linux kernel source tree. +- We'll need to pass a `--prepare` argument, since `rm` deletes the dir each time. +- Benchmark simple recursive rm with hyperfine: `hyperfine --prepare "cp -r tree tree-tmp" "target/release/coreutils rm -r tree-tmp"`. + +## Comparing with GNU rm + +Hyperfine accepts multiple commands to run and will compare them. To compare performance with GNU rm +duplicate the string you passed to hyperfine but remove the `target/release/coreutils` bit from it. + +Example: `hyperfine --prepare "cp -r tree tree-tmp" "target/release/coreutils rm -rf tree-tmp"` becomes +`hyperfine --prepare "cp -r tree tree-tmp" "target/release/coreutils rm -rf tree-tmp" "rm -rf tree-tmp"` +(This assumes GNU rm is installed as `rm`) + +This can also be used to compare with version of rm built before your changes to ensure your change does not regress this. + +Here is a `bash` script for doing this comparison: + +```shell +#!/bin/bash +cargo build --no-default-features --features rm --release +test_dir="$1" +hyperfine --prepare "cp -r $test_dir tmp_d" "rm -rf tmp_d" "target/release/coreutils rm -rf tmp_d" +``` + +## Checking system call count + +- Another thing to look at would be system calls count using strace (on linux) or equivalent on other operating systems. +- Example: `strace -c target/release/coreutils rm -rf tree` + +## Cargo Flamegraph + +With Cargo Flamegraph you can easily make a flamegraph of `rm`: + +```shell +cargo flamegraph --cmd coreutils -- rm [additional parameters] +``` + +However, if the `-r` option is given, the output becomes pretty much useless due to recursion. We can fix this by merging all the direct recursive calls with `uniq`, below is a `bash` script that does this. + +```shell +#!/bin/bash +cargo build --release --no-default-features --features rm +perf record target/release/coreutils rm "$@" +perf script | uniq | inferno-collapse-perf | inferno-flamegraph > flamegraph.svg +``` + diff --git a/src/uu/rm/benchmark.sh b/src/uu/rm/benchmark.sh new file mode 100755 index 000000000..5feaea4e8 --- /dev/null +++ b/src/uu/rm/benchmark.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Exit on any failures +set +x + +cargo build --no-default-features --features rm --release +test_dir="$1" +hyperfine --prepare "cp -r $test_dir tmp_d" "rm -rf tmp_d" "target/release/coreutils rm -rf tmp_d" From cd9c97f7058b9e4c79d16cc216d2d57d35d02559 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Mon, 21 Aug 2023 22:49:17 +0200 Subject: [PATCH 064/370] README: update links to docs --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4929224d1..c5b4609c9 100644 --- a/README.md +++ b/README.md @@ -54,8 +54,8 @@ that scripts can be easily transferred between platforms. uutils has both user and developer documentation available: -- [User Manual](https://uutils.github.io/user/) -- [Developer Documentation](https://uutils.github.io/dev/coreutils/) +- [User Manual](https://uutils.github.io/coreutils/book/) +- [Developer Documentation](https://uutils.github.io/dev/coreutils/) (currently offline, you can use docs.rs in the meantime) Both can also be generated locally, the instructions for that can be found in the [coreutils docs](https://github.com/uutils/uutils.github.io) repository. @@ -303,7 +303,7 @@ make PREFIX=/my/path uninstall Below is the evolution of how many GNU tests uutils passes. A more detailed breakdown of the GNU test results of the main branch can be found -[in the user manual](https://uutils.github.io/user/test_coverage.html). +[in the user manual](https://uutils.github.io/coreutils/book/test_coverage.html). See for the main meta bugs (many are missing). From 1b705ae07cebb29d59004e0c2025ab36d3090d28 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 22 Aug 2023 09:45:17 +0200 Subject: [PATCH 065/370] factor: simplify loop in test --- tests/by-util/test_factor.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/by-util/test_factor.rs b/tests/by-util/test_factor.rs index 542c6fb3f..a14a673a8 100644 --- a/tests/by-util/test_factor.rs +++ b/tests/by-util/test_factor.rs @@ -163,14 +163,12 @@ fn test_random() { let mut factors = Vec::new(); while product < min { // log distribution---higher probability for lower numbers - let factor; - loop { + let factor = loop { let next = rng.gen_range(0_f64..log_num_primes).exp2().floor() as usize; if next < NUM_PRIMES { - factor = primes[next]; - break; + break primes[next]; } - } + }; match product.checked_mul(factor) { Some(p) => { From 181261beefe8b709d8081b49f98fa5fd8efdc24c Mon Sep 17 00:00:00 2001 From: Ben Schofield Date: Tue, 22 Aug 2023 07:56:24 -0700 Subject: [PATCH 066/370] Add samply to sampling options Add samply to the sampling options for `rm` benchmarking. --- src/uu/rm/BENCHMARKING.md | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/uu/rm/BENCHMARKING.md b/src/uu/rm/BENCHMARKING.md index ee524cb24..4170e2df1 100644 --- a/src/uu/rm/BENCHMARKING.md +++ b/src/uu/rm/BENCHMARKING.md @@ -33,7 +33,24 @@ hyperfine --prepare "cp -r $test_dir tmp_d" "rm -rf tmp_d" "target/release/core - Another thing to look at would be system calls count using strace (on linux) or equivalent on other operating systems. - Example: `strace -c target/release/coreutils rm -rf tree` -## Cargo Flamegraph +## Flamegraphs + +### Samply + +Samply is one option for simply creating flamegraphs. It isues the Firefox profiler as a UI. + +To install: +```bash +cargo install samply +``` + +To run: + +```bash +samply record target/release/coreutils rm -rf ../linux +``` + +### Cargo Flamegraph With Cargo Flamegraph you can easily make a flamegraph of `rm`: @@ -41,12 +58,3 @@ With Cargo Flamegraph you can easily make a flamegraph of `rm`: cargo flamegraph --cmd coreutils -- rm [additional parameters] ``` -However, if the `-r` option is given, the output becomes pretty much useless due to recursion. We can fix this by merging all the direct recursive calls with `uniq`, below is a `bash` script that does this. - -```shell -#!/bin/bash -cargo build --release --no-default-features --features rm -perf record target/release/coreutils rm "$@" -perf script | uniq | inferno-collapse-perf | inferno-flamegraph > flamegraph.svg -``` - From 9ddf218ed97747a9bfd16179b7665f43d79882b1 Mon Sep 17 00:00:00 2001 From: Ben Schofield Date: Tue, 22 Aug 2023 07:59:11 -0700 Subject: [PATCH 067/370] Add samply url --- src/uu/rm/BENCHMARKING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/rm/BENCHMARKING.md b/src/uu/rm/BENCHMARKING.md index 4170e2df1..a71b3faed 100644 --- a/src/uu/rm/BENCHMARKING.md +++ b/src/uu/rm/BENCHMARKING.md @@ -35,9 +35,9 @@ hyperfine --prepare "cp -r $test_dir tmp_d" "rm -rf tmp_d" "target/release/core ## Flamegraphs -### Samply +### samply -Samply is one option for simply creating flamegraphs. It isues the Firefox profiler as a UI. +[samply](https://github.com/mstange/samply) is one option for simply creating flamegraphs. It isues the Firefox profiler as a UI. To install: ```bash From 7d7d4fb04a6bd053c91cc8cdc469ca734000e60d Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Tue, 22 Aug 2023 13:09:28 -0400 Subject: [PATCH 068/370] build-gnu.sh: `/usr/bin/timeout` should not be hardcoded to /usr/bin location Fixes #5193 --- util/build-gnu.sh | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index d852ed66f..d02c8c842 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -82,7 +82,16 @@ else ./bootstrap --skip-po ./configure --quiet --disable-gcc-warnings #Add timeout to to protect against hangs - sed -i 's|^"\$@|/usr/bin/timeout 600 "\$@|' build-aux/test-driver + # On MacOS there is no system /usr/bin/timeout + # and trying to add it to /usr/bin (with symlink of copy binary) will fail unless system integrity protection is disabled (not ideal) + # ref: https://support.apple.com/en-us/102149 + # On MacOS the Homebrew coreutils could be installed and then "sudo ln -s /opt/homebrew/bin/timeout /usr/local/bin/timeout" + # Set to /usr/local/timeout instead if /usr/bin/timeout is not found + if [ -x /usr/bin/timeout ] ; then + sed -i 's|^"\$@|/usr/bin/timeout 600 "\$@|' build-aux/test-driver + else + sed -i 's|^"\$@|/usr/local/bin/timeout 600 "\$@|' build-aux/test-driver + fi # Change the PATH in the Makefile to test the uutils coreutils instead of the GNU coreutils sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${UU_BUILD_DIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile sed -i 's| tr | /usr/bin/tr |' tests/init.sh @@ -153,13 +162,28 @@ sed -i 's|touch |/usr/bin/touch |' tests/cp/reflink-perm.sh tests/ls/block-size. sed -i 's|ln -|/usr/bin/ln -|' tests/cp/link-deref.sh sed -i 's|cp |/usr/bin/cp |' tests/mv/hard-2.sh sed -i 's|paste |/usr/bin/paste |' tests/misc/od-endian.sh -sed -i 's|timeout |/usr/bin/timeout |' tests/tail-2/follow-stdin.sh +# On MacOS there is no system /usr/bin/timeout +# and trying to add it to /usr/bin (with symlink of copy binary) will fail unless system integrity protection is disabled (not ideal) +# ref: https://support.apple.com/en-us/102149 +# On MacOS the Homebrew coreutils could be installed and then "sudo ln -s /opt/homebrew/bin/timeout /usr/local/bin/timeout" +# Set to /usr/local/timeout instead if /usr/bin/timeout is not found +if [ -x /usr/bin/timeout ] ; then + sed -i 's|timeout |/usr/bin/timeout |' tests/tail-2/follow-stdin.sh +else + sed -i 's|timeout |/usr/local/bin/timeout |' tests/tail-2/follow-stdin.sh +fi + # Add specific timeout to tests that currently hang to limit time spent waiting -sed -i 's|\(^\s*\)seq \$|\1/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh +if [ -x /usr/bin/timeout ] ; then + sed -i 's|\(^\s*\)seq \$|\1/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh +else + sed -i 's|\(^\s*\)seq \$|\1/usr/local/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh +fi -# Remove dup of /usr/bin/ when executed several times +# Remove dup of /usr/bin/ (and /usr/local/bin) when executed several times grep -rlE '/usr/bin/\s?/usr/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/bin/\s?/usr/bin/|/usr/bin/|g' +grep -rlE '/usr/local/bin/\s?/usr/local/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/local/bin/\s?/usr/local/bin/|/usr/local/bin/|g' #### Adjust tests to make them work with Rust/coreutils # in some cases, what we are doing in rust/coreutils is good (or better) From 75cc6e3fdccedf551e297e54715cc65ed6045c7c Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Tue, 22 Aug 2023 13:22:24 -0400 Subject: [PATCH 069/370] added some TODO(s) for missing/moved locations --- util/build-gnu.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index d02c8c842..6c608a060 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -151,6 +151,9 @@ sed -i -e '/tests\/misc\/seq-precision.sh/ D' \ sed -i '/INT_OFLOW/ D' tests/misc/printf.sh # Use the system coreutils where the test fails due to error in a util that is not the one being tested +# TODO : tests/tail-2/ does not appear to exist +# and have been moved to just tests/tail/ location +# Might need to update the section bvelow to reflect that sed -i 's|stat|/usr/bin/stat|' tests/touch/60-seconds.sh tests/misc/sort-compress-proc.sh sed -i 's|ls -|/usr/bin/ls -|' tests/cp/same-file.sh tests/misc/mknod.sh tests/mv/part-symlink.sh sed -i 's|chmod |/usr/bin/chmod |' tests/du/inacc-dir.sh tests/tail-2/tail-n0f.sh tests/cp/fail-perm.sh tests/mv/i-2.sh tests/misc/shuf.sh @@ -175,6 +178,9 @@ fi # Add specific timeout to tests that currently hang to limit time spent waiting +# TODO : tests/misc/seq-precision.sh tests/misc/seq-long-double.sh do not appear to exist +# and have been moved to tests/seq/ location +# Might need to update the section bvelow to reflect that if [ -x /usr/bin/timeout ] ; then sed -i 's|\(^\s*\)seq \$|\1/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh else @@ -205,6 +211,9 @@ sed -i -e "s|rm: cannot remove 'rel': Permission denied|rm: cannot remove 'rel': # overlay-headers.sh test intends to check for inotify events, # however there's a bug because `---dis` is an alias for: `---disable-inotify` +# TODO : tests/tail-2/ does not appear to exist +# and have been moved to just tests/tail/ location +# Might need to update the section bvelow to reflect that sed -i -e "s|---dis ||g" tests/tail-2/overlay-headers.sh test -f "${UU_BUILD_DIR}/getlimits" || cp src/getlimits "${UU_BUILD_DIR}" From c44c3cd71649252ae333dca0c55ab56d9ca52163 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Tue, 22 Aug 2023 15:28:02 -0400 Subject: [PATCH 070/370] fixed spelling --- util/build-gnu.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 6c608a060..4414b7f12 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -153,7 +153,7 @@ sed -i '/INT_OFLOW/ D' tests/misc/printf.sh # Use the system coreutils where the test fails due to error in a util that is not the one being tested # TODO : tests/tail-2/ does not appear to exist # and have been moved to just tests/tail/ location -# Might need to update the section bvelow to reflect that +# Might need to update the section below to reflect that sed -i 's|stat|/usr/bin/stat|' tests/touch/60-seconds.sh tests/misc/sort-compress-proc.sh sed -i 's|ls -|/usr/bin/ls -|' tests/cp/same-file.sh tests/misc/mknod.sh tests/mv/part-symlink.sh sed -i 's|chmod |/usr/bin/chmod |' tests/du/inacc-dir.sh tests/tail-2/tail-n0f.sh tests/cp/fail-perm.sh tests/mv/i-2.sh tests/misc/shuf.sh @@ -180,7 +180,7 @@ fi # Add specific timeout to tests that currently hang to limit time spent waiting # TODO : tests/misc/seq-precision.sh tests/misc/seq-long-double.sh do not appear to exist # and have been moved to tests/seq/ location -# Might need to update the section bvelow to reflect that +# Might need to update the section below to reflect that if [ -x /usr/bin/timeout ] ; then sed -i 's|\(^\s*\)seq \$|\1/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh else @@ -213,7 +213,7 @@ sed -i -e "s|rm: cannot remove 'rel': Permission denied|rm: cannot remove 'rel': # however there's a bug because `---dis` is an alias for: `---disable-inotify` # TODO : tests/tail-2/ does not appear to exist # and have been moved to just tests/tail/ location -# Might need to update the section bvelow to reflect that +# Might need to update the section below to reflect that sed -i -e "s|---dis ||g" tests/tail-2/overlay-headers.sh test -f "${UU_BUILD_DIR}/getlimits" || cp src/getlimits "${UU_BUILD_DIR}" From 079f7f9258964d586e48a9495da97ccedf40260c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 23 Aug 2023 00:11:14 +0000 Subject: [PATCH 071/370] chore(deps): update rust crate num-bigint to 0.4.4 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f25b7c20c..b92ab5f1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1399,9 +1399,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", diff --git a/Cargo.toml b/Cargo.toml index 71c04d355..426a2c9d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -297,7 +297,7 @@ memmap2 = "0.7" nix = { version = "0.26", default-features = false } nom = "7.1.3" notify = { version = "=6.0.1", features = ["macos_kqueue"] } -num-bigint = "0.4.3" +num-bigint = "0.4.4" num-traits = "0.2.16" number_prefix = "0.4" once_cell = "1.18.0" From 774180bb09dc372ca8057f96583c509e3e1fe2be Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 23 Aug 2023 10:54:00 +0200 Subject: [PATCH 072/370] Remove the author copyright notices from files missed by #5184 --- src/uu/dir/src/dir.rs | 2 -- src/uu/du/src/du.rs | 2 -- src/uu/expr/src/expr.rs | 2 -- src/uu/expr/src/syntax_tree.rs | 2 -- src/uu/expr/src/tokens.rs | 2 -- src/uu/factor/build.rs | 4 ---- src/uu/factor/sieve.rs | 2 -- src/uu/factor/src/cli.rs | 3 --- src/uu/factor/src/factor.rs | 2 -- src/uu/factor/src/miller_rabin.rs | 2 -- src/uu/factor/src/numeric/gcd.rs | 3 --- src/uu/factor/src/numeric/mod.rs | 2 -- src/uu/factor/src/numeric/modular_inverse.rs | 3 --- src/uu/factor/src/numeric/montgomery.rs | 3 --- src/uu/factor/src/numeric/traits.rs | 3 --- src/uu/factor/src/rho.rs | 3 --- src/uu/factor/src/table.rs | 3 --- src/uu/false/src/false.rs | 2 -- src/uu/fmt/src/fmt.rs | 4 +--- src/uu/fmt/src/linebreak.rs | 4 +--- src/uu/fmt/src/parasplit.rs | 4 +--- src/uu/fold/src/fold.rs | 2 -- src/uu/hashsum/src/hashsum.rs | 4 ---- src/uu/hostid/src/hostid.rs | 2 -- src/uu/hostname/src/hostname.rs | 2 -- src/uu/install/src/install.rs | 2 -- src/uu/join/src/join.rs | 2 -- src/uu/kill/src/kill.rs | 2 -- src/uu/link/src/link.rs | 2 -- src/uu/ln/src/ln.rs | 2 -- src/uu/logname/src/logname.rs | 2 -- src/uu/mkdir/src/mkdir.rs | 2 -- src/uu/mkfifo/src/mkfifo.rs | 2 -- src/uu/more/src/more.rs | 2 -- src/uu/nice/src/nice.rs | 2 -- src/uu/nl/src/nl.rs | 2 -- src/uu/nohup/src/nohup.rs | 2 -- src/uu/nproc/src/nproc.rs | 2 -- src/uu/numfmt/src/numfmt.rs | 2 -- src/uu/od/src/od.rs | 2 -- src/uu/paste/src/paste.rs | 2 -- src/uu/pathchk/src/pathchk.rs | 2 -- src/uu/printenv/src/printenv.rs | 2 -- src/uu/ptx/src/ptx.rs | 2 -- src/uu/pwd/src/pwd.rs | 2 -- src/uu/readlink/src/readlink.rs | 2 -- src/uu/realpath/src/realpath.rs | 2 -- src/uu/relpath/src/relpath.rs | 2 -- src/uu/rm/src/rm.rs | 2 -- src/uu/rmdir/src/rmdir.rs | 2 -- src/uu/shred/src/shred.rs | 3 --- src/uu/shuf/src/shuf.rs | 2 -- src/uu/sleep/src/sleep.rs | 2 -- src/uu/sort/src/check.rs | 2 -- src/uu/sort/src/chunks.rs | 2 -- src/uu/sort/src/custom_str_cmp.rs | 2 -- src/uu/sort/src/ext_sort.rs | 2 -- src/uu/sort/src/numeric_str_cmp.rs | 2 -- src/uu/sort/src/sort.rs | 4 ---- src/uu/split/src/split.rs | 2 -- src/uu/stdbuf/src/stdbuf.rs | 2 -- src/uu/sum/src/sum.rs | 2 -- src/uu/sync/src/sync.rs | 2 -- src/uu/tac/src/tac.rs | 2 -- src/uu/tail/src/platform/mod.rs | 3 --- src/uu/tail/src/platform/unix.rs | 3 --- src/uu/tail/src/platform/windows.rs | 2 -- src/uu/tail/src/tail.rs | 4 ---- src/uu/tee/src/tee.rs | 2 -- src/uu/timeout/src/timeout.rs | 2 -- src/uu/true/src/true.rs | 2 -- src/uu/truncate/src/truncate.rs | 2 -- src/uu/tsort/src/tsort.rs | 3 --- src/uu/tty/src/tty.rs | 2 -- src/uu/unexpand/src/unexpand.rs | 4 ---- src/uu/uniq/src/uniq.rs | 2 -- src/uu/unlink/src/unlink.rs | 2 -- src/uu/uptime/src/uptime.rs | 3 --- src/uu/users/src/users.rs | 3 --- src/uu/vdir/src/vdir.rs | 2 -- src/uu/wc/src/wc.rs | 2 -- src/uu/whoami/src/platform/mod.rs | 2 -- src/uu/whoami/src/platform/unix.rs | 3 --- src/uu/whoami/src/platform/windows.rs | 2 -- src/uu/whoami/src/whoami.rs | 2 -- src/uu/yes/src/yes.rs | 2 -- 86 files changed, 3 insertions(+), 199 deletions(-) diff --git a/src/uu/dir/src/dir.rs b/src/uu/dir/src/dir.rs index 6caf7bbe8..fb26b265f 100644 --- a/src/uu/dir/src/dir.rs +++ b/src/uu/dir/src/dir.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) gmnsii -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 14bda4967..493eb4848 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Derek Chiang -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/expr/src/expr.rs b/src/uu/expr/src/expr.rs index 97cfa32f3..458466558 100644 --- a/src/uu/expr/src/expr.rs +++ b/src/uu/expr/src/expr.rs @@ -1,7 +1,5 @@ //* This file is part of the uutils coreutils package. //* -//* (c) Roman Gafiyatullin -//* //* For the full copyright and license information, please view the LICENSE //* file that was distributed with this source code. diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index 1d2ddbced..71a0d5408 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -1,7 +1,5 @@ //* This file is part of the uutils coreutils package. //* -//* (c) Roman Gafiyatullin -//* //* For the full copyright and license information, please view the LICENSE //* file that was distributed with this source code. diff --git a/src/uu/expr/src/tokens.rs b/src/uu/expr/src/tokens.rs index 21220d7dc..f211eefaa 100644 --- a/src/uu/expr/src/tokens.rs +++ b/src/uu/expr/src/tokens.rs @@ -1,7 +1,5 @@ //* This file is part of the uutils coreutils package. //* -//* (c) Roman Gafiyatullin -//* //* For the full copyright and license information, please view the LICENSE //* file that was distributed with this source code. diff --git a/src/uu/factor/build.rs b/src/uu/factor/build.rs index bdd132094..2ec215f2e 100644 --- a/src/uu/factor/build.rs +++ b/src/uu/factor/build.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) kwantam -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. @@ -92,8 +90,6 @@ const MAX_WIDTH: usize = 102; const PREAMBLE: &str = r##"/* * This file is part of the uutils coreutils package. * -* (c) kwantam -* * For the full copyright and license information, please view the LICENSE file * that was distributed with this source code. */ diff --git a/src/uu/factor/sieve.rs b/src/uu/factor/sieve.rs index 2c637fad1..3d569c6bf 100644 --- a/src/uu/factor/sieve.rs +++ b/src/uu/factor/sieve.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) kwantam -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/factor/src/cli.rs b/src/uu/factor/src/cli.rs index 714b38e5e..d35e2ede6 100644 --- a/src/uu/factor/src/cli.rs +++ b/src/uu/factor/src/cli.rs @@ -1,8 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2014 T. Jameson Little -// * (c) 2020 nicoo -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/factor/src/factor.rs b/src/uu/factor/src/factor.rs index a87f4219e..7ce5eb822 100644 --- a/src/uu/factor/src/factor.rs +++ b/src/uu/factor/src/factor.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2020 nicoo -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/factor/src/miller_rabin.rs b/src/uu/factor/src/miller_rabin.rs index de2f8a924..5c88278d2 100644 --- a/src/uu/factor/src/miller_rabin.rs +++ b/src/uu/factor/src/miller_rabin.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2020 nicoo -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/factor/src/numeric/gcd.rs b/src/uu/factor/src/numeric/gcd.rs index 05eb20cb0..10efc339a 100644 --- a/src/uu/factor/src/numeric/gcd.rs +++ b/src/uu/factor/src/numeric/gcd.rs @@ -1,8 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2015 Wiktor Kuropatwa -// * (c) 2020 nicoo -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/factor/src/numeric/mod.rs b/src/uu/factor/src/numeric/mod.rs index d086027b8..4a087274b 100644 --- a/src/uu/factor/src/numeric/mod.rs +++ b/src/uu/factor/src/numeric/mod.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2020 nicoo -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/factor/src/numeric/modular_inverse.rs b/src/uu/factor/src/numeric/modular_inverse.rs index 992253a43..52e87e412 100644 --- a/src/uu/factor/src/numeric/modular_inverse.rs +++ b/src/uu/factor/src/numeric/modular_inverse.rs @@ -1,8 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2015 Wiktor Kuropatwa -// * (c) 2020 nicoo -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/factor/src/numeric/montgomery.rs b/src/uu/factor/src/numeric/montgomery.rs index d411d0d41..3d225dd1e 100644 --- a/src/uu/factor/src/numeric/montgomery.rs +++ b/src/uu/factor/src/numeric/montgomery.rs @@ -1,8 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2020 Alex Lyon -// * (c) 2020 nicoo -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/factor/src/numeric/traits.rs b/src/uu/factor/src/numeric/traits.rs index 1dc681976..a3b8912f9 100644 --- a/src/uu/factor/src/numeric/traits.rs +++ b/src/uu/factor/src/numeric/traits.rs @@ -1,8 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2020 Alex Lyon -// * (c) 2020 nicoo -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/factor/src/rho.rs b/src/uu/factor/src/rho.rs index e7aa00b4d..8de8ade83 100644 --- a/src/uu/factor/src/rho.rs +++ b/src/uu/factor/src/rho.rs @@ -1,8 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2015 Wiktor Kuropatwa -// * (c) 2020 nicoo -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/factor/src/table.rs b/src/uu/factor/src/table.rs index 0fb338d9d..063ec0620 100644 --- a/src/uu/factor/src/table.rs +++ b/src/uu/factor/src/table.rs @@ -1,8 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2015 kwantam -// * (c) 2020 nicoo -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/false/src/false.rs b/src/uu/false/src/false.rs index 27b6be291..293bb1eb5 100644 --- a/src/uu/false/src/false.rs +++ b/src/uu/false/src/false.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Jordi Boggiano -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. use clap::{Arg, ArgAction, Command}; diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index bf08fbc3e..0ff20e987 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -1,6 +1,4 @@ -// * This file is part of `fmt` from the uutils coreutils package. -// * -// * (c) kwantam +// * This file is part of the uutils coreutils package. // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/fmt/src/linebreak.rs b/src/uu/fmt/src/linebreak.rs index e86623c88..b3e79152f 100644 --- a/src/uu/fmt/src/linebreak.rs +++ b/src/uu/fmt/src/linebreak.rs @@ -1,6 +1,4 @@ -// * This file is part of `fmt` from the uutils coreutils package. -// * -// * (c) kwantam +// * This file is part of the uutils coreutils package. // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/fmt/src/parasplit.rs b/src/uu/fmt/src/parasplit.rs index c94c81974..fbad5d16e 100644 --- a/src/uu/fmt/src/parasplit.rs +++ b/src/uu/fmt/src/parasplit.rs @@ -1,6 +1,4 @@ -// * This file is part of `fmt` from the uutils coreutils package. -// * -// * (c) kwantam +// * This file is part of the uutils coreutils package. // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/fold/src/fold.rs b/src/uu/fold/src/fold.rs index d53573d82..b01101942 100644 --- a/src/uu/fold/src/fold.rs +++ b/src/uu/fold/src/fold.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alex Lyon -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index cc1b050fd..0e297c8cc 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -1,9 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alex Lyon -// * (c) Vsevolod Velichko -// * (c) Gil Cottle -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/hostid/src/hostid.rs b/src/uu/hostid/src/hostid.rs index 3657d137a..f30def1b9 100644 --- a/src/uu/hostid/src/hostid.rs +++ b/src/uu/hostid/src/hostid.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Maciej Dziardziel -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs index 83a22a82f..82df4e99f 100644 --- a/src/uu/hostname/src/hostname.rs +++ b/src/uu/hostname/src/hostname.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alan Andrade -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index 8aca020af..a2d49fe8b 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Ben Eills -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index afcb4d7d2..e769ceb58 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Konstantin Pospelov -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/kill/src/kill.rs b/src/uu/kill/src/kill.rs index d18a483fd..1bc89f9a6 100644 --- a/src/uu/kill/src/kill.rs +++ b/src/uu/kill/src/kill.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Maciej Dziardziel -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/link/src/link.rs b/src/uu/link/src/link.rs index 6688003a9..6a7f78fca 100644 --- a/src/uu/link/src/link.rs +++ b/src/uu/link/src/link.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Michael Gehring -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. use clap::builder::ValueParser; diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index c2bf25c5c..42426be3c 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Joseph Crail -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/logname/src/logname.rs b/src/uu/logname/src/logname.rs index b3cd06243..55008bb73 100644 --- a/src/uu/logname/src/logname.rs +++ b/src/uu/logname/src/logname.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Benoit Benedetti -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/mkdir/src/mkdir.rs b/src/uu/mkdir/src/mkdir.rs index a94439af5..cdc03a30c 100644 --- a/src/uu/mkdir/src/mkdir.rs +++ b/src/uu/mkdir/src/mkdir.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Nicholas Juszczak -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/mkfifo/src/mkfifo.rs b/src/uu/mkfifo/src/mkfifo.rs index dc338cf12..021dbff5f 100644 --- a/src/uu/mkfifo/src/mkfifo.rs +++ b/src/uu/mkfifo/src/mkfifo.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Michael Gehring -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index c488ba8af..6cbfa2b1d 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Martin Kysel -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/nice/src/nice.rs b/src/uu/nice/src/nice.rs index b23608ff6..35871d694 100644 --- a/src/uu/nice/src/nice.rs +++ b/src/uu/nice/src/nice.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alex Lyon -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 5bb1eb9e4..519102a31 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Tobias Bohumir Schottdorf -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. // * diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index 8247cdb3e..3f2453471 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2014 Vsevolod Velichko -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/nproc/src/nproc.rs b/src/uu/nproc/src/nproc.rs index 2b6cae04e..16262d514 100644 --- a/src/uu/nproc/src/nproc.rs +++ b/src/uu/nproc/src/nproc.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Michael Gehring -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index b0a5670d4..10ae5387c 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Yury Krivopalov -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index 09765ed2b..dd083ff6d 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Ben Hirsch -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/paste/src/paste.rs b/src/uu/paste/src/paste.rs index 45ba2d8dc..8541e0d50 100644 --- a/src/uu/paste/src/paste.rs +++ b/src/uu/paste/src/paste.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alex Lyon -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index 598b9718b..f59fd6a90 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -2,8 +2,6 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Inokentiy Babushkin -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/printenv/src/printenv.rs b/src/uu/printenv/src/printenv.rs index beeb7285b..166670244 100644 --- a/src/uu/printenv/src/printenv.rs +++ b/src/uu/printenv/src/printenv.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Jordi Boggiano -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index ecfd67ce8..38cc1473d 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Dorota Kapturkiewicz -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/pwd/src/pwd.rs b/src/uu/pwd/src/pwd.rs index 9e04dd38b..0b532672a 100644 --- a/src/uu/pwd/src/pwd.rs +++ b/src/uu/pwd/src/pwd.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Derek Chiang -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/readlink/src/readlink.rs b/src/uu/readlink/src/readlink.rs index 7e9f7be15..3775f7487 100644 --- a/src/uu/readlink/src/readlink.rs +++ b/src/uu/readlink/src/readlink.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Haitao Li -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/realpath/src/realpath.rs b/src/uu/realpath/src/realpath.rs index e2b7d7557..ddbb254d5 100644 --- a/src/uu/realpath/src/realpath.rs +++ b/src/uu/realpath/src/realpath.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2014 Vsevolod Velichko -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/relpath/src/relpath.rs b/src/uu/relpath/src/relpath.rs index ef7c43474..e667a60cc 100644 --- a/src/uu/relpath/src/relpath.rs +++ b/src/uu/relpath/src/relpath.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) 2014 Vsevolod Velichko -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index fb4a2149e..a87eca2b0 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alex Lyon -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/rmdir/src/rmdir.rs b/src/uu/rmdir/src/rmdir.rs index d0123186f..73bdce231 100644 --- a/src/uu/rmdir/src/rmdir.rs +++ b/src/uu/rmdir/src/rmdir.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alex Lyon -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index fd14a3245..6af81022a 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -1,8 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Michael Rosenberg <42micro@gmail.com> -// * (c) Fort -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/shuf/src/shuf.rs b/src/uu/shuf/src/shuf.rs index 2481baf3d..987383f4a 100644 --- a/src/uu/shuf/src/shuf.rs +++ b/src/uu/shuf/src/shuf.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alex Lyon -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/sleep/src/sleep.rs b/src/uu/sleep/src/sleep.rs index 8acb7724f..b8dc3c612 100644 --- a/src/uu/sleep/src/sleep.rs +++ b/src/uu/sleep/src/sleep.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alex Lyon -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/sort/src/check.rs b/src/uu/sort/src/check.rs index cc687aafc..df080acae 100644 --- a/src/uu/sort/src/check.rs +++ b/src/uu/sort/src/check.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Michael Debertol -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/sort/src/chunks.rs b/src/uu/sort/src/chunks.rs index ffee7e453..e1ba68ade 100644 --- a/src/uu/sort/src/chunks.rs +++ b/src/uu/sort/src/chunks.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Michael Debertol -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/sort/src/custom_str_cmp.rs b/src/uu/sort/src/custom_str_cmp.rs index 089d33bc4..7b626548f 100644 --- a/src/uu/sort/src/custom_str_cmp.rs +++ b/src/uu/sort/src/custom_str_cmp.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Michael Debertol -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/sort/src/ext_sort.rs b/src/uu/sort/src/ext_sort.rs index a8f4b2590..ae9c7403e 100644 --- a/src/uu/sort/src/ext_sort.rs +++ b/src/uu/sort/src/ext_sort.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Michael Debertol -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/sort/src/numeric_str_cmp.rs b/src/uu/sort/src/numeric_str_cmp.rs index 1a986ea76..31c85d6db 100644 --- a/src/uu/sort/src/numeric_str_cmp.rs +++ b/src/uu/sort/src/numeric_str_cmp.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Michael Debertol -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index b40eb05c1..c4091d437 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -1,9 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Michael Yin -// * (c) Robert Swinford -// * (c) Michael Debertol -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index f1be0c47d..345d489ca 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Akira Hayakawa -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index 85dddbddd..b5c79b365 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Dorota Kapturkiewicz -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/sum/src/sum.rs b/src/uu/sum/src/sum.rs index 6a17a630d..91c6cdb6c 100644 --- a/src/uu/sum/src/sum.rs +++ b/src/uu/sum/src/sum.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) T. Jameson Little -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/sync/src/sync.rs b/src/uu/sync/src/sync.rs index e135fbe7f..3ad53314c 100644 --- a/src/uu/sync/src/sync.rs +++ b/src/uu/sync/src/sync.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alexander Fomin -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/tac/src/tac.rs b/src/uu/tac/src/tac.rs index 96bb82f1e..68cc8b333 100644 --- a/src/uu/tac/src/tac.rs +++ b/src/uu/tac/src/tac.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alex Lyon -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/tail/src/platform/mod.rs b/src/uu/tail/src/platform/mod.rs index e5ae8b8d8..fb953ca10 100644 --- a/src/uu/tail/src/platform/mod.rs +++ b/src/uu/tail/src/platform/mod.rs @@ -1,9 +1,6 @@ /* * This file is part of the uutils coreutils package. * - * (c) Alexander Batischev - * (c) Thomas Queiroz - * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/src/uu/tail/src/platform/unix.rs b/src/uu/tail/src/platform/unix.rs index ed34b2cf9..26d0c3d8e 100644 --- a/src/uu/tail/src/platform/unix.rs +++ b/src/uu/tail/src/platform/unix.rs @@ -1,9 +1,6 @@ /* * This file is part of the uutils coreutils package. * - * (c) Alexander Batischev - * (c) Thomas Queiroz - * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/src/uu/tail/src/platform/windows.rs b/src/uu/tail/src/platform/windows.rs index 3e4cc7edc..263d35417 100644 --- a/src/uu/tail/src/platform/windows.rs +++ b/src/uu/tail/src/platform/windows.rs @@ -1,8 +1,6 @@ /* * This file is part of the uutils coreutils package. * - * (c) Alexander Batischev - * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/src/uu/tail/src/tail.rs b/src/uu/tail/src/tail.rs index e07616c6f..daf683936 100644 --- a/src/uu/tail/src/tail.rs +++ b/src/uu/tail/src/tail.rs @@ -1,9 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Morten Olsen Lysgaard -// * (c) Alexander Batischev -// * (c) Thomas Queiroz -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index 5c388dd0e..6382eb4ec 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Aleksander Bielawski -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index 531f29e82..e492ef591 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alex Lyon -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/true/src/true.rs b/src/uu/true/src/true.rs index 334652ce8..3b7fe817a 100644 --- a/src/uu/true/src/true.rs +++ b/src/uu/true/src/true.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Jordi Boggiano -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. use clap::{Arg, ArgAction, Command}; diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index f050b52b4..cd3875b78 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Alex Lyon -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/tsort/src/tsort.rs b/src/uu/tsort/src/tsort.rs index 68f51b213..d0a178df2 100644 --- a/src/uu/tsort/src/tsort.rs +++ b/src/uu/tsort/src/tsort.rs @@ -1,8 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Ben Eggers -// * (c) Akira Hayakawa -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. use clap::{crate_version, Arg, Command}; diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index e2d9d1847..4f351b932 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Jordi Boggiano -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. // * diff --git a/src/uu/unexpand/src/unexpand.rs b/src/uu/unexpand/src/unexpand.rs index dd4471e2d..74e25d3f8 100644 --- a/src/uu/unexpand/src/unexpand.rs +++ b/src/uu/unexpand/src/unexpand.rs @@ -1,9 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Virgile Andreani -// * (c) kwantam -// * * 2015-04-28 ~ updated to work with both UTF-8 and non-UTF-8 encodings -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index 89141f35f..330aa23e9 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Chirag B Jadwani -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/unlink/src/unlink.rs b/src/uu/unlink/src/unlink.rs index 5d1594a05..6091cdcef 100644 --- a/src/uu/unlink/src/unlink.rs +++ b/src/uu/unlink/src/unlink.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Colin Warren -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/uptime/src/uptime.rs b/src/uu/uptime/src/uptime.rs index 6f4e62084..f615d313d 100644 --- a/src/uu/uptime/src/uptime.rs +++ b/src/uu/uptime/src/uptime.rs @@ -1,8 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Jordi Boggiano -// * (c) Jian Zeng -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/users/src/users.rs b/src/uu/users/src/users.rs index 6a5e54f99..f1f38c873 100644 --- a/src/uu/users/src/users.rs +++ b/src/uu/users/src/users.rs @@ -1,8 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) KokaKiwi -// * (c) Jian Zeng -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/vdir/src/vdir.rs b/src/uu/vdir/src/vdir.rs index c49a3f1b3..8caa47150 100644 --- a/src/uu/vdir/src/vdir.rs +++ b/src/uu/vdir/src/vdir.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) gmnsii -// * // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index b79559b29..48b544783 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Boden Garman -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/whoami/src/platform/mod.rs b/src/uu/whoami/src/platform/mod.rs index b5064a8d2..57edb1dc5 100644 --- a/src/uu/whoami/src/platform/mod.rs +++ b/src/uu/whoami/src/platform/mod.rs @@ -1,8 +1,6 @@ /* * This file is part of the uutils coreutils package. * - * (c) Jordi Boggiano - * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/src/uu/whoami/src/platform/unix.rs b/src/uu/whoami/src/platform/unix.rs index 1c0ea15d5..8288c3978 100644 --- a/src/uu/whoami/src/platform/unix.rs +++ b/src/uu/whoami/src/platform/unix.rs @@ -1,9 +1,6 @@ /* * This file is part of the uutils coreutils package. * - * (c) Jordi Boggiano - * (c) Jian Zeng - * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/src/uu/whoami/src/platform/windows.rs b/src/uu/whoami/src/platform/windows.rs index 3bad1eb21..44be482c7 100644 --- a/src/uu/whoami/src/platform/windows.rs +++ b/src/uu/whoami/src/platform/windows.rs @@ -1,8 +1,6 @@ /* * This file is part of the uutils coreutils package. * - * (c) Jordi Boggiano - * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ diff --git a/src/uu/whoami/src/whoami.rs b/src/uu/whoami/src/whoami.rs index 04360fe7a..00802633e 100644 --- a/src/uu/whoami/src/whoami.rs +++ b/src/uu/whoami/src/whoami.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Jordi Boggiano -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. diff --git a/src/uu/yes/src/yes.rs b/src/uu/yes/src/yes.rs index 72c19b872..e4cf0180e 100644 --- a/src/uu/yes/src/yes.rs +++ b/src/uu/yes/src/yes.rs @@ -1,7 +1,5 @@ // * This file is part of the uutils coreutils package. // * -// * (c) Jordi Boggiano -// * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. From 903490a9c8c505203a6cd80949398e261d03a1ed Mon Sep 17 00:00:00 2001 From: Ben Schofield Date: Wed, 23 Aug 2023 13:05:06 -0700 Subject: [PATCH 073/370] spelling --- src/uu/rm/BENCHMARKING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/rm/BENCHMARKING.md b/src/uu/rm/BENCHMARKING.md index a71b3faed..cff93ec93 100644 --- a/src/uu/rm/BENCHMARKING.md +++ b/src/uu/rm/BENCHMARKING.md @@ -33,11 +33,11 @@ hyperfine --prepare "cp -r $test_dir tmp_d" "rm -rf tmp_d" "target/release/core - Another thing to look at would be system calls count using strace (on linux) or equivalent on other operating systems. - Example: `strace -c target/release/coreutils rm -rf tree` -## Flamegraphs +## Flamegraph ### samply -[samply](https://github.com/mstange/samply) is one option for simply creating flamegraphs. It isues the Firefox profiler as a UI. +[samply](https://github.com/mstange/samply) is one option for simply creating flamegraphs. It uses the Firefox profiler as a UI. To install: ```bash From c3f9e19a3bc8c254015239670e562d2a60d67d74 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Thu, 24 Aug 2023 12:07:48 +0200 Subject: [PATCH 074/370] all: normalize license notice in all *.rs files --- build.rs | 5 +++++ src/uu/base32/src/base32.rs | 4 ++-- src/uu/base32/src/base_common.rs | 4 ++-- src/uu/base64/src/base64.rs | 4 ++-- src/uu/basenc/src/basenc.rs | 4 ++-- src/uu/chroot/src/error.rs | 8 ++++---- src/uu/cksum/src/cksum.rs | 2 +- src/uu/cp/src/copydir.rs | 8 ++++---- src/uu/cp/src/cp.rs | 10 ++++------ src/uu/cp/src/platform/linux.rs | 8 ++++---- src/uu/cp/src/platform/macos.rs | 8 ++++---- src/uu/cp/src/platform/mod.rs | 8 ++++---- src/uu/cp/src/platform/other.rs | 8 ++++---- src/uu/dd/src/blocks.rs | 8 ++++---- src/uu/dd/src/numbers.rs | 8 ++++---- src/uu/dd/src/progress.rs | 8 ++++---- src/uu/df/src/blocks.rs | 8 ++++---- src/uu/df/src/columns.rs | 8 ++++---- src/uu/df/src/df.rs | 4 ++-- src/uu/df/src/filesystem.rs | 8 ++++---- src/uu/df/src/table.rs | 8 ++++---- src/uu/dir/src/dir.rs | 8 ++++---- src/uu/du/src/du.rs | 8 ++++---- src/uu/expand/src/expand.rs | 1 - src/uu/expr/src/expr.rs | 8 ++++---- src/uu/expr/src/syntax_tree.rs | 8 ++++---- src/uu/expr/src/tokens.rs | 8 ++++---- src/uu/factor/build.rs | 8 ++++---- src/uu/factor/sieve.rs | 8 ++++---- src/uu/factor/src/cli.rs | 8 ++++---- src/uu/factor/src/factor.rs | 8 ++++---- src/uu/factor/src/miller_rabin.rs | 8 ++++---- src/uu/factor/src/numeric/gcd.rs | 8 ++++---- src/uu/factor/src/numeric/mod.rs | 8 ++++---- src/uu/factor/src/numeric/modular_inverse.rs | 8 ++++---- src/uu/factor/src/numeric/montgomery.rs | 8 ++++---- src/uu/factor/src/numeric/traits.rs | 8 ++++---- src/uu/factor/src/rho.rs | 8 ++++---- src/uu/factor/src/table.rs | 8 ++++---- src/uu/false/src/false.rs | 8 ++++---- src/uu/fmt/src/fmt.rs | 8 ++++---- src/uu/fmt/src/linebreak.rs | 8 ++++---- src/uu/fmt/src/parasplit.rs | 8 ++++---- src/uu/fold/src/fold.rs | 8 ++++---- src/uu/hashsum/src/hashsum.rs | 8 ++++---- src/uu/head/src/head.rs | 8 ++++---- src/uu/head/src/parse.rs | 8 ++++---- src/uu/hostid/src/hostid.rs | 8 ++++---- src/uu/hostname/src/hostname.rs | 8 ++++---- src/uu/install/src/install.rs | 8 ++++---- 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 | 4 ++-- src/uu/mkdir/src/mkdir.rs | 8 ++++---- src/uu/mkfifo/src/mkfifo.rs | 8 ++++---- src/uu/more/src/more.rs | 8 ++++---- src/uu/mv/src/error.rs | 4 ++-- src/uu/mv/src/mv.rs | 4 ++-- src/uu/nice/src/nice.rs | 8 ++++---- src/uu/nl/src/nl.rs | 9 ++++----- src/uu/nohup/src/nohup.rs | 8 ++++---- src/uu/nproc/src/nproc.rs | 8 ++++---- src/uu/numfmt/src/errors.rs | 8 ++++---- src/uu/numfmt/src/numfmt.rs | 8 ++++---- src/uu/od/src/od.rs | 8 ++++---- src/uu/paste/src/paste.rs | 8 ++++---- src/uu/pathchk/src/pathchk.rs | 9 ++++----- src/uu/pr/src/pr.rs | 4 ++-- src/uu/printenv/src/printenv.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/seq/src/error.rs | 8 ++++---- src/uu/seq/src/seq.rs | 8 ++++---- src/uu/shred/src/shred.rs | 8 ++++---- src/uu/shuf/src/shuf.rs | 8 ++++---- src/uu/sleep/src/sleep.rs | 8 ++++---- src/uu/sort/src/check.rs | 8 ++++---- src/uu/sort/src/chunks.rs | 8 ++++---- src/uu/sort/src/custom_str_cmp.rs | 8 ++++---- src/uu/sort/src/ext_sort.rs | 8 ++++---- src/uu/sort/src/numeric_str_cmp.rs | 8 ++++---- src/uu/sort/src/sort.rs | 8 ++++---- src/uu/split/src/filenames.rs | 8 ++++---- src/uu/split/src/number.rs | 8 ++++---- src/uu/split/src/split.rs | 8 ++++---- src/uu/stat/src/stat.rs | 4 ++-- src/uu/stdbuf/src/stdbuf.rs | 8 ++++---- src/uu/stty/src/flags.rs | 8 ++++---- src/uu/stty/src/stty.rs | 8 ++++---- src/uu/sum/src/sum.rs | 8 ++++---- src/uu/sync/src/sync.rs | 8 ++++---- src/uu/tac/src/error.rs | 8 ++++---- src/uu/tac/src/tac.rs | 8 ++++---- src/uu/tail/src/args.rs | 8 ++++---- src/uu/tail/src/chunks.rs | 8 ++++---- src/uu/tail/src/follow/files.rs | 8 ++++---- src/uu/tail/src/follow/mod.rs | 8 ++++---- src/uu/tail/src/follow/watch.rs | 8 ++++---- src/uu/tail/src/parse.rs | 8 ++++---- src/uu/tail/src/paths.rs | 8 ++++---- src/uu/tail/src/platform/mod.rs | 10 ++++------ src/uu/tail/src/platform/unix.rs | 10 ++++------ src/uu/tail/src/platform/windows.rs | 11 +++++------ src/uu/tail/src/tail.rs | 8 ++++---- src/uu/tail/src/text.rs | 8 ++++---- src/uu/tee/src/tee.rs | 8 ++++---- src/uu/timeout/src/status.rs | 8 ++++---- src/uu/timeout/src/timeout.rs | 8 ++++---- src/uu/touch/src/touch.rs | 4 ++-- src/uu/tr/src/convert.rs | 8 ++++---- src/uu/tr/src/operation.rs | 8 ++++---- src/uu/tr/src/tr.rs | 8 ++++---- src/uu/tr/src/unicode_table.rs | 8 ++++---- src/uu/true/src/true.rs | 8 ++++---- src/uu/truncate/src/truncate.rs | 8 ++++---- src/uu/tsort/src/tsort.rs | 8 ++++---- src/uu/tty/src/tty.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/vdir/src/vdir.rs | 8 ++++---- src/uu/wc/src/wc.rs | 8 ++++---- src/uu/whoami/src/platform/mod.rs | 10 ++++------ src/uu/whoami/src/platform/unix.rs | 10 ++++------ src/uu/whoami/src/platform/windows.rs | 10 ++++------ src/uu/whoami/src/whoami.rs | 8 ++++---- src/uu/yes/src/yes.rs | 8 ++++---- src/uucore/src/lib/features/fsext.rs | 4 ++-- src/uucore/src/lib/features/lines.rs | 8 ++++---- src/uucore/src/lib/features/process.rs | 4 ++-- src/uucore/src/lib/features/signals.rs | 4 ++-- src/uucore/src/lib/features/sum.rs | 4 ++-- src/uucore/src/lib/macros.rs | 5 +++++ src/uucore/src/lib/parser/parse_size.rs | 8 ++++---- tests/by-util/test_base32.rs | 4 ++-- tests/by-util/test_du.rs | 8 ++++---- tests/by-util/test_factor.rs | 4 ++-- tests/by-util/test_groups.rs | 8 ++++---- tests/by-util/test_head.rs | 8 ++++---- tests/by-util/test_id.rs | 8 ++++---- tests/by-util/test_od.rs | 9 +++++---- tests/by-util/test_pinky.rs | 8 ++++---- tests/by-util/test_sort.rs | 8 ++++---- tests/by-util/test_split.rs | 8 ++++---- tests/by-util/test_stat.rs | 8 ++++---- tests/by-util/test_tail.rs | 8 ++++---- tests/by-util/test_test.rs | 2 -- tests/by-util/test_truncate.rs | 8 ++++---- tests/by-util/test_who.rs | 8 ++++---- tests/by-util/test_whoami.rs | 8 ++++---- tests/common/macros.rs | 8 ++++---- tests/common/random.rs | 8 ++++---- tests/common/util.rs | 8 ++++---- 163 files changed, 611 insertions(+), 618 deletions(-) diff --git a/build.rs b/build.rs index d210e2a2e..bb4e2b536 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,8 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + // spell-checker:ignore (vars) krate use std::env; diff --git a/src/uu/base32/src/base32.rs b/src/uu/base32/src/base32.rs index 2ef63fbc0..09250421c 100644 --- a/src/uu/base32/src/base32.rs +++ b/src/uu/base32/src/base32.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::io::{stdin, Read}; diff --git a/src/uu/base32/src/base_common.rs b/src/uu/base32/src/base_common.rs index ba2ef9229..4a30705af 100644 --- a/src/uu/base32/src/base_common.rs +++ b/src/uu/base32/src/base_common.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::io::{stdout, Read, Write}; diff --git a/src/uu/base64/src/base64.rs b/src/uu/base64/src/base64.rs index 4e4a3c293..6544638bd 100644 --- a/src/uu/base64/src/base64.rs +++ b/src/uu/base64/src/base64.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use uu_base32::base_common; pub use uu_base32::uu_app; diff --git a/src/uu/basenc/src/basenc.rs b/src/uu/basenc/src/basenc.rs index 0ee8a816b..ff512b176 100644 --- a/src/uu/basenc/src/basenc.rs +++ b/src/uu/basenc/src/basenc.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //spell-checker:ignore (args) lsbf msbf diff --git a/src/uu/chroot/src/error.rs b/src/uu/chroot/src/error.rs index 43ef98595..526f1a75a 100644 --- a/src/uu/chroot/src/error.rs +++ b/src/uu/chroot/src/error.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore NEWROOT Userspec userspec //! Errors returned by chroot. use std::fmt::Display; diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index 83d48ec1a..6c9c79582 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -1,6 +1,6 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE +// For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore (ToDO) fname, algo diff --git a/src/uu/cp/src/copydir.rs b/src/uu/cp/src/copydir.rs index 818b0d222..cfb18212d 100644 --- a/src/uu/cp/src/copydir.rs +++ b/src/uu/cp/src/copydir.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore TODO canonicalizes direntry pathbuf symlinked //! Recursively copy the contents of a directory. //! diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index ce16357c6..4b326d9d5 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1,12 +1,10 @@ -#![allow(clippy::missing_safety_doc)] -#![allow(clippy::extra_unused_lifetimes)] - // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. - +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) copydir ficlone fiemap ftruncate linkgs lstat nlink nlinks pathbuf pwrite reflink strs xattrs symlinked deduplicated advcpmv nushell +#![allow(clippy::missing_safety_doc)] +#![allow(clippy::extra_unused_lifetimes)] use quick_error::quick_error; use std::borrow::Cow; diff --git a/src/uu/cp/src/platform/linux.rs b/src/uu/cp/src/platform/linux.rs index 18f2520a2..674e66ea5 100644 --- a/src/uu/cp/src/platform/linux.rs +++ b/src/uu/cp/src/platform/linux.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore ficlone reflink ftruncate pwrite fiemap use std::fs::{File, OpenOptions}; use std::io::Read; diff --git a/src/uu/cp/src/platform/macos.rs b/src/uu/cp/src/platform/macos.rs index b173aa959..8c62c78d9 100644 --- a/src/uu/cp/src/platform/macos.rs +++ b/src/uu/cp/src/platform/macos.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore reflink use std::ffi::CString; use std::fs::{self, File}; diff --git a/src/uu/cp/src/platform/mod.rs b/src/uu/cp/src/platform/mod.rs index 9dbcefa80..c79427068 100644 --- a/src/uu/cp/src/platform/mod.rs +++ b/src/uu/cp/src/platform/mod.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #[cfg(target_os = "macos")] mod macos; #[cfg(target_os = "macos")] diff --git a/src/uu/cp/src/platform/other.rs b/src/uu/cp/src/platform/other.rs index f5882f75e..7ca1a5ded 100644 --- a/src/uu/cp/src/platform/other.rs +++ b/src/uu/cp/src/platform/other.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore reflink use std::fs; use std::path::Path; diff --git a/src/uu/dd/src/blocks.rs b/src/uu/dd/src/blocks.rs index a8d2c1408..8e5557a2c 100644 --- a/src/uu/dd/src/blocks.rs +++ b/src/uu/dd/src/blocks.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore datastructures rstat rposition cflags ctable diff --git a/src/uu/dd/src/numbers.rs b/src/uu/dd/src/numbers.rs index 0cab572b4..2911f7e58 100644 --- a/src/uu/dd/src/numbers.rs +++ b/src/uu/dd/src/numbers.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /// Functions for formatting a number as a magnitude and a unit suffix. /// The first ten powers of 1024. diff --git a/src/uu/dd/src/progress.rs b/src/uu/dd/src/progress.rs index a9d29ff63..4fe04cb0e 100644 --- a/src/uu/dd/src/progress.rs +++ b/src/uu/dd/src/progress.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore btotal sigval //! Read and write progress tracking for dd. //! diff --git a/src/uu/df/src/blocks.rs b/src/uu/df/src/blocks.rs index f48d2ffd2..9bc16b782 100644 --- a/src/uu/df/src/blocks.rs +++ b/src/uu/df/src/blocks.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Types for representing and displaying block sizes. use crate::{OPT_BLOCKSIZE, OPT_PORTABILITY}; use clap::ArgMatches; diff --git a/src/uu/df/src/columns.rs b/src/uu/df/src/columns.rs index f9515d791..0659d7f7d 100644 --- a/src/uu/df/src/columns.rs +++ b/src/uu/df/src/columns.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore itotal iused iavail ipcent pcent squashfs use crate::{OPT_INODES, OPT_OUTPUT, OPT_PRINT_TYPE}; use clap::{parser::ValueSource, ArgMatches}; diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 9a3eeac65..78325f3d2 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore itotal iused iavail ipcent pcent tmpfs squashfs lofs mod blocks; mod columns; diff --git a/src/uu/df/src/filesystem.rs b/src/uu/df/src/filesystem.rs index d50822e7f..ef5107958 100644 --- a/src/uu/df/src/filesystem.rs +++ b/src/uu/df/src/filesystem.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Provides a summary representation of a filesystem. //! //! A [`Filesystem`] struct represents a device containing a diff --git a/src/uu/df/src/table.rs b/src/uu/df/src/table.rs index 06bfc3383..4c3d08f45 100644 --- a/src/uu/df/src/table.rs +++ b/src/uu/df/src/table.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore tmpfs Pcent Itotal Iused Iavail Ipcent //! The filesystem usage data table. //! diff --git a/src/uu/dir/src/dir.rs b/src/uu/dir/src/dir.rs index fb26b265f..e25529511 100644 --- a/src/uu/dir/src/dir.rs +++ b/src/uu/dir/src/dir.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::Command; use std::ffi::OsString; diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 493eb4848..5be2a8a2b 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use chrono::prelude::DateTime; use chrono::Local; diff --git a/src/uu/expand/src/expand.rs b/src/uu/expand/src/expand.rs index fb73ce4b5..9294d1a8f 100644 --- a/src/uu/expand/src/expand.rs +++ b/src/uu/expand/src/expand.rs @@ -1,6 +1,5 @@ // This file is part of the uutils coreutils package. // -// // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. diff --git a/src/uu/expr/src/expr.rs b/src/uu/expr/src/expr.rs index 458466558..ea559090c 100644 --- a/src/uu/expr/src/expr.rs +++ b/src/uu/expr/src/expr.rs @@ -1,7 +1,7 @@ -//* This file is part of the uutils coreutils package. -//* -//* For the full copyright and license information, please view the LICENSE -//* file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::{crate_version, Arg, ArgAction, Command}; use uucore::{ diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index 71a0d5408..0e0795bd4 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -1,7 +1,7 @@ -//* This file is part of the uutils coreutils package. -//* -//* For the full copyright and license information, please view the LICENSE -//* file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! //! Here we employ shunting-yard algorithm for building AST from tokens according to operators' precedence and associative-ness. diff --git a/src/uu/expr/src/tokens.rs b/src/uu/expr/src/tokens.rs index f211eefaa..b4e4c7da5 100644 --- a/src/uu/expr/src/tokens.rs +++ b/src/uu/expr/src/tokens.rs @@ -1,7 +1,7 @@ -//* This file is part of the uutils coreutils package. -//* -//* For the full copyright and license information, please view the LICENSE -//* file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! //! The following tokens are present in the expr grammar: diff --git a/src/uu/factor/build.rs b/src/uu/factor/build.rs index 2ec215f2e..8de0605a2 100644 --- a/src/uu/factor/build.rs +++ b/src/uu/factor/build.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Generate a table of the multiplicative inverses of p_i mod 2^64 //! for the first 1027 odd primes (all 13 bit and smaller primes). diff --git a/src/uu/factor/sieve.rs b/src/uu/factor/sieve.rs index 3d569c6bf..e2211ce05 100644 --- a/src/uu/factor/sieve.rs +++ b/src/uu/factor/sieve.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) filts, minidx, minkey paridx diff --git a/src/uu/factor/src/cli.rs b/src/uu/factor/src/cli.rs index d35e2ede6..bfc4ede15 100644 --- a/src/uu/factor/src/cli.rs +++ b/src/uu/factor/src/cli.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::error::Error; use std::fmt::Write as FmtWrite; diff --git a/src/uu/factor/src/factor.rs b/src/uu/factor/src/factor.rs index 7ce5eb822..1af6bc550 100644 --- a/src/uu/factor/src/factor.rs +++ b/src/uu/factor/src/factor.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use smallvec::SmallVec; use std::cell::RefCell; diff --git a/src/uu/factor/src/miller_rabin.rs b/src/uu/factor/src/miller_rabin.rs index 5c88278d2..1ccc55600 100644 --- a/src/uu/factor/src/miller_rabin.rs +++ b/src/uu/factor/src/miller_rabin.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (URL) appspot diff --git a/src/uu/factor/src/numeric/gcd.rs b/src/uu/factor/src/numeric/gcd.rs index 10efc339a..43c6ce9b7 100644 --- a/src/uu/factor/src/numeric/gcd.rs +++ b/src/uu/factor/src/numeric/gcd.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) kgcdab gcdac gcdbc diff --git a/src/uu/factor/src/numeric/mod.rs b/src/uu/factor/src/numeric/mod.rs index 4a087274b..d4c0b5dc7 100644 --- a/src/uu/factor/src/numeric/mod.rs +++ b/src/uu/factor/src/numeric/mod.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. mod gcd; pub use gcd::gcd; diff --git a/src/uu/factor/src/numeric/modular_inverse.rs b/src/uu/factor/src/numeric/modular_inverse.rs index 52e87e412..bacf57d9c 100644 --- a/src/uu/factor/src/numeric/modular_inverse.rs +++ b/src/uu/factor/src/numeric/modular_inverse.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use super::traits::Int; diff --git a/src/uu/factor/src/numeric/montgomery.rs b/src/uu/factor/src/numeric/montgomery.rs index 3d225dd1e..10c6dd2d9 100644 --- a/src/uu/factor/src/numeric/montgomery.rs +++ b/src/uu/factor/src/numeric/montgomery.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use super::*; diff --git a/src/uu/factor/src/numeric/traits.rs b/src/uu/factor/src/numeric/traits.rs index a3b8912f9..c3528a4ad 100644 --- a/src/uu/factor/src/numeric/traits.rs +++ b/src/uu/factor/src/numeric/traits.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. pub(crate) use num_traits::{ identities::{One, Zero}, diff --git a/src/uu/factor/src/rho.rs b/src/uu/factor/src/rho.rs index 8de8ade83..2af0f6855 100644 --- a/src/uu/factor/src/rho.rs +++ b/src/uu/factor/src/rho.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use rand::distributions::{Distribution, Uniform}; use rand::rngs::SmallRng; diff --git a/src/uu/factor/src/table.rs b/src/uu/factor/src/table.rs index 063ec0620..e9b525a3a 100644 --- a/src/uu/factor/src/table.rs +++ b/src/uu/factor/src/table.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker: ignore (ToDO) INVS diff --git a/src/uu/false/src/false.rs b/src/uu/false/src/false.rs index 293bb1eb5..3ae25e569 100644 --- a/src/uu/false/src/false.rs +++ b/src/uu/false/src/false.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::{Arg, ArgAction, Command}; use std::{ffi::OsString, io::Write}; use uucore::error::{set_exit_code, UResult}; diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index 0ff20e987..c5eac7073 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) PSKIP linebreak ostream parasplit tabwidth xanti xprefix diff --git a/src/uu/fmt/src/linebreak.rs b/src/uu/fmt/src/linebreak.rs index b3e79152f..13f34ca96 100644 --- a/src/uu/fmt/src/linebreak.rs +++ b/src/uu/fmt/src/linebreak.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) INFTY MULT accum breakwords linebreak linebreaking linebreaks linelen maxlength minlength nchars ostream overlen parasplit plass posn powf punct signum slen sstart tabwidth tlen underlen winfo wlen wordlen diff --git a/src/uu/fmt/src/parasplit.rs b/src/uu/fmt/src/parasplit.rs index fbad5d16e..68c8f78fa 100644 --- a/src/uu/fmt/src/parasplit.rs +++ b/src/uu/fmt/src/parasplit.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) INFTY MULT PSKIP accum aftertab beforetab breakwords fmt's formatline linebreak linebreaking linebreaks linelen maxlength minlength nchars noformat noformatline ostream overlen parasplit pfxind plass pmatch poffset posn powf prefixindent punct signum slen sstart tabwidth tlen underlen winfo wlen wordlen wordsplits xanti xprefix diff --git a/src/uu/fold/src/fold.rs b/src/uu/fold/src/fold.rs index b01101942..95b6d9a82 100644 --- a/src/uu/fold/src/fold.rs +++ b/src/uu/fold/src/fold.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDOs) ncount routput diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index 0e297c8cc..1931c7d79 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) algo, algoname, regexes, nread, nonames diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index 931f8a652..c60bbfe99 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) zlines BUFWRITER seekable diff --git a/src/uu/head/src/parse.rs b/src/uu/head/src/parse.rs index 56c359a0c..90e1f2ce0 100644 --- a/src/uu/head/src/parse.rs +++ b/src/uu/head/src/parse.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::ffi::OsString; use uucore::parse_size::{parse_size, ParseSizeError}; diff --git a/src/uu/hostid/src/hostid.rs b/src/uu/hostid/src/hostid.rs index f30def1b9..a5c18d075 100644 --- a/src/uu/hostid/src/hostid.rs +++ b/src/uu/hostid/src/hostid.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) gethostid diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs index 82df4e99f..6a318cb8c 100644 --- a/src/uu/hostname/src/hostname.rs +++ b/src/uu/hostname/src/hostname.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) MAKEWORD addrs hashset diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index a2d49fe8b..02cf8345d 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) rwxr sourcepath targetpath Isnt uioerror diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index e769ceb58..71720f2cc 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) autoformat FILENUM whitespaces pairable unpairable nocheck diff --git a/src/uu/kill/src/kill.rs b/src/uu/kill/src/kill.rs index 1bc89f9a6..b0e18a798 100644 --- a/src/uu/kill/src/kill.rs +++ b/src/uu/kill/src/kill.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) signalname pids killpg diff --git a/src/uu/link/src/link.rs b/src/uu/link/src/link.rs index 6a7f78fca..806e89828 100644 --- a/src/uu/link/src/link.rs +++ b/src/uu/link/src/link.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::builder::ValueParser; use clap::{crate_version, Arg, Command}; use std::ffi::OsString; diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index 42426be3c..18d515a88 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) srcpath targetpath EEXIST diff --git a/src/uu/logname/src/logname.rs b/src/uu/logname/src/logname.rs index 55008bb73..52505d98d 100644 --- a/src/uu/logname/src/logname.rs +++ b/src/uu/logname/src/logname.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /* last synced with: logname (GNU coreutils) 8.22 */ diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 792768153..1f5165e83 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) cpio svgz webm somegroup nlink rmvb xspf tabsize dired diff --git a/src/uu/mkdir/src/mkdir.rs b/src/uu/mkdir/src/mkdir.rs index cdc03a30c..2044855e4 100644 --- a/src/uu/mkdir/src/mkdir.rs +++ b/src/uu/mkdir/src/mkdir.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) ugoa cmode diff --git a/src/uu/mkfifo/src/mkfifo.rs b/src/uu/mkfifo/src/mkfifo.rs index 021dbff5f..dc1f876fc 100644 --- a/src/uu/mkfifo/src/mkfifo.rs +++ b/src/uu/mkfifo/src/mkfifo.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::{crate_version, Arg, ArgAction, Command}; use libc::mkfifo; diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index 6cbfa2b1d..75cf79c07 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (methods) isnt diff --git a/src/uu/mv/src/error.rs b/src/uu/mv/src/error.rs index 7810c3a95..a6605e232 100644 --- a/src/uu/mv/src/error.rs +++ b/src/uu/mv/src/error.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::error::Error; use std::fmt::{Display, Formatter, Result}; diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 6f6415789..9f7a96618 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) sourcepath targetpath diff --git a/src/uu/nice/src/nice.rs b/src/uu/nice/src/nice.rs index 35871d694..3eaeba956 100644 --- a/src/uu/nice/src/nice.rs +++ b/src/uu/nice/src/nice.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) getpriority execvp setpriority nstr PRIO cstrs ENOENT diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 519102a31..61a0a9f35 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -1,8 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. -// * +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::{crate_version, Arg, ArgAction, Command}; use std::fs::File; diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index 3f2453471..fdbed9395 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) execvp SIGHUP cproc vprocmgr cstrs homeout diff --git a/src/uu/nproc/src/nproc.rs b/src/uu/nproc/src/nproc.rs index 16262d514..d0bd3083d 100644 --- a/src/uu/nproc/src/nproc.rs +++ b/src/uu/nproc/src/nproc.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) NPROCESSORS nprocs numstr threadstr sysconf diff --git a/src/uu/numfmt/src/errors.rs b/src/uu/numfmt/src/errors.rs index 22c6962d6..77dd6f0aa 100644 --- a/src/uu/numfmt/src/errors.rs +++ b/src/uu/numfmt/src/errors.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::{ error::Error, diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index 10ae5387c..4afe56555 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::errors::*; use crate::format::format_and_print; diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index dd083ff6d..769dae98e 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (clap) dont // spell-checker:ignore (ToDO) formatteriteminfo inputdecoder inputoffset mockstream nrofbytes partialreader odfunc multifile exitcode diff --git a/src/uu/paste/src/paste.rs b/src/uu/paste/src/paste.rs index 8541e0d50..89bba034c 100644 --- a/src/uu/paste/src/paste.rs +++ b/src/uu/paste/src/paste.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) delim diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index f59fd6a90..3510a3327 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -1,10 +1,9 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #![allow(unused_must_use)] // because we of writeln! -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. - // spell-checker:ignore (ToDO) lstat use clap::{crate_version, Arg, ArgAction, Command}; use std::fs; diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 37674bad7..ef178a888 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // // spell-checker:ignore (ToDO) adFfmprt, kmerge diff --git a/src/uu/printenv/src/printenv.rs b/src/uu/printenv/src/printenv.rs index 166670244..cab24336f 100644 --- a/src/uu/printenv/src/printenv.rs +++ b/src/uu/printenv/src/printenv.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /* last synced with: printenv (GNU coreutils) 8.13 */ diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index 38cc1473d..4385ab484 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDOs) corasick memchr Roff trunc oset iset CHARCLASS diff --git a/src/uu/pwd/src/pwd.rs b/src/uu/pwd/src/pwd.rs index 0b532672a..fde2357e2 100644 --- a/src/uu/pwd/src/pwd.rs +++ b/src/uu/pwd/src/pwd.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::ArgAction; use clap::{crate_version, Arg, Command}; diff --git a/src/uu/readlink/src/readlink.rs b/src/uu/readlink/src/readlink.rs index 3775f7487..2febe51af 100644 --- a/src/uu/readlink/src/readlink.rs +++ b/src/uu/readlink/src/readlink.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) errno diff --git a/src/uu/realpath/src/realpath.rs b/src/uu/realpath/src/realpath.rs index ddbb254d5..64806fbab 100644 --- a/src/uu/realpath/src/realpath.rs +++ b/src/uu/realpath/src/realpath.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) retcode diff --git a/src/uu/relpath/src/relpath.rs b/src/uu/relpath/src/relpath.rs index e667a60cc..46dd0d663 100644 --- a/src/uu/relpath/src/relpath.rs +++ b/src/uu/relpath/src/relpath.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) subpath absto absfrom absbase diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index a87eca2b0..d9421d0ae 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (path) eacces diff --git a/src/uu/rmdir/src/rmdir.rs b/src/uu/rmdir/src/rmdir.rs index 73bdce231..ef152f01a 100644 --- a/src/uu/rmdir/src/rmdir.rs +++ b/src/uu/rmdir/src/rmdir.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) ENOTDIR diff --git a/src/uu/seq/src/error.rs b/src/uu/seq/src/error.rs index fc8452e13..e81c30fe6 100644 --- a/src/uu/seq/src/error.rs +++ b/src/uu/seq/src/error.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore numberparse //! Errors returned by seq. use std::error::Error; diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index dec66a7b1..4f04b377e 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) istr chiter argptr ilen extendedbigdecimal extendedbigint numberparse use std::io::{stdout, ErrorKind, Write}; use std::process::exit; diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 6af81022a..9b1f7fc98 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) wipesync prefill diff --git a/src/uu/shuf/src/shuf.rs b/src/uu/shuf/src/shuf.rs index 987383f4a..1b21b9532 100644 --- a/src/uu/shuf/src/shuf.rs +++ b/src/uu/shuf/src/shuf.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) cmdline evec seps rvec fdata diff --git a/src/uu/sleep/src/sleep.rs b/src/uu/sleep/src/sleep.rs index b8dc3c612..b1d6bd899 100644 --- a/src/uu/sleep/src/sleep.rs +++ b/src/uu/sleep/src/sleep.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::thread; use std::time::Duration; diff --git a/src/uu/sort/src/check.rs b/src/uu/sort/src/check.rs index df080acae..763b6deb7 100644 --- a/src/uu/sort/src/check.rs +++ b/src/uu/sort/src/check.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Check if a file is ordered diff --git a/src/uu/sort/src/chunks.rs b/src/uu/sort/src/chunks.rs index e1ba68ade..525a9f66b 100644 --- a/src/uu/sort/src/chunks.rs +++ b/src/uu/sort/src/chunks.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Utilities for reading files as chunks. diff --git a/src/uu/sort/src/custom_str_cmp.rs b/src/uu/sort/src/custom_str_cmp.rs index 7b626548f..fb128d9af 100644 --- a/src/uu/sort/src/custom_str_cmp.rs +++ b/src/uu/sort/src/custom_str_cmp.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Custom string comparisons. //! diff --git a/src/uu/sort/src/ext_sort.rs b/src/uu/sort/src/ext_sort.rs index ae9c7403e..08de4e33e 100644 --- a/src/uu/sort/src/ext_sort.rs +++ b/src/uu/sort/src/ext_sort.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Sort big files by using auxiliary files for storing intermediate chunks. //! diff --git a/src/uu/sort/src/numeric_str_cmp.rs b/src/uu/sort/src/numeric_str_cmp.rs index 31c85d6db..661f536a3 100644 --- a/src/uu/sort/src/numeric_str_cmp.rs +++ b/src/uu/sort/src/numeric_str_cmp.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Fast comparison for strings representing a base 10 number without precision loss. //! diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index c4091d437..4e6e84187 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // Although these links don't always seem to describe reality, check out the POSIX and GNU specs: // https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html diff --git a/src/uu/split/src/filenames.rs b/src/uu/split/src/filenames.rs index 6bec4105f..08f08e293 100644 --- a/src/uu/split/src/filenames.rs +++ b/src/uu/split/src/filenames.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore zaaa zaab //! Compute filenames from a given index. //! diff --git a/src/uu/split/src/number.rs b/src/uu/split/src/number.rs index 567526538..39d64f927 100644 --- a/src/uu/split/src/number.rs +++ b/src/uu/split/src/number.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore zaaa zaab //! A number in arbitrary radix expressed in a positional notation. //! diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 345d489ca..71aacfed0 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore nbbbb ncccc diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index b3c9dc513..19fc5370a 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::builder::ValueParser; use uucore::display::Quotable; diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index b5c79b365..6e522aa3d 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) tempdir dyld dylib dragonflybsd optgrps libstdbuf diff --git a/src/uu/stty/src/flags.rs b/src/uu/stty/src/flags.rs index 536c08d80..2c8e154e8 100644 --- a/src/uu/stty/src/flags.rs +++ b/src/uu/stty/src/flags.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore parenb parodd cmspar hupcl cstopb cread clocal crtscts CSIZE // spell-checker:ignore ignbrk brkint ignpar parmrk inpck istrip inlcr igncr icrnl ixoff ixon iuclc ixany imaxbel iutf diff --git a/src/uu/stty/src/stty.rs b/src/uu/stty/src/stty.rs index c933e48ae..d55870730 100644 --- a/src/uu/stty/src/stty.rs +++ b/src/uu/stty/src/stty.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore clocal erange tcgetattr tcsetattr tcsanow tiocgwinsz tiocswinsz cfgetospeed cfsetospeed ushort vmin vtime diff --git a/src/uu/sum/src/sum.rs b/src/uu/sum/src/sum.rs index 91c6cdb6c..4616274d0 100644 --- a/src/uu/sum/src/sum.rs +++ b/src/uu/sum/src/sum.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) sysv diff --git a/src/uu/sync/src/sync.rs b/src/uu/sync/src/sync.rs index 3ad53314c..c0b8f3d00 100644 --- a/src/uu/sync/src/sync.rs +++ b/src/uu/sync/src/sync.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /* Last synced with: sync (GNU coreutils) 8.13 */ diff --git a/src/uu/tac/src/error.rs b/src/uu/tac/src/error.rs index 43b03b970..7a737ad9b 100644 --- a/src/uu/tac/src/error.rs +++ b/src/uu/tac/src/error.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Errors returned by tac during processing of a file. use std::error::Error; use std::fmt::Display; diff --git a/src/uu/tac/src/tac.rs b/src/uu/tac/src/tac.rs index 68cc8b333..b8cb61029 100644 --- a/src/uu/tac/src/tac.rs +++ b/src/uu/tac/src/tac.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) sbytes slen dlen memmem memmap Mmap mmap SIGBUS mod error; diff --git a/src/uu/tail/src/args.rs b/src/uu/tail/src/args.rs index 3b4984819..795652f26 100644 --- a/src/uu/tail/src/args.rs +++ b/src/uu/tail/src/args.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) kqueue Signum fundu diff --git a/src/uu/tail/src/chunks.rs b/src/uu/tail/src/chunks.rs index 7a1e5bc34..6582bd251 100644 --- a/src/uu/tail/src/chunks.rs +++ b/src/uu/tail/src/chunks.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Iterating over a file by chunks, either starting at the end of the file with [`ReverseChunks`] //! or at the end of piped stdin with [`LinesChunk`] or [`BytesChunk`]. diff --git a/src/uu/tail/src/follow/files.rs b/src/uu/tail/src/follow/files.rs index 8686e73f4..e4f980267 100644 --- a/src/uu/tail/src/follow/files.rs +++ b/src/uu/tail/src/follow/files.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore tailable seekable stdlib (stdlib) diff --git a/src/uu/tail/src/follow/mod.rs b/src/uu/tail/src/follow/mod.rs index e31eb54d1..52eef318f 100644 --- a/src/uu/tail/src/follow/mod.rs +++ b/src/uu/tail/src/follow/mod.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. mod files; mod watch; diff --git a/src/uu/tail/src/follow/watch.rs b/src/uu/tail/src/follow/watch.rs index 9569e6e21..3ecb47f67 100644 --- a/src/uu/tail/src/follow/watch.rs +++ b/src/uu/tail/src/follow/watch.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) tailable untailable stdlib kqueue Uncategorized unwatch diff --git a/src/uu/tail/src/parse.rs b/src/uu/tail/src/parse.rs index 96cf1e918..3d6b2697e 100644 --- a/src/uu/tail/src/parse.rs +++ b/src/uu/tail/src/parse.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::ffi::OsString; diff --git a/src/uu/tail/src/paths.rs b/src/uu/tail/src/paths.rs index 5ed654037..117cab8b0 100644 --- a/src/uu/tail/src/paths.rs +++ b/src/uu/tail/src/paths.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore tailable seekable stdlib (stdlib) diff --git a/src/uu/tail/src/platform/mod.rs b/src/uu/tail/src/platform/mod.rs index fb953ca10..cd2953ffd 100644 --- a/src/uu/tail/src/platform/mod.rs +++ b/src/uu/tail/src/platform/mod.rs @@ -1,9 +1,7 @@ -/* - * This file is part of the uutils coreutils package. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #[cfg(unix)] pub use self::unix::{ diff --git a/src/uu/tail/src/platform/unix.rs b/src/uu/tail/src/platform/unix.rs index 26d0c3d8e..a04582a2c 100644 --- a/src/uu/tail/src/platform/unix.rs +++ b/src/uu/tail/src/platform/unix.rs @@ -1,9 +1,7 @@ -/* - * This file is part of the uutils coreutils package. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) stdlib, ISCHR, GETFD // spell-checker:ignore (options) EPERM, ENOSYS diff --git a/src/uu/tail/src/platform/windows.rs b/src/uu/tail/src/platform/windows.rs index 263d35417..592516162 100644 --- a/src/uu/tail/src/platform/windows.rs +++ b/src/uu/tail/src/platform/windows.rs @@ -1,9 +1,8 @@ -/* - * This file is part of the uutils coreutils package. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + use windows_sys::Win32::Foundation::{CloseHandle, BOOL, HANDLE, WAIT_FAILED, WAIT_OBJECT_0}; use windows_sys::Win32::System::Threading::{ OpenProcess, WaitForSingleObject, PROCESS_SYNCHRONIZE, diff --git a/src/uu/tail/src/tail.rs b/src/uu/tail/src/tail.rs index daf683936..0488e0808 100644 --- a/src/uu/tail/src/tail.rs +++ b/src/uu/tail/src/tail.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) seekable seek'd tail'ing ringbuffer ringbuf unwatch Uncategorized filehandle Signum // spell-checker:ignore (libs) kqueue diff --git a/src/uu/tail/src/text.rs b/src/uu/tail/src/text.rs index e7686d301..e7aa6c253 100644 --- a/src/uu/tail/src/text.rs +++ b/src/uu/tail/src/text.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) kqueue diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index 6382eb4ec..ca6e8a7c6 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::{builder::PossibleValue, crate_version, Arg, ArgAction, Command}; use std::fs::OpenOptions; diff --git a/src/uu/timeout/src/status.rs b/src/uu/timeout/src/status.rs index 9a8558954..10103ab9b 100644 --- a/src/uu/timeout/src/status.rs +++ b/src/uu/timeout/src/status.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Exit status codes produced by `timeout`. use std::convert::From; use uucore::error::UError; diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index e492ef591..5e73fe2ab 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) tstr sigstr cmdname setpgid sigchld getpid mod status; diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index 135d119bd..e9970cb24 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) filetime datetime lpszfilepath mktime DATETIME subsecond datelike timelike // spell-checker:ignore (FORMATS) MMDDhhmm YYYYMMDDHHMM YYMMDDHHMM YYYYMMDDHHMMS diff --git a/src/uu/tr/src/convert.rs b/src/uu/tr/src/convert.rs index 00656ca49..28a80e9f5 100644 --- a/src/uu/tr/src/convert.rs +++ b/src/uu/tr/src/convert.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (strings) anychar combinator diff --git a/src/uu/tr/src/operation.rs b/src/uu/tr/src/operation.rs index f27ccc0b9..b7d74427a 100644 --- a/src/uu/tr/src/operation.rs +++ b/src/uu/tr/src/operation.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (strings) anychar combinator Alnum Punct Xdigit alnum punct xdigit cntrl diff --git a/src/uu/tr/src/tr.rs b/src/uu/tr/src/tr.rs index 9abbca631..9c6e7a7da 100644 --- a/src/uu/tr/src/tr.rs +++ b/src/uu/tr/src/tr.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) allocs bset dflag cflag sflag tflag diff --git a/src/uu/tr/src/unicode_table.rs b/src/uu/tr/src/unicode_table.rs index 43d9fd6f4..a00a30b8b 100644 --- a/src/uu/tr/src/unicode_table.rs +++ b/src/uu/tr/src/unicode_table.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. pub static BEL: char = '\u{0007}'; pub static BS: char = '\u{0008}'; diff --git a/src/uu/true/src/true.rs b/src/uu/true/src/true.rs index 3b7fe817a..637758625 100644 --- a/src/uu/true/src/true.rs +++ b/src/uu/true/src/true.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::{Arg, ArgAction, Command}; use std::{ffi::OsString, io::Write}; use uucore::error::{set_exit_code, UResult}; diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index cd3875b78..3b1e9bd09 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) RFILE refsize rfilename fsize tsize use clap::{crate_version, Arg, ArgAction, Command}; diff --git a/src/uu/tsort/src/tsort.rs b/src/uu/tsort/src/tsort.rs index d0a178df2..f094963dc 100644 --- a/src/uu/tsort/src/tsort.rs +++ b/src/uu/tsort/src/tsort.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::{crate_version, Arg, Command}; use std::collections::{BTreeMap, BTreeSet}; use std::fs::File; diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index 4f351b932..96d851d37 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // * // * Synced with http://lingrok.org/xref/coreutils/src/tty.c diff --git a/src/uu/unexpand/src/unexpand.rs b/src/uu/unexpand/src/unexpand.rs index 74e25d3f8..11ad43060 100644 --- a/src/uu/unexpand/src/unexpand.rs +++ b/src/uu/unexpand/src/unexpand.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) nums aflag uflag scol prevtab amode ctype cwidth nbytes lastcol pctype Preprocess diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index 330aa23e9..3aac7b834 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::{builder::ValueParser, crate_version, Arg, ArgAction, ArgMatches, Command}; use std::ffi::{OsStr, OsString}; diff --git a/src/uu/unlink/src/unlink.rs b/src/uu/unlink/src/unlink.rs index 6091cdcef..85e1ab4f5 100644 --- a/src/uu/unlink/src/unlink.rs +++ b/src/uu/unlink/src/unlink.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /* last synced with: unlink (GNU coreutils) 8.21 */ diff --git a/src/uu/uptime/src/uptime.rs b/src/uu/uptime/src/uptime.rs index f615d313d..778fbc920 100644 --- a/src/uu/uptime/src/uptime.rs +++ b/src/uu/uptime/src/uptime.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) getloadavg upsecs updays nusers loadavg boottime uphours upmins diff --git a/src/uu/users/src/users.rs b/src/uu/users/src/users.rs index f1f38c873..199882b7e 100644 --- a/src/uu/users/src/users.rs +++ b/src/uu/users/src/users.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (paths) wtmp diff --git a/src/uu/vdir/src/vdir.rs b/src/uu/vdir/src/vdir.rs index 8caa47150..b9d80c401 100644 --- a/src/uu/vdir/src/vdir.rs +++ b/src/uu/vdir/src/vdir.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE file -// * that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use clap::Command; use std::ffi::OsString; diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index 48b544783..6d5894db0 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // cSpell:ignore ilog wc wc's diff --git a/src/uu/whoami/src/platform/mod.rs b/src/uu/whoami/src/platform/mod.rs index 57edb1dc5..bc6b2888c 100644 --- a/src/uu/whoami/src/platform/mod.rs +++ b/src/uu/whoami/src/platform/mod.rs @@ -1,9 +1,7 @@ -/* - * This file is part of the uutils coreutils package. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) getusername diff --git a/src/uu/whoami/src/platform/unix.rs b/src/uu/whoami/src/platform/unix.rs index 8288c3978..31ab16fba 100644 --- a/src/uu/whoami/src/platform/unix.rs +++ b/src/uu/whoami/src/platform/unix.rs @@ -1,9 +1,7 @@ -/* - * This file is part of the uutils coreutils package. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::ffi::OsString; use std::io; diff --git a/src/uu/whoami/src/platform/windows.rs b/src/uu/whoami/src/platform/windows.rs index 44be482c7..aad2eed3d 100644 --- a/src/uu/whoami/src/platform/windows.rs +++ b/src/uu/whoami/src/platform/windows.rs @@ -1,9 +1,7 @@ -/* - * This file is part of the uutils coreutils package. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use std::ffi::OsString; use std::io; diff --git a/src/uu/whoami/src/whoami.rs b/src/uu/whoami/src/whoami.rs index 00802633e..cb8bcd9c7 100644 --- a/src/uu/whoami/src/whoami.rs +++ b/src/uu/whoami/src/whoami.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /* last synced with: whoami (GNU coreutils) 8.21 */ diff --git a/src/uu/yes/src/yes.rs b/src/uu/yes/src/yes.rs index e4cf0180e..e6868d9d8 100644 --- a/src/uu/yes/src/yes.rs +++ b/src/uu/yes/src/yes.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /* last synced with: yes (GNU coreutils) 8.13 */ diff --git a/src/uucore/src/lib/features/fsext.rs b/src/uucore/src/lib/features/fsext.rs index f526e7fde..52c079e2e 100644 --- a/src/uucore/src/lib/features/fsext.rs +++ b/src/uucore/src/lib/features/fsext.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //! Set of functions to manage file systems diff --git a/src/uucore/src/lib/features/lines.rs b/src/uucore/src/lib/features/lines.rs index a7f4df76d..3e3c82b3a 100644 --- a/src/uucore/src/lib/features/lines.rs +++ b/src/uucore/src/lib/features/lines.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) //! Iterate over lines, including the line ending character(s). //! diff --git a/src/uucore/src/lib/features/process.rs b/src/uucore/src/lib/features/process.rs index 8e7e46479..c7dff1f05 100644 --- a/src/uucore/src/lib/features/process.rs +++ b/src/uucore/src/lib/features/process.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars) cvar exitstatus // spell-checker:ignore (sys/unix) WIFSIGNALED diff --git a/src/uucore/src/lib/features/signals.rs b/src/uucore/src/lib/features/signals.rs index 423eb19c9..61482024d 100644 --- a/src/uucore/src/lib/features/signals.rs +++ b/src/uucore/src/lib/features/signals.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (vars/api) fcntl setrlimit setitimer // spell-checker:ignore (vars/signals) ABRT ALRM CHLD SEGV SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGEMT SIGFPE SIGHUP SIGILL SIGINFO SIGINT SIGIO SIGIOT SIGKILL SIGPIPE SIGPROF SIGPWR SIGQUIT SIGSEGV SIGSTOP SIGSYS SIGTERM SIGTRAP SIGTSTP SIGTHR SIGTTIN SIGTTOU SIGURG SIGUSR SIGVTALRM SIGWINCH SIGXCPU SIGXFSZ STKFLT PWR THR TSTP TTIN TTOU VTALRM XCPU XFSZ diff --git a/src/uucore/src/lib/features/sum.rs b/src/uucore/src/lib/features/sum.rs index d4945421e..2b69008de 100644 --- a/src/uucore/src/lib/features/sum.rs +++ b/src/uucore/src/lib/features/sum.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore memmem algo diff --git a/src/uucore/src/lib/macros.rs b/src/uucore/src/lib/macros.rs index d1893dd9a..ad86d5308 100644 --- a/src/uucore/src/lib/macros.rs +++ b/src/uucore/src/lib/macros.rs @@ -1,3 +1,8 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + // TODO fix broken links #![allow(rustdoc::broken_intra_doc_links)] //! Macros for the uucore utilities. diff --git a/src/uucore/src/lib/parser/parse_size.rs b/src/uucore/src/lib/parser/parse_size.rs index 2ea84e389..a93e0fe66 100644 --- a/src/uucore/src/lib/parser/parse_size.rs +++ b/src/uucore/src/lib/parser/parse_size.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) hdsf ghead gtail ACDBK hexdigit diff --git a/tests/by-util/test_base32.rs b/tests/by-util/test_base32.rs index b8e72cb04..8bb5bda54 100644 --- a/tests/by-util/test_base32.rs +++ b/tests/by-util/test_base32.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // use crate::common::util::TestScenario; diff --git a/tests/by-util/test_du.rs b/tests/by-util/test_du.rs index d365bd87e..9a508da25 100644 --- a/tests/by-util/test_du.rs +++ b/tests/by-util/test_du.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (paths) sublink subwords azerty azeaze xcwww azeaz amaz azea qzerty tazerty tsublink #[cfg(not(windows))] diff --git a/tests/by-util/test_factor.rs b/tests/by-util/test_factor.rs index a14a673a8..2a11363b7 100644 --- a/tests/by-util/test_factor.rs +++ b/tests/by-util/test_factor.rs @@ -1,7 +1,7 @@ // This file is part of the uutils coreutils package. // -// For the full copyright and license information, please view the LICENSE file -// that was distributed with this source code. +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #![allow(clippy::unreadable_literal)] // spell-checker:ignore (methods) hexdigest diff --git a/tests/by-util/test_groups.rs b/tests/by-util/test_groups.rs index 4f6bb7f1b..47cb89249 100644 --- a/tests/by-util/test_groups.rs +++ b/tests/by-util/test_groups.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //spell-checker: ignore coreutil diff --git a/tests/by-util/test_head.rs b/tests/by-util/test_head.rs index 0e1eafc86..65aeca437 100644 --- a/tests/by-util/test_head.rs +++ b/tests/by-util/test_head.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) bogusfile emptyfile abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstu diff --git a/tests/by-util/test_id.rs b/tests/by-util/test_id.rs index 4174bdde6..5c2a67199 100644 --- a/tests/by-util/test_id.rs +++ b/tests/by-util/test_id.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) coreutil diff --git a/tests/by-util/test_od.rs b/tests/by-util/test_od.rs index 54ac06384..78c4e1b04 100644 --- a/tests/by-util/test_od.rs +++ b/tests/by-util/test_od.rs @@ -1,8 +1,9 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + // spell-checker:ignore abcdefghijklmnopqrstuvwxyz -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. use crate::common::util::TestScenario; use std::env; diff --git a/tests/by-util/test_pinky.rs b/tests/by-util/test_pinky.rs index f266175f5..57413c4c9 100644 --- a/tests/by-util/test_pinky.rs +++ b/tests/by-util/test_pinky.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::{expected_result, TestScenario}; use pinky::Capitalize; diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index 0c8af8969..690623c1c 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) ints diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index de1bb9cdf..c5f32482e 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes threebytes asciilowercase fghij klmno pqrst uvwxyz fivelines twohundredfortyonebytes onehundredlines nbbbb use crate::common::util::{AtPath, TestScenario}; diff --git a/tests/by-util/test_stat.rs b/tests/by-util/test_stat.rs index d932b35d6..e918d54e9 100644 --- a/tests/by-util/test_stat.rs +++ b/tests/by-util/test_stat.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use crate::common::util::{expected_result, TestScenario}; diff --git a/tests/by-util/test_tail.rs b/tests/by-util/test_tail.rs index 75abb8eb6..bc89f56a0 100644 --- a/tests/by-util/test_tail.rs +++ b/tests/by-util/test_tail.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (ToDO) abcdefghijklmnopqrstuvwxyz efghijklmnopqrstuvwxyz vwxyz emptyfile file siette ocho nueve diez MULT // spell-checker:ignore (libs) kqueue diff --git a/tests/by-util/test_test.rs b/tests/by-util/test_test.rs index 91af9033a..2f36a805c 100644 --- a/tests/by-util/test_test.rs +++ b/tests/by-util/test_test.rs @@ -1,9 +1,7 @@ -// // This file is part of the uutils coreutils package. // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// // spell-checker:ignore (words) egid euid pseudofloat diff --git a/tests/by-util/test_truncate.rs b/tests/by-util/test_truncate.rs index 7a0bac6e9..972b4fc5b 100644 --- a/tests/by-util/test_truncate.rs +++ b/tests/by-util/test_truncate.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (words) RFILE diff --git a/tests/by-util/test_who.rs b/tests/by-util/test_who.rs index 31b46c3bf..3bacc38c1 100644 --- a/tests/by-util/test_who.rs +++ b/tests/by-util/test_who.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. // spell-checker:ignore (flags) runlevel mesg diff --git a/tests/by-util/test_whoami.rs b/tests/by-util/test_whoami.rs index 9e6c35be6..d32c4ec24 100644 --- a/tests/by-util/test_whoami.rs +++ b/tests/by-util/test_whoami.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. #[cfg(unix)] use crate::common::util::expected_result; diff --git a/tests/common/macros.rs b/tests/common/macros.rs index 4f5965d5a..4902ca49b 100644 --- a/tests/common/macros.rs +++ b/tests/common/macros.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. /// Platform-independent helper for constructing a `PathBuf` from individual elements #[macro_export] diff --git a/tests/common/random.rs b/tests/common/random.rs index bf1e6a907..42b6eaa77 100644 --- a/tests/common/random.rs +++ b/tests/common/random.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. use rand::distributions::{Distribution, Uniform}; use rand::{thread_rng, Rng}; diff --git a/tests/common/util.rs b/tests/common/util.rs index 8ef5f517a..0fbc58cd5 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -1,7 +1,7 @@ -// * This file is part of the uutils coreutils package. -// * -// * For the full copyright and license information, please view the LICENSE -// * file that was distributed with this source code. +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. //spell-checker: ignore (linux) rlimit prlimit coreutil ggroups uchild uncaptured scmd SHLVL canonicalized From 4d78ca47b11767a6d80c5392ffb3ad8144392aab Mon Sep 17 00:00:00 2001 From: Ben Schofield Date: Thu, 24 Aug 2023 11:15:03 -0600 Subject: [PATCH 075/370] Add Spell ignore Add `samply` and `flamegraph` to spell ignore lists. --- .vscode/cspell.dictionaries/shell.wordlist.txt | 3 +++ src/uu/rm/BENCHMARKING.md | 1 + 2 files changed, 4 insertions(+) diff --git a/.vscode/cspell.dictionaries/shell.wordlist.txt b/.vscode/cspell.dictionaries/shell.wordlist.txt index 16d7b25e9..95dea94a7 100644 --- a/.vscode/cspell.dictionaries/shell.wordlist.txt +++ b/.vscode/cspell.dictionaries/shell.wordlist.txt @@ -83,6 +83,8 @@ codespell commitlint dprint dtrace +flamegraph +flamegraphs gcov gmake grcov @@ -90,6 +92,7 @@ grep markdownlint rerast rollup +samply sed selinuxenabled sestatus diff --git a/src/uu/rm/BENCHMARKING.md b/src/uu/rm/BENCHMARKING.md index cff93ec93..507906d49 100644 --- a/src/uu/rm/BENCHMARKING.md +++ b/src/uu/rm/BENCHMARKING.md @@ -1,3 +1,4 @@ + # Benchmarking rm Run `cargo build --release` before benchmarking after you make a change! From 6468845850a0c847f42fb400ffecbdcf54f8e99c Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Thu, 24 Aug 2023 20:36:52 -0400 Subject: [PATCH 076/370] refactor to check for system timeout once + commented out many moved/deleted test files that make script fail --- util/build-gnu.sh | 71 ++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 4414b7f12..c6991d15c 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -18,6 +18,20 @@ path_GNU="$(readlink -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")" ### +# On MacOS there is no system /usr/bin/timeout +# and trying to add it to /usr/bin (with symlink of copy binary) will fail unless system integrity protection is disabled (not ideal) +# ref: https://support.apple.com/en-us/102149 +# On MacOS the Homebrew coreutils could be installed and then "sudo ln -s /opt/homebrew/bin/timeout /usr/local/bin/timeout" +# Set to /usr/local/bin/timeout instead if /usr/bin/timeout is not found +SYSTEM_TIMEOUT="timeout" +if [ -x /usr/bin/timeout ] ; then + SYSTEM_TIMEOUT="/usr/bin/timeout" +elif [ -x /usr/local/bin/timeout ] ; then + SYSTEM_TIMEOUT="/usr/local/bin/timeout" +fi + +### + if test ! -d "${path_GNU}"; then echo "Could not find GNU coreutils (expected at '${path_GNU}')" echo "Run the following to download into the expected path:" @@ -82,16 +96,7 @@ else ./bootstrap --skip-po ./configure --quiet --disable-gcc-warnings #Add timeout to to protect against hangs - # On MacOS there is no system /usr/bin/timeout - # and trying to add it to /usr/bin (with symlink of copy binary) will fail unless system integrity protection is disabled (not ideal) - # ref: https://support.apple.com/en-us/102149 - # On MacOS the Homebrew coreutils could be installed and then "sudo ln -s /opt/homebrew/bin/timeout /usr/local/bin/timeout" - # Set to /usr/local/timeout instead if /usr/bin/timeout is not found - if [ -x /usr/bin/timeout ] ; then - sed -i 's|^"\$@|/usr/bin/timeout 600 "\$@|' build-aux/test-driver - else - sed -i 's|^"\$@|/usr/local/bin/timeout 600 "\$@|' build-aux/test-driver - fi + sed -i 's|^"\$@|'"${SYSTEM_TIMEOUT}"' 600 "\$@|' build-aux/test-driver # Change the PATH in the Makefile to test the uutils coreutils instead of the GNU coreutils sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${UU_BUILD_DIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile sed -i 's| tr | /usr/bin/tr |' tests/init.sh @@ -148,44 +153,32 @@ sed -i -e '/tests\/misc\/seq-precision.sh/ D' \ Makefile # printf doesn't limit the values used in its arg, so this produced ~2GB of output -sed -i '/INT_OFLOW/ D' tests/misc/printf.sh +# Looks like tests/misc/printf.sh does not exist anymore - comment it out for now +#sed -i '/INT_OFLOW/ D' tests/misc/printf.sh # Use the system coreutils where the test fails due to error in a util that is not the one being tested # TODO : tests/tail-2/ does not appear to exist # and have been moved to just tests/tail/ location # Might need to update the section below to reflect that -sed -i 's|stat|/usr/bin/stat|' tests/touch/60-seconds.sh tests/misc/sort-compress-proc.sh +# Also looks like tests/misc/sort-compress-proc.sh and tests/tail-2/tail-n0f.sh and tests/misc/shuf.sh and many others do not exist anymore or moved - comment it out for now +sed -i 's|stat|/usr/bin/stat|' tests/touch/60-seconds.sh #tests/misc/sort-compress-proc.sh sed -i 's|ls -|/usr/bin/ls -|' tests/cp/same-file.sh tests/misc/mknod.sh tests/mv/part-symlink.sh -sed -i 's|chmod |/usr/bin/chmod |' tests/du/inacc-dir.sh tests/tail-2/tail-n0f.sh tests/cp/fail-perm.sh tests/mv/i-2.sh tests/misc/shuf.sh -sed -i 's|sort |/usr/bin/sort |' tests/ls/hyperlink.sh tests/misc/test-N.sh -sed -i 's|split |/usr/bin/split |' tests/misc/factor-parallel.sh -sed -i 's|id -|/usr/bin/id -|' tests/misc/runcon-no-reorder.sh +sed -i 's|chmod |/usr/bin/chmod |' tests/du/inacc-dir.sh tests/cp/fail-perm.sh tests/mv/i-2.sh #tests/misc/shuf.sh #tests/tail-2/tail-n0f.sh +sed -i 's|sort |/usr/bin/sort |' tests/ls/hyperlink.sh #tests/misc/test-N.sh +#sed -i 's|split |/usr/bin/split |' tests/misc/factor-parallel.sh +#sed -i 's|id -|/usr/bin/id -|' tests/misc/runcon-no-reorder.sh # tests/ls/abmon-align.sh - https://github.com/uutils/coreutils/issues/3505 -sed -i 's|touch |/usr/bin/touch |' tests/cp/reflink-perm.sh tests/ls/block-size.sh tests/mv/update.sh tests/misc/ls-time.sh tests/misc/stat-nanoseconds.sh tests/misc/time-style.sh tests/misc/test-N.sh tests/ls/abmon-align.sh +sed -i 's|touch |/usr/bin/touch |' tests/cp/reflink-perm.sh tests/ls/block-size.sh tests/mv/update.sh tests/misc/time-style.sh tests/ls/abmon-align.sh #tests/misc/ls-time.sh tests/misc/stat-nanoseconds.sh tests/misc/test-N.sh sed -i 's|ln -|/usr/bin/ln -|' tests/cp/link-deref.sh sed -i 's|cp |/usr/bin/cp |' tests/mv/hard-2.sh -sed -i 's|paste |/usr/bin/paste |' tests/misc/od-endian.sh -# On MacOS there is no system /usr/bin/timeout -# and trying to add it to /usr/bin (with symlink of copy binary) will fail unless system integrity protection is disabled (not ideal) -# ref: https://support.apple.com/en-us/102149 -# On MacOS the Homebrew coreutils could be installed and then "sudo ln -s /opt/homebrew/bin/timeout /usr/local/bin/timeout" -# Set to /usr/local/timeout instead if /usr/bin/timeout is not found -if [ -x /usr/bin/timeout ] ; then - sed -i 's|timeout |/usr/bin/timeout |' tests/tail-2/follow-stdin.sh -else - sed -i 's|timeout |/usr/local/bin/timeout |' tests/tail-2/follow-stdin.sh -fi - +#sed -i 's|paste |/usr/bin/paste |' tests/misc/od-endian.sh +#sed -i 's|timeout |'"${SYSTEM_TIMEOUT}"' |' tests/tail-2/follow-stdin.sh # Add specific timeout to tests that currently hang to limit time spent waiting # TODO : tests/misc/seq-precision.sh tests/misc/seq-long-double.sh do not appear to exist # and have been moved to tests/seq/ location -# Might need to update the section below to reflect that -if [ -x /usr/bin/timeout ] ; then - sed -i 's|\(^\s*\)seq \$|\1/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh -else - sed -i 's|\(^\s*\)seq \$|\1/usr/local/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh -fi +# Might need to update the section below to reflect that, but comment it out for now +#sed -i 's|\(^\s*\)seq \$|\1'"${SYSTEM_TIMEOUT}"' 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh # Remove dup of /usr/bin/ (and /usr/local/bin) when executed several times grep -rlE '/usr/bin/\s?/usr/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/bin/\s?/usr/bin/|/usr/bin/|g' @@ -214,7 +207,7 @@ sed -i -e "s|rm: cannot remove 'rel': Permission denied|rm: cannot remove 'rel': # TODO : tests/tail-2/ does not appear to exist # and have been moved to just tests/tail/ location # Might need to update the section below to reflect that -sed -i -e "s|---dis ||g" tests/tail-2/overlay-headers.sh +#sed -i -e "s|---dis ||g" tests/tail-2/overlay-headers.sh test -f "${UU_BUILD_DIR}/getlimits" || cp src/getlimits "${UU_BUILD_DIR}" @@ -271,11 +264,13 @@ sed -i -e "s/Try 'mv --help' for more information/For more information, try '--h # GNU doesn't support width > INT_MAX # disable these test cases -sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/misc/printf-cov.pl +# TODO: moved or deleted tests/misc/printf-cov.pl +#sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/misc/printf-cov.pl sed -i -e "s/du: invalid -t argument/du: invalid --threshold argument/" -e "s/du: option requires an argument/error: a value is required for '--threshold ' but none was supplied/" -e "/Try 'du --help' for more information./d" tests/du/threshold.sh # disable two kind of tests: # "hostid BEFORE --help" doesn't fail for GNU. we fail. we are probably doing better # "hostid BEFORE --help AFTER " same for this -sed -i -e "s/env \$prog \$BEFORE \$opt > out2/env \$prog \$BEFORE \$opt > out2 #/" -e "s/env \$prog \$BEFORE \$opt AFTER > out3/env \$prog \$BEFORE \$opt AFTER > out3 #/" -e "s/compare exp out2/compare exp out2 #/" -e "s/compare exp out3/compare exp out3 #/" tests/misc/help-version-getopt.sh +# TODO moved or deleted tests/misc/help-version-getopt.sh +#sed -i -e "s/env \$prog \$BEFORE \$opt > out2/env \$prog \$BEFORE \$opt > out2 #/" -e "s/env \$prog \$BEFORE \$opt AFTER > out3/env \$prog \$BEFORE \$opt AFTER > out3 #/" -e "s/compare exp out2/compare exp out2 #/" -e "s/compare exp out3/compare exp out3 #/" tests/misc/help-version-getopt.sh From 01b2834f2eae3dfc4c24cb1ce2a25983f87fb775 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 25 Aug 2023 08:12:18 +0200 Subject: [PATCH 077/370] Fix clippy warnings with Rust 1.72.0 --- src/uu/cp/src/copydir.rs | 4 ++-- src/uu/cp/src/cp.rs | 3 ++- src/uu/factor/src/factor.rs | 3 ++- src/uu/factor/src/miller_rabin.rs | 2 +- src/uu/fmt/src/linebreak.rs | 1 + src/uu/ln/src/ln.rs | 2 +- src/uu/mktemp/src/mktemp.rs | 2 +- src/uu/ptx/src/ptx.rs | 4 ++-- src/uu/stat/src/stat.rs | 4 ++-- src/uu/tsort/src/tsort.rs | 1 + src/uucore/src/lib/features/sum.rs | 6 +++--- .../tokenize/num_format/formatters/base_conv/mod.rs | 2 +- src/uucore/src/lib/features/tokenize/sub.rs | 4 ++-- tests/by-util/test_runcon.rs | 2 +- 14 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/uu/cp/src/copydir.rs b/src/uu/cp/src/copydir.rs index cfb18212d..430548d0c 100644 --- a/src/uu/cp/src/copydir.rs +++ b/src/uu/cp/src/copydir.rs @@ -33,8 +33,8 @@ use crate::{ fn adjust_canonicalization(p: &Path) -> Cow { // In some cases, \\? can be missing on some Windows paths. Add it at the // beginning unless the path is prefixed with a device namespace. - const VERBATIM_PREFIX: &str = r#"\\?"#; - const DEVICE_NS_PREFIX: &str = r#"\\."#; + const VERBATIM_PREFIX: &str = r"\\?"; + const DEVICE_NS_PREFIX: &str = r"\\."; let has_prefix = p .components() diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 4b326d9d5..ff8548ced 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1133,6 +1133,7 @@ fn preserve_hardlinks( let inode = get_inode(&info); let nlinks = info.number_of_links(); let mut found_hard_link = false; + #[allow(clippy::explicit_iter_loop)] for (link, link_inode) in hard_links.iter() { if *link_inode == inode { // Consider the following files: @@ -1212,7 +1213,7 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult None }; - for source in sources.iter() { + for source in sources { if seen_sources.contains(source) { // FIXME: compare sources by the actual file they point to, not their path. (e.g. dir/file == dir/../dir/file in most cases) show_warning!("source {} specified more than once", source.quote()); diff --git a/src/uu/factor/src/factor.rs b/src/uu/factor/src/factor.rs index 1af6bc550..a7e848bb8 100644 --- a/src/uu/factor/src/factor.rs +++ b/src/uu/factor/src/factor.rs @@ -96,7 +96,7 @@ impl fmt::Display for Factors { v.sort_unstable(); let include_exponents = f.alternate(); - for (p, exp) in v.iter() { + for (p, exp) in v { if include_exponents && *exp > 1 { write!(f, " {p}^{exp}")?; } else { @@ -292,6 +292,7 @@ impl std::ops::BitXor for Factors { fn bitxor(self, rhs: Exponent) -> Self { debug_assert_ne!(rhs, 0); let mut r = Self::one(); + #[allow(clippy::explicit_iter_loop)] for (p, e) in self.0.borrow().0.iter() { r.add(*p, rhs * e); } diff --git a/src/uu/factor/src/miller_rabin.rs b/src/uu/factor/src/miller_rabin.rs index 1ccc55600..a06b20cd3 100644 --- a/src/uu/factor/src/miller_rabin.rs +++ b/src/uu/factor/src/miller_rabin.rs @@ -61,7 +61,7 @@ pub(crate) fn test(m: A) -> Result { let one = m.one(); let minus_one = m.minus_one(); - 'witness: for _a in A::BASIS.iter() { + 'witness: for _a in A::BASIS { let _a = _a % n; if _a == 0 { continue; diff --git a/src/uu/fmt/src/linebreak.rs b/src/uu/fmt/src/linebreak.rs index 13f34ca96..fbd990fff 100644 --- a/src/uu/fmt/src/linebreak.rs +++ b/src/uu/fmt/src/linebreak.rs @@ -273,6 +273,7 @@ fn find_kp_breakpoints<'a, T: Iterator>>( next_active_breaks.clear(); // go through each active break, extending it and possibly adding a new active // break if we are above the minimum required length + #[allow(clippy::explicit_iter_loop)] for &i in active_breaks.iter() { let active = &mut linebreaks[i]; // normalize demerits to avoid overflow, and record if this is the least diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index 18d515a88..8b76aa73c 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -297,7 +297,7 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings) } let mut all_successful = true; - for srcpath in files.iter() { + for srcpath in files { let targetpath = if settings.no_dereference && matches!(settings.overwrite, OverwriteMode::Force) { // In that case, we don't want to do link resolution diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index f99136810..77ef5fcbe 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -451,7 +451,7 @@ pub fn dry_exec(tmpdir: &str, prefix: &str, rand: usize, suffix: &str) -> UResul // Randomize. let bytes = &mut buf[prefix.len()..prefix.len() + rand]; rand::thread_rng().fill(bytes); - for byte in bytes.iter_mut() { + for byte in bytes { *byte = match *byte % 62 { v @ 0..=9 => v + b'0', v @ 10..=35 => v - 10 + b'a', diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index 4385ab484..1e9532a3a 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -322,7 +322,7 @@ fn create_word_set(config: &Config, filter: &WordFilter, file_map: &FileMap) -> let reg = Regex::new(&filter.word_regex).unwrap(); let ref_reg = Regex::new(&config.context_regex).unwrap(); let mut word_set: BTreeSet = BTreeSet::new(); - for (file, lines) in file_map.iter() { + for (file, lines) in file_map { let mut count: usize = 0; let offs = lines.offset; for line in &lines.lines { @@ -654,7 +654,7 @@ fn write_traditional_output( let context_reg = Regex::new(&config.context_regex).unwrap(); - for word_ref in words.iter() { + for word_ref in words { let file_map_value: &FileContent = file_map .get(&(word_ref.filename)) .expect("Missing file in file map"); diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 19fc5370a..c36b45006 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -633,7 +633,7 @@ impl Stater { Ok(meta) => { let tokens = &self.default_tokens; - for t in tokens.iter() { + for t in tokens { match *t { Token::Char(c) => print!("{c}"), Token::Directive { @@ -701,7 +701,7 @@ impl Stater { &self.default_dev_tokens }; - for t in tokens.iter() { + for t in tokens { match *t { Token::Char(c) => print!("{c}"), Token::Directive { diff --git a/src/uu/tsort/src/tsort.rs b/src/uu/tsort/src/tsort.rs index f094963dc..e71710847 100644 --- a/src/uu/tsort/src/tsort.rs +++ b/src/uu/tsort/src/tsort.rs @@ -154,6 +154,7 @@ impl Graph { self.result.push(n.clone()); let n_out_edges = self.out_edges.get_mut(&n).unwrap(); + #[allow(clippy::explicit_iter_loop)] for m in n_out_edges.iter() { let m_in_edges = self.in_edges.get_mut(m).unwrap(); m_in_edges.remove(&n); diff --git a/src/uucore/src/lib/features/sum.rs b/src/uucore/src/lib/features/sum.rs index 2b69008de..e079d7a30 100644 --- a/src/uucore/src/lib/features/sum.rs +++ b/src/uucore/src/lib/features/sum.rs @@ -176,7 +176,7 @@ impl Digest for CRC { } fn hash_update(&mut self, input: &[u8]) { - for &elt in input.iter() { + for &elt in input { self.update(elt); } self.size += input.len(); @@ -223,7 +223,7 @@ impl Digest for BSD { } fn hash_update(&mut self, input: &[u8]) { - for &byte in input.iter() { + for &byte in input { self.state = (self.state >> 1) + ((self.state & 1) << 15); self.state = self.state.wrapping_add(u16::from(byte)); } @@ -257,7 +257,7 @@ impl Digest for SYSV { } fn hash_update(&mut self, input: &[u8]) { - for &byte in input.iter() { + for &byte in input { self.state = self.state.wrapping_add(u32::from(byte)); } } diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs b/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs index f8b5da86c..7c041fec8 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs @@ -195,7 +195,7 @@ pub fn str_to_arrnum(src: &str, radix_def_src: &dyn RadixDef) -> Vec { pub fn arrnum_to_str(src: &[u8], radix_def_dest: &dyn RadixDef) -> String { let mut str_out = String::new(); - for u in src.iter() { + for u in src { #[allow(clippy::single_match)] match radix_def_dest.format_u8(*u) { Some(c) => { diff --git a/src/uucore/src/lib/features/tokenize/sub.rs b/src/uucore/src/lib/features/tokenize/sub.rs index 4651dc8d8..447616ae6 100644 --- a/src/uucore/src/lib/features/tokenize/sub.rs +++ b/src/uucore/src/lib/features/tokenize/sub.rs @@ -188,11 +188,11 @@ impl SubParser { // though, as we want to mimic the original behavior of printing // the field as interpreted up until the error in the field. - let mut legal_fields = vec![ + let mut legal_fields = [ // 'a', 'A', //c99 hex float implementation not yet complete 'b', 'c', 'd', 'e', 'E', 'f', 'F', 'g', 'G', 'i', 'o', 's', 'u', 'x', 'X', ]; - let mut specifiers = vec!['h', 'j', 'l', 'L', 't', 'z']; + let mut specifiers = ['h', 'j', 'l', 'L', 't', 'z']; legal_fields.sort_unstable(); specifiers.sort_unstable(); diff --git a/tests/by-util/test_runcon.rs b/tests/by-util/test_runcon.rs index 7635fea49..8e8b9b6b5 100644 --- a/tests/by-util/test_runcon.rs +++ b/tests/by-util/test_runcon.rs @@ -137,7 +137,7 @@ fn custom_context() { } fn get_sestatus_context(output: &[u8]) -> &str { - let re = regex::bytes::Regex::new(r#"Current context:\s*(\S+)\s*"#) + let re = regex::bytes::Regex::new(r"Current context:\s*(\S+)\s*") .expect("Invalid regular expression"); output From b9c05ed4e37f678704b63e70d3438538200661f3 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 25 Aug 2023 15:03:19 +0200 Subject: [PATCH 078/370] Remove the author copyright notices from files missed by https://github.com/uutils/coreutils/pull/5184 and https://github.com/uutils/coreutils/pull/5197 --- src/uucore/src/lib/lib.rs | 3 --- src/uucore_procs/src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 1d97522c7..4f2a1c766 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -4,9 +4,6 @@ // file that was distributed with this source code. // library ~ (core/bundler file) -// Copyright (C) ~ Alex Lyon -// Copyright (C) ~ Roy Ivy III ; MIT license - // * feature-gated external crates (re-shared as public internal modules) #[cfg(feature = "libc")] pub extern crate libc; diff --git a/src/uucore_procs/src/lib.rs b/src/uucore_procs/src/lib.rs index ef1ba87cf..cbe915936 100644 --- a/src/uucore_procs/src/lib.rs +++ b/src/uucore_procs/src/lib.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// Copyright (C) ~ Roy Ivy III ; MIT license +// // spell-checker:ignore backticks uuhelp use std::{fs::File, io::Read, path::PathBuf}; From 79a44d768cecc9bff751d4772cc3faf2906920eb Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 25 Aug 2023 15:29:15 +0200 Subject: [PATCH 079/370] uucore,comm: fix warnings from bool_to_int_with_if --- src/uu/comm/src/comm.rs | 12 ++---------- src/uucore/src/lib/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/uu/comm/src/comm.rs b/src/uu/comm/src/comm.rs index 1bb0020d5..e6977142e 100644 --- a/src/uu/comm/src/comm.rs +++ b/src/uu/comm/src/comm.rs @@ -30,14 +30,6 @@ mod options { pub const ZERO_TERMINATED: &str = "zero-terminated"; } -fn column_width(col: &str, opts: &ArgMatches) -> usize { - if opts.get_flag(col) { - 0 - } else { - 1 - } -} - enum Input { Stdin(Stdin), FileIn(BufReader), @@ -75,8 +67,8 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &ArgMatches) { delim => delim, }; - let width_col_1 = column_width(options::COLUMN_1, opts); - let width_col_2 = column_width(options::COLUMN_2, opts); + let width_col_1 = usize::from(!opts.get_flag(options::COLUMN_1)); + let width_col_2 = usize::from(!opts.get_flag(options::COLUMN_2)); let delim_col_2 = delim.repeat(width_col_1); let delim_col_3 = delim.repeat(width_col_1 + width_col_2); diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 1d97522c7..add5d9d3b 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -133,8 +133,8 @@ pub fn set_utility_is_second_arg() { static ARGV: Lazy> = Lazy::new(|| wild::args_os().collect()); static UTIL_NAME: Lazy = Lazy::new(|| { - let base_index = if get_utility_is_second_arg() { 1 } else { 0 }; - let is_man = if ARGV[base_index].eq("manpage") { 1 } else { 0 }; + let base_index = usize::from(get_utility_is_second_arg()); + let is_man = usize::from(ARGV[base_index].eq("manpage")); let argv_index = base_index + is_man; ARGV[argv_index].to_string_lossy().into_owned() From 350b9c3d486449f592b9fd92f349b884926073cb Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Fri, 25 Aug 2023 13:43:48 -0400 Subject: [PATCH 080/370] reverted commented out test files and added more details in TODO(s) --- util/build-gnu.sh | 51 +++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index c6991d15c..587cf8580 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -152,37 +152,37 @@ sed -i -e '/tests\/misc\/invalid-opt.pl/ D' \ sed -i -e '/tests\/misc\/seq-precision.sh/ D' \ Makefile +# TODO: many files and some directories modified with 'sed' in the sections below either no longer exist or have been moved +# TODO: Might need to review and updated sections below +# TODO: As a result this script will fail when executed normally as 'bash util/build-gnu.hs' due to the 'set -e' set at the beginning +# TODO: The rest of the 'sed' commands after first failure in this scenario will not be executed as bash will exit on first error +# TODO: However, the behaviour might be different when running it via GitHub actions (GnuTests) +# TODO: For now, when running in local a workaround would be to comment out the 'set -e' at the beginning of the file + # printf doesn't limit the values used in its arg, so this produced ~2GB of output -# Looks like tests/misc/printf.sh does not exist anymore - comment it out for now -#sed -i '/INT_OFLOW/ D' tests/misc/printf.sh +# TODO: this is the first one to likely fail as tests/misc/printf.sh does not exist/have been moved +sed -i '/INT_OFLOW/ D' tests/misc/printf.sh +# TODO: all commands below might not be executed # Use the system coreutils where the test fails due to error in a util that is not the one being tested -# TODO : tests/tail-2/ does not appear to exist -# and have been moved to just tests/tail/ location -# Might need to update the section below to reflect that -# Also looks like tests/misc/sort-compress-proc.sh and tests/tail-2/tail-n0f.sh and tests/misc/shuf.sh and many others do not exist anymore or moved - comment it out for now -sed -i 's|stat|/usr/bin/stat|' tests/touch/60-seconds.sh #tests/misc/sort-compress-proc.sh +sed -i 's|stat|/usr/bin/stat|' tests/touch/60-seconds.sh tests/misc/sort-compress-proc.sh sed -i 's|ls -|/usr/bin/ls -|' tests/cp/same-file.sh tests/misc/mknod.sh tests/mv/part-symlink.sh -sed -i 's|chmod |/usr/bin/chmod |' tests/du/inacc-dir.sh tests/cp/fail-perm.sh tests/mv/i-2.sh #tests/misc/shuf.sh #tests/tail-2/tail-n0f.sh -sed -i 's|sort |/usr/bin/sort |' tests/ls/hyperlink.sh #tests/misc/test-N.sh -#sed -i 's|split |/usr/bin/split |' tests/misc/factor-parallel.sh -#sed -i 's|id -|/usr/bin/id -|' tests/misc/runcon-no-reorder.sh +sed -i 's|chmod |/usr/bin/chmod |' tests/du/inacc-dir.sh tests/tail-2/tail-n0f.sh tests/cp/fail-perm.sh tests/mv/i-2.sh tests/misc/shuf.sh +sed -i 's|sort |/usr/bin/sort |' tests/ls/hyperlink.sh tests/misc/test-N.sh +sed -i 's|split |/usr/bin/split |' tests/misc/factor-parallel.sh +sed -i 's|id -|/usr/bin/id -|' tests/misc/runcon-no-reorder.sh # tests/ls/abmon-align.sh - https://github.com/uutils/coreutils/issues/3505 -sed -i 's|touch |/usr/bin/touch |' tests/cp/reflink-perm.sh tests/ls/block-size.sh tests/mv/update.sh tests/misc/time-style.sh tests/ls/abmon-align.sh #tests/misc/ls-time.sh tests/misc/stat-nanoseconds.sh tests/misc/test-N.sh +sed -i 's|touch |/usr/bin/touch |' tests/cp/reflink-perm.sh tests/ls/block-size.sh tests/mv/update.sh tests/misc/ls-time.sh tests/misc/stat-nanoseconds.sh tests/misc/time-style.sh tests/misc/test-N.sh tests/ls/abmon-align.sh sed -i 's|ln -|/usr/bin/ln -|' tests/cp/link-deref.sh sed -i 's|cp |/usr/bin/cp |' tests/mv/hard-2.sh -#sed -i 's|paste |/usr/bin/paste |' tests/misc/od-endian.sh -#sed -i 's|timeout |'"${SYSTEM_TIMEOUT}"' |' tests/tail-2/follow-stdin.sh +sed -i 's|paste |/usr/bin/paste |' tests/misc/od-endian.sh +sed -i 's|timeout |/usr/bin/timeout |' tests/tail-2/follow-stdin.sh # Add specific timeout to tests that currently hang to limit time spent waiting -# TODO : tests/misc/seq-precision.sh tests/misc/seq-long-double.sh do not appear to exist -# and have been moved to tests/seq/ location -# Might need to update the section below to reflect that, but comment it out for now -#sed -i 's|\(^\s*\)seq \$|\1'"${SYSTEM_TIMEOUT}"' 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh +sed -i 's|\(^\s*\)seq \$|\1/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh -# Remove dup of /usr/bin/ (and /usr/local/bin) when executed several times +# Remove dup of /usr/bin/ when executed several times grep -rlE '/usr/bin/\s?/usr/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/bin/\s?/usr/bin/|/usr/bin/|g' -grep -rlE '/usr/local/bin/\s?/usr/local/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/local/bin/\s?/usr/local/bin/|/usr/local/bin/|g' #### Adjust tests to make them work with Rust/coreutils # in some cases, what we are doing in rust/coreutils is good (or better) @@ -204,10 +204,7 @@ sed -i -e "s|rm: cannot remove 'rel': Permission denied|rm: cannot remove 'rel': # overlay-headers.sh test intends to check for inotify events, # however there's a bug because `---dis` is an alias for: `---disable-inotify` -# TODO : tests/tail-2/ does not appear to exist -# and have been moved to just tests/tail/ location -# Might need to update the section below to reflect that -#sed -i -e "s|---dis ||g" tests/tail-2/overlay-headers.sh +sed -i -e "s|---dis ||g" tests/tail-2/overlay-headers.sh test -f "${UU_BUILD_DIR}/getlimits" || cp src/getlimits "${UU_BUILD_DIR}" @@ -264,13 +261,11 @@ sed -i -e "s/Try 'mv --help' for more information/For more information, try '--h # GNU doesn't support width > INT_MAX # disable these test cases -# TODO: moved or deleted tests/misc/printf-cov.pl -#sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/misc/printf-cov.pl +sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/misc/printf-cov.pl sed -i -e "s/du: invalid -t argument/du: invalid --threshold argument/" -e "s/du: option requires an argument/error: a value is required for '--threshold ' but none was supplied/" -e "/Try 'du --help' for more information./d" tests/du/threshold.sh # disable two kind of tests: # "hostid BEFORE --help" doesn't fail for GNU. we fail. we are probably doing better # "hostid BEFORE --help AFTER " same for this -# TODO moved or deleted tests/misc/help-version-getopt.sh -#sed -i -e "s/env \$prog \$BEFORE \$opt > out2/env \$prog \$BEFORE \$opt > out2 #/" -e "s/env \$prog \$BEFORE \$opt AFTER > out3/env \$prog \$BEFORE \$opt AFTER > out3 #/" -e "s/compare exp out2/compare exp out2 #/" -e "s/compare exp out3/compare exp out3 #/" tests/misc/help-version-getopt.sh +sed -i -e "s/env \$prog \$BEFORE \$opt > out2/env \$prog \$BEFORE \$opt > out2 #/" -e "s/env \$prog \$BEFORE \$opt AFTER > out3/env \$prog \$BEFORE \$opt AFTER > out3 #/" -e "s/compare exp out2/compare exp out2 #/" -e "s/compare exp out3/compare exp out3 #/" tests/misc/help-version-getopt.sh From 2e2387d434281d37093f22c62bed188717ebbf66 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 26 Aug 2023 14:35:35 +0200 Subject: [PATCH 081/370] parse_size,dd: turn instance fns to associated fns --- src/uu/dd/src/parseargs.rs | 22 +++++++++++----------- src/uucore/src/lib/parser/parse_size.rs | 11 +++++------ 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/uu/dd/src/parseargs.rs b/src/uu/dd/src/parseargs.rs index bccf98f82..53fae1b4b 100644 --- a/src/uu/dd/src/parseargs.rs +++ b/src/uu/dd/src/parseargs.rs @@ -245,29 +245,29 @@ impl Parser { None => return Err(ParseError::UnrecognizedOperand(operand.to_string())), Some((k, v)) => match k { "bs" => { - let bs = self.parse_bytes(k, v)?; + let bs = Self::parse_bytes(k, v)?; self.ibs = bs; self.obs = bs; } - "cbs" => self.cbs = Some(self.parse_bytes(k, v)?), + "cbs" => self.cbs = Some(Self::parse_bytes(k, v)?), "conv" => self.parse_conv_flags(v)?, - "count" => self.count = Some(self.parse_n(v)?), - "ibs" => self.ibs = self.parse_bytes(k, v)?, + "count" => self.count = Some(Self::parse_n(v)?), + "ibs" => self.ibs = Self::parse_bytes(k, v)?, "if" => self.infile = Some(v.to_string()), "iflag" => self.parse_input_flags(v)?, - "obs" => self.obs = self.parse_bytes(k, v)?, + "obs" => self.obs = Self::parse_bytes(k, v)?, "of" => self.outfile = Some(v.to_string()), "oflag" => self.parse_output_flags(v)?, - "seek" | "oseek" => self.seek = self.parse_n(v)?, - "skip" | "iseek" => self.skip = self.parse_n(v)?, - "status" => self.status = Some(self.parse_status_level(v)?), + "seek" | "oseek" => self.seek = Self::parse_n(v)?, + "skip" | "iseek" => self.skip = Self::parse_n(v)?, + "status" => self.status = Some(Self::parse_status_level(v)?), _ => return Err(ParseError::UnrecognizedOperand(operand.to_string())), }, } Ok(()) } - fn parse_n(&self, val: &str) -> Result { + fn parse_n(val: &str) -> Result { let n = parse_bytes_with_opt_multiplier(val)?; Ok(if val.ends_with('B') { Num::Bytes(n) @@ -276,13 +276,13 @@ impl Parser { }) } - fn parse_bytes(&self, arg: &str, val: &str) -> Result { + fn parse_bytes(arg: &str, val: &str) -> Result { parse_bytes_with_opt_multiplier(val)? .try_into() .map_err(|_| ParseError::BsOutOfRange(arg.to_string())) } - fn parse_status_level(&self, val: &str) -> Result { + fn parse_status_level(val: &str) -> Result { match val { "none" => Ok(StatusLevel::None), "noxfer" => Ok(StatusLevel::Noxfer), diff --git a/src/uucore/src/lib/parser/parse_size.rs b/src/uucore/src/lib/parser/parse_size.rs index a93e0fe66..5f64afcd8 100644 --- a/src/uucore/src/lib/parser/parse_size.rs +++ b/src/uucore/src/lib/parser/parse_size.rs @@ -75,7 +75,7 @@ impl<'parser> Parser<'parser> { return Err(ParseSizeError::parse_failure(size)); } - let number_system: NumberSystem = self.determine_number_system(size); + let number_system = Self::determine_number_system(size); // Split the size argument into numeric and unit parts // For example, if the argument is "123K", the numeric part is "123", and @@ -156,16 +156,16 @@ impl<'parser> Parser<'parser> { if numeric_string.is_empty() { 1 } else { - self.parse_number(&numeric_string, 10, size)? + Self::parse_number(&numeric_string, 10, size)? } } NumberSystem::Octal => { let trimmed_string = numeric_string.trim_start_matches('0'); - self.parse_number(trimmed_string, 8, size)? + Self::parse_number(trimmed_string, 8, size)? } NumberSystem::Hexadecimal => { let trimmed_string = numeric_string.trim_start_matches("0x"); - self.parse_number(trimmed_string, 16, size)? + Self::parse_number(trimmed_string, 16, size)? } }; @@ -174,7 +174,7 @@ impl<'parser> Parser<'parser> { .ok_or_else(|| ParseSizeError::size_too_big(size)) } - fn determine_number_system(&self, size: &str) -> NumberSystem { + fn determine_number_system(size: &str) -> NumberSystem { if size.len() <= 1 { return NumberSystem::Decimal; } @@ -197,7 +197,6 @@ impl<'parser> Parser<'parser> { } fn parse_number( - &self, numeric_string: &str, radix: u32, original_size: &str, From db342556c2ce93be472abccd6594b27e932aa7f6 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 14 Aug 2023 13:40:05 +0200 Subject: [PATCH 082/370] nl: implement -d/--section-delimiter --- src/uu/nl/src/helper.rs | 9 +++++ src/uu/nl/src/nl.rs | 44 ++++++++++++++++----- tests/by-util/test_nl.rs | 83 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 125 insertions(+), 11 deletions(-) diff --git a/src/uu/nl/src/helper.rs b/src/uu/nl/src/helper.rs index fe550e6a0..ae14a6d59 100644 --- a/src/uu/nl/src/helper.rs +++ b/src/uu/nl/src/helper.rs @@ -13,6 +13,15 @@ pub fn parse_options(settings: &mut crate::Settings, opts: &clap::ArgMatches) -> // This vector holds error messages encountered. let mut errs: Vec = vec![]; settings.renumber = opts.get_flag(options::NO_RENUMBER); + if let Some(delimiter) = opts.get_one::(options::SECTION_DELIMITER) { + // check whether the delimiter is a single ASCII char (1 byte) + // because GNU nl doesn't add a ':' to single non-ASCII chars + settings.section_delimiter = if delimiter.len() == 1 { + format!("{delimiter}:") + } else { + delimiter.to_owned() + }; + } if let Some(val) = opts.get_one::(options::NUMBER_SEPARATOR) { settings.number_separator = val.to_owned(); } diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 61a0a9f35..839ec35db 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -23,7 +23,7 @@ pub struct Settings { body_numbering: NumberingStyle, footer_numbering: NumberingStyle, // The variable corresponding to -d - section_delimiter: [char; 2], + section_delimiter: String, // The variables corresponding to the options -v, -i, -l, -w. starting_line_number: i64, line_increment: i64, @@ -43,7 +43,7 @@ impl Default for Settings { header_numbering: NumberingStyle::None, body_numbering: NumberingStyle::NonEmpty, footer_numbering: NumberingStyle::None, - section_delimiter: ['\\', ':'], + section_delimiter: String::from("\\:"), starting_line_number: 1, line_increment: 1, join_blank_lines: 1, @@ -120,6 +120,32 @@ impl NumberFormat { } } +enum SectionDelimiter { + Header, + Body, + Footer, +} + +impl SectionDelimiter { + // A valid section delimiter contains the pattern one to three times, + // and nothing else. + fn parse(s: &str, pattern: &str) -> Option { + if s.is_empty() || pattern.is_empty() { + return None; + } + + let pattern_count = s.matches(pattern).count(); + let is_length_ok = pattern_count * pattern.len() == s.len(); + + match (pattern_count, is_length_ok) { + (3, true) => Some(Self::Header), + (2, true) => Some(Self::Body), + (1, true) => Some(Self::Footer), + _ => None, + } + } +} + pub mod options { pub const HELP: &str = "help"; pub const FILE: &str = "file"; @@ -299,14 +325,12 @@ fn nl(reader: &mut BufReader, settings: &Settings) -> UResult<()> { consecutive_empty_lines = 0; }; - // FIXME section delimiters are hardcoded and settings.section_delimiter is ignored - // because --section-delimiter is not correctly implemented yet - let _ = settings.section_delimiter; // XXX suppress "field never read" warning - let new_numbering_style = match line.as_str() { - "\\:\\:\\:" => Some(&settings.header_numbering), - "\\:\\:" => Some(&settings.body_numbering), - "\\:" => Some(&settings.footer_numbering), - _ => None, + let new_numbering_style = match SectionDelimiter::parse(&line, &settings.section_delimiter) + { + Some(SectionDelimiter::Header) => Some(&settings.header_numbering), + Some(SectionDelimiter::Body) => Some(&settings.body_numbering), + Some(SectionDelimiter::Footer) => Some(&settings.footer_numbering), + None => None, }; if let Some(new_style) = new_numbering_style { diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index b58c0c206..e21bb5037 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -2,7 +2,8 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore binvalid finvalid hinvalid iinvalid linvalid ninvalid vinvalid winvalid +// +// spell-checker:ignore binvalid finvalid hinvalid iinvalid linvalid nabcabc nabcabcabc ninvalid vinvalid winvalid use crate::common::util::TestScenario; #[test] @@ -486,3 +487,83 @@ fn test_line_number_overflow() { .stdout_is(format!("{}\ta\n", i64::MIN)) .stderr_is("nl: line number overflow\n"); } + +#[test] +fn test_section_delimiter() { + for arg in ["-dabc", "--section-delimiter=abc"] { + new_ucmd!() + .arg(arg) + .pipe_in("a\nabcabcabc\nb") // header section + .succeeds() + .stdout_is(" 1\ta\n\n b\n"); + + new_ucmd!() + .arg(arg) + .pipe_in("a\nabcabc\nb") // body section + .succeeds() + .stdout_is(" 1\ta\n\n 1\tb\n"); + + new_ucmd!() + .arg(arg) + .pipe_in("a\nabc\nb") // footer section + .succeeds() + .stdout_is(" 1\ta\n\n b\n"); + } +} + +#[test] +fn test_one_char_section_delimiter_expansion() { + for arg in ["-da", "--section-delimiter=a"] { + new_ucmd!() + .arg(arg) + .pipe_in("a\na:a:a:\nb") // header section + .succeeds() + .stdout_is(" 1\ta\n\n b\n"); + + new_ucmd!() + .arg(arg) + .pipe_in("a\na:a:\nb") // body section + .succeeds() + .stdout_is(" 1\ta\n\n 1\tb\n"); + + new_ucmd!() + .arg(arg) + .pipe_in("a\na:\nb") // footer section + .succeeds() + .stdout_is(" 1\ta\n\n b\n"); + } +} + +#[test] +fn test_non_ascii_one_char_section_delimiter() { + for arg in ["-dä", "--section-delimiter=ä"] { + new_ucmd!() + .arg(arg) + .pipe_in("a\näää\nb") // header section + .succeeds() + .stdout_is(" 1\ta\n\n b\n"); + + new_ucmd!() + .arg(arg) + .pipe_in("a\nää\nb") // body section + .succeeds() + .stdout_is(" 1\ta\n\n 1\tb\n"); + + new_ucmd!() + .arg(arg) + .pipe_in("a\nä\nb") // footer section + .succeeds() + .stdout_is(" 1\ta\n\n b\n"); + } +} + +#[test] +fn test_empty_section_delimiter() { + for arg in ["-d ''", "--section-delimiter=''"] { + new_ucmd!() + .arg(arg) + .pipe_in("a\n\nb") + .succeeds() + .stdout_is(" 1\ta\n \n 2\tb\n"); + } +} From 84d96f9d028a4dd8c0f98ba6db2ba6dc90c79dcb Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Sat, 26 Aug 2023 11:11:46 -0400 Subject: [PATCH 083/370] split: refactor for more common use case --- src/uu/split/src/split.rs | 81 ++++++++++++++++++- tests/by-util/test_split.rs | 152 +++++++++++++++++++++++++++++++++++- 2 files changed, 229 insertions(+), 4 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 71aacfed0..c4b7e6d66 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -51,14 +51,66 @@ const AFTER_HELP: &str = help_section!("after help", "split.md"); #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { + let args = args.collect_lossy(); + + let (args, obs_lines) = handle_obsolete(&args[..]); + let matches = uu_app().try_get_matches_from(args)?; - match Settings::from(&matches) { + + match Settings::from(&matches, &obs_lines) { Ok(settings) => split(&settings), Err(e) if e.requires_usage() => Err(UUsageError::new(1, format!("{e}"))), Err(e) => Err(USimpleError::new(1, format!("{e}"))), } } +/// Extract obsolete shorthand (if any) for specifying lines in following scenarios (and similar) +/// `split -22 file` would mean `split -l 22 file` +/// `split -2de file` would mean `split -l 2 -d -e file` +/// `split -x300e file` would mean `split -x -l 300 -e file` +/// `split -x300e -22 file` would mean `split -x -e -l 22 file` (last obsolete lines option wins) +/// following GNU `split` behavior +fn handle_obsolete(args: &[String]) -> (Vec, Option) { + let mut v: Vec = vec![]; + let mut obs_lines = None; + for arg in args.iter() { + let slice = &arg; + if slice.starts_with('-') && !slice.starts_with("--") { + // start of the short option string + // extract numeric part and filter it out + let mut obs_lines_extracted: Vec = vec![]; + let filtered_slice: Vec = slice + .chars() + .filter(|c| { + if c.is_ascii_digit() { + obs_lines_extracted.push(*c); + false + } else { + true + } + }) + .collect(); + + if filtered_slice.get(1).is_some() { + // there were some short options in front of obsolete lines number + // i.e. '-xd100' or similar + // preserve it + v.push(filtered_slice.iter().collect()) + } + if !obs_lines_extracted.is_empty() { + // obsolete lines value was extracted + obs_lines = Some(obs_lines_extracted.iter().collect()); + } + } else { + // not a short option + // preserve it + v.push(arg.to_owned()); + } + } + println!("{:#?}",v); + (v, obs_lines) +} + pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(crate_version!()) @@ -357,6 +409,17 @@ impl fmt::Display for StrategyError { } impl Strategy { + /// Parse a strategy from obsolete line option value + fn from_obs(obs_value: &str) -> Result { + let n = parse_size(obs_value).map_err(StrategyError::Lines)?; + if n > 0 { + Ok(Self::Lines(n)) + } else { + Err(StrategyError::Lines(ParseSizeError::ParseFailure( + obs_value.to_string(), + ))) + } + } /// Parse a strategy from the command-line arguments. fn from(matches: &ArgMatches) -> Result { fn get_and_parse( @@ -506,7 +569,7 @@ impl fmt::Display for SettingsError { impl Settings { /// Parse a strategy from the command-line arguments. - fn from(matches: &ArgMatches) -> Result { + fn from(matches: &ArgMatches, obs_lines: &Option) -> Result { let additional_suffix = matches .get_one::(OPT_ADDITIONAL_SUFFIX) .unwrap() @@ -514,7 +577,19 @@ impl Settings { if additional_suffix.contains('/') { return Err(SettingsError::SuffixContainsSeparator(additional_suffix)); } - let strategy = Strategy::from(matches).map_err(SettingsError::Strategy)?; + + // obsolete lines option cannot be used simultaneously with OPT_LINES + let strategy = match obs_lines { + Some(obs_value) => { + if matches.value_source(OPT_LINES) == Some(ValueSource::CommandLine) { + return Err(SettingsError::Strategy(StrategyError::MultipleWays)); + } else { + Strategy::from_obs(obs_value).map_err(SettingsError::Strategy)? + } + } + None => Strategy::from(matches).map_err(SettingsError::Strategy)?, + }; + let (suffix_type, suffix_start) = suffix_type_from(matches)?; let suffix_length_str = matches.get_one::(OPT_SUFFIX_LENGTH).unwrap(); let suffix_length: usize = suffix_length_str diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index c5f32482e..fe753f084 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes threebytes asciilowercase fghij klmno pqrst uvwxyz fivelines twohundredfortyonebytes onehundredlines nbbbb +// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes threebytes asciilowercase fghij klmno pqrst uvwxyz fivelines twohundredfortyonebytes onehundredlines nbbbb dxen use crate::common::util::{AtPath, TestScenario}; use rand::{thread_rng, Rng, SeedableRng}; @@ -320,6 +320,156 @@ fn test_split_lines_number() { .stderr_only("split: invalid number of lines: '2fb'\n"); } +/// Test for obsolete lines option standalone +#[test] +fn test_split_obs_lines_standalone() { + let (at, mut ucmd) = at_and_ucmd!(); + let name = "obs-lines-standalone"; + RandomFile::new(&at, name).add_lines(4); + ucmd.args(&["-2", name]).succeeds().no_stderr().no_stdout(); + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 2); + assert_eq!(glob.collate(), at.read_bytes(name)); +} + +/// Test for invalid obsolete lines option +#[test] +fn test_split_invalid_obs_lines_standalone() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.touch("file"); + + scene + .ucmd() + .args(&["-2fb", "file"]) + .fails() + .code_is(1) + .stderr_only("error: unexpected argument '-f' found\n"); +} + +/// Test for obsolete lines option as part of combined short options +#[test] +fn test_split_obs_lines_within_combined_shorts() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + let name = "obs-lines-within-shorts"; + RandomFile::new(&at, name).add_lines(400); + + scene + .ucmd() + .args(&["-d200xe", name]) + .succeeds() + .no_stderr() + .no_stdout(); + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 2); + assert_eq!(glob.collate(), at.read_bytes(name)) +} + +/// Test for obsolete lines option starts as part of combined short options +#[test] +fn test_split_obs_lines_starts_combined_shorts() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + let name = "obs-lines-starts-shorts"; + RandomFile::new(&at, name).add_lines(400); + + scene + .ucmd() + .args(&["-x200d", name]) + .succeeds() + .no_stderr() + .no_stdout(); + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 2); + assert_eq!(glob.collate(), at.read_bytes(name)) +} + +/// Test for using both obsolete lines (standalone) option and short/long lines option simultaneously +#[test] +fn test_split_both_lines_and_obs_lines_standalone() { + // This test will ensure that if both lines option '-l' or '--lines' + // and obsolete lines option '-100' are used + // it fails + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.touch("file"); + + scene + .ucmd() + .args(&["-l", "2", "-2", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: cannot split in more than one way\n"); + scene + .ucmd() + .args(&["--lines", "2", "-2", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: cannot split in more than one way\n"); +} + +/// Test for using more than one obsolete lines option (standalone) +/// last one wins +#[test] +fn test_split_multiple_obs_lines_standalone() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + let name = "multiple-obs-lines"; + RandomFile::new(&at, name).add_lines(400); + + scene + .ucmd() + .args(&["-3000", "-200", name]) + .succeeds() + .no_stderr() + .no_stdout(); + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 2); + assert_eq!(glob.collate(), at.read_bytes(name)) +} + +/// Test for using more than one obsolete lines option within combined shorts +/// last one wins +#[test] +fn test_split_multiple_obs_lines_within_combined() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + let name = "multiple-obs-lines"; + RandomFile::new(&at, name).add_lines(400); + + scene + .ucmd() + .args(&["-x5000d -e200x", name]) + .succeeds() + .no_stderr() + .no_stdout(); + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 2); + assert_eq!(glob.collate(), at.read_bytes(name)) +} + +/// Test for using both obsolete lines option within combined shorts with conflicting -n option simultaneously +#[test] +fn test_split_obs_lines_within_combined_with_number() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.touch("file"); + + scene + .ucmd() + .args(&["-3dxen", "4", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: cannot split in more than one way\n"); + scene + .ucmd() + .args(&["-dxe30n", "4", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: cannot split in more than one way\n"); +} + #[test] fn test_split_invalid_bytes_size() { new_ucmd!() From b3e994b36049fd709341ec72e7b7106c188d5a40 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 26 Aug 2023 16:50:39 +0000 Subject: [PATCH 084/370] chore(deps): update rust crate regex to 1.9.4 --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b92ab5f1c..f538cb841 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1758,9 +1758,9 @@ checksum = "f1bfbf25d7eb88ddcbb1ec3d755d0634da8f7657b2cb8b74089121409ab8228f" [[package]] name = "regex" -version = "1.9.3" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" dependencies = [ "aho-corasick", "memchr", @@ -1770,9 +1770,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" dependencies = [ "aho-corasick", "memchr", @@ -1781,9 +1781,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "relative-path" diff --git a/Cargo.toml b/Cargo.toml index 426a2c9d0..7a10995ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -311,7 +311,7 @@ rand = { version = "0.8", features = ["small_rng"] } rand_core = "0.6" rayon = "1.7" redox_syscall = "0.3" -regex = "1.9.3" +regex = "1.9.4" rstest = "0.18.2" rust-ini = "0.19.0" same-file = "1.0.6" From 70dd8eb8dcdfffa7b69a22bc9a3162408d912f84 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Sat, 26 Aug 2023 13:22:36 -0400 Subject: [PATCH 085/370] split: updates to target correct GNU coreutils release --- util/build-gnu.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 587cf8580..f6be73ff4 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -32,10 +32,16 @@ fi ### +release_tag_GNU="v9.3" + if test ! -d "${path_GNU}"; then echo "Could not find GNU coreutils (expected at '${path_GNU}')" echo "Run the following to download into the expected path:" echo "git clone --recurse-submodules https://github.com/coreutils/coreutils.git \"${path_GNU}\"" + echo "After downloading GNU coreutils to \"${path_GNU}\" run the following commands to cheout latest release tag" + echo "cd \"${path_GNU}\"" + echo "git fetch --all --tags" + echo "git checkout tags/\"${release_tag_GNU}\"" exit 1 fi @@ -152,17 +158,8 @@ sed -i -e '/tests\/misc\/invalid-opt.pl/ D' \ sed -i -e '/tests\/misc\/seq-precision.sh/ D' \ Makefile -# TODO: many files and some directories modified with 'sed' in the sections below either no longer exist or have been moved -# TODO: Might need to review and updated sections below -# TODO: As a result this script will fail when executed normally as 'bash util/build-gnu.hs' due to the 'set -e' set at the beginning -# TODO: The rest of the 'sed' commands after first failure in this scenario will not be executed as bash will exit on first error -# TODO: However, the behaviour might be different when running it via GitHub actions (GnuTests) -# TODO: For now, when running in local a workaround would be to comment out the 'set -e' at the beginning of the file - # printf doesn't limit the values used in its arg, so this produced ~2GB of output -# TODO: this is the first one to likely fail as tests/misc/printf.sh does not exist/have been moved sed -i '/INT_OFLOW/ D' tests/misc/printf.sh -# TODO: all commands below might not be executed # Use the system coreutils where the test fails due to error in a util that is not the one being tested sed -i 's|stat|/usr/bin/stat|' tests/touch/60-seconds.sh tests/misc/sort-compress-proc.sh From eac08f72c2ef97a7d7206fb3f98fc28a447172be Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Sat, 26 Aug 2023 13:24:08 -0400 Subject: [PATCH 086/370] split: double quotes --- util/build-gnu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index f6be73ff4..74ec29670 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -41,7 +41,7 @@ if test ! -d "${path_GNU}"; then echo "After downloading GNU coreutils to \"${path_GNU}\" run the following commands to cheout latest release tag" echo "cd \"${path_GNU}\"" echo "git fetch --all --tags" - echo "git checkout tags/\"${release_tag_GNU}\"" + echo "git checkout tags/${release_tag_GNU}" exit 1 fi From 4a4759c43c7cd10c81e53f9e352cd9f8f2a5fb63 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Sat, 26 Aug 2023 13:44:34 -0400 Subject: [PATCH 087/370] split: updated to SYSTEM_TIMEOUT in a few more places --- util/build-gnu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 74ec29670..4e196debe 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -173,10 +173,10 @@ sed -i 's|touch |/usr/bin/touch |' tests/cp/reflink-perm.sh tests/ls/block-size. sed -i 's|ln -|/usr/bin/ln -|' tests/cp/link-deref.sh sed -i 's|cp |/usr/bin/cp |' tests/mv/hard-2.sh sed -i 's|paste |/usr/bin/paste |' tests/misc/od-endian.sh -sed -i 's|timeout |/usr/bin/timeout |' tests/tail-2/follow-stdin.sh +sed -i 's|timeout |'"${SYSTEM_TIMEOUT}"' |' tests/tail-2/follow-stdin.sh # Add specific timeout to tests that currently hang to limit time spent waiting -sed -i 's|\(^\s*\)seq \$|\1/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh +sed -i 's|\(^\s*\)seq \$|\1'"${SYSTEM_TIMEOUT}"' 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh # Remove dup of /usr/bin/ when executed several times grep -rlE '/usr/bin/\s?/usr/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/bin/\s?/usr/bin/|/usr/bin/|g' From a384973b1a7e40435e165ab7a65a59ab26da7fd8 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Sat, 26 Aug 2023 13:51:21 -0400 Subject: [PATCH 088/370] split: remove dup for /usr/local/bin when executed several times --- util/build-gnu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 4e196debe..ce15dd3f8 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -180,6 +180,7 @@ sed -i 's|\(^\s*\)seq \$|\1'"${SYSTEM_TIMEOUT}"' 0.1 seq \$|' tests/misc/seq-pre # Remove dup of /usr/bin/ when executed several times grep -rlE '/usr/bin/\s?/usr/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/bin/\s?/usr/bin/|/usr/bin/|g' +grep -rlE '/usr/local/bin/\s?/usr/local/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/local/bin/\s?/usr/local/bin/|/usr/local/bin/|g' #### Adjust tests to make them work with Rust/coreutils # in some cases, what we are doing in rust/coreutils is good (or better) From 0edba89b55ba51d974c90645079454f128c2ae6b Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Sat, 26 Aug 2023 13:53:36 -0400 Subject: [PATCH 089/370] split: comments --- util/build-gnu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index ce15dd3f8..57764ed50 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -178,7 +178,7 @@ sed -i 's|timeout |'"${SYSTEM_TIMEOUT}"' |' tests/tail-2/follow-stdin.sh # Add specific timeout to tests that currently hang to limit time spent waiting sed -i 's|\(^\s*\)seq \$|\1'"${SYSTEM_TIMEOUT}"' 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh -# Remove dup of /usr/bin/ when executed several times +# Remove dup of /usr/bin/ and /usr/local/bin/ when executed several times grep -rlE '/usr/bin/\s?/usr/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/bin/\s?/usr/bin/|/usr/bin/|g' grep -rlE '/usr/local/bin/\s?/usr/local/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/local/bin/\s?/usr/local/bin/|/usr/local/bin/|g' From ab859f4efa4637e68b3d6a653a0ed44c2fe16da5 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Mon, 28 Aug 2023 00:19:10 +0200 Subject: [PATCH 090/370] cp: re-export uucore::{BackupMode, UpdateMode} This allows other projects to construct values for these types which in turn allows them to construct Options. This is implemented at the request of nushell --- src/uu/cp/src/cp.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index ce16357c6..e8beaef78 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -32,14 +32,16 @@ use libc::mkfifo; use quick_error::ResultExt; use platform::copy_on_write; -use uucore::backup_control::{self, BackupMode}; use uucore::display::Quotable; use uucore::error::{set_exit_code, UClapError, UError, UResult, UUsageError}; use uucore::fs::{ canonicalize, is_symlink_loop, paths_refer_to_same_file, FileInformation, MissingHandling, ResolveMode, }; -use uucore::update_control::{self, UpdateMode}; +use uucore::{backup_control, update_control}; +// These are exposed for projects (e.g. nushell) that want to create an `Options` value, which +// requires these enum. +pub use uucore::{backup_control::BackupMode, update_control::UpdateMode}; use uucore::{ crash, format_usage, help_about, help_section, help_usage, prompt_yes, show_error, show_warning, util_name, From 1eae064e5c68bb2de2738f295f443e91c6630e97 Mon Sep 17 00:00:00 2001 From: Yury Zhytkou <54360928+zhitkoff@users.noreply.github.com> Date: Mon, 28 Aug 2023 04:09:52 -0400 Subject: [PATCH 091/370] split: better handle numeric and hex suffixes, short and long, with and without values (#5198) * split: better handle numeric and hex suffixes, short and long, with and without values Fixes #5171 * refactoring with overrides_with_all() in args definitions * fixed comments * updated help on suffixes to match GNU * comments * refactor to remove value_parser() * split: refactor suffix processing + updated tests * split: minor formatting --- src/uu/split/src/split.rs | 105 ++++++++++++++------ tests/by-util/test_split.rs | 190 +++++++++++++++++++++++++++++++++++- 2 files changed, 263 insertions(+), 32 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 71aacfed0..517031791 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore nbbbb ncccc +// spell-checker:ignore nbbbb ncccc hexdigit mod filenames; mod number; @@ -11,8 +11,7 @@ mod platform; use crate::filenames::FilenameIterator; use crate::filenames::SuffixType; -use clap::ArgAction; -use clap::{crate_version, parser::ValueSource, Arg, ArgMatches, Command}; +use clap::{crate_version, parser::ValueSource, Arg, ArgAction, ArgMatches, Command}; use std::env; use std::fmt; use std::fs::{metadata, File}; @@ -32,7 +31,9 @@ static OPT_ADDITIONAL_SUFFIX: &str = "additional-suffix"; static OPT_FILTER: &str = "filter"; static OPT_NUMBER: &str = "number"; static OPT_NUMERIC_SUFFIXES: &str = "numeric-suffixes"; +static OPT_NUMERIC_SUFFIXES_SHORT: &str = "-d"; static OPT_HEX_SUFFIXES: &str = "hex-suffixes"; +static OPT_HEX_SUFFIXES_SHORT: &str = "-x"; static OPT_SUFFIX_LENGTH: &str = "suffix-length"; static OPT_DEFAULT_SUFFIX_LENGTH: &str = "0"; static OPT_VERBOSE: &str = "verbose"; @@ -122,12 +123,56 @@ pub fn uu_app() -> Command { .action(ArgAction::SetTrue), ) .arg( - Arg::new(OPT_NUMERIC_SUFFIXES) + Arg::new(OPT_NUMERIC_SUFFIXES_SHORT) .short('d') + .action(clap::ArgAction::SetTrue) + .overrides_with_all([ + OPT_NUMERIC_SUFFIXES, + OPT_NUMERIC_SUFFIXES_SHORT, + OPT_HEX_SUFFIXES, + OPT_HEX_SUFFIXES_SHORT + ]) + .help("use numeric suffixes starting at 0, not alphabetic"), + ) + .arg( + Arg::new(OPT_NUMERIC_SUFFIXES) .long(OPT_NUMERIC_SUFFIXES) + .require_equals(true) .default_missing_value("0") .num_args(0..=1) - .help("use numeric suffixes instead of alphabetic"), + .overrides_with_all([ + OPT_NUMERIC_SUFFIXES, + OPT_NUMERIC_SUFFIXES_SHORT, + OPT_HEX_SUFFIXES, + OPT_HEX_SUFFIXES_SHORT + ]) + .help("same as -d, but allow setting the start value"), + ) + .arg( + Arg::new(OPT_HEX_SUFFIXES_SHORT) + .short('x') + .action(clap::ArgAction::SetTrue) + .overrides_with_all([ + OPT_NUMERIC_SUFFIXES, + OPT_NUMERIC_SUFFIXES_SHORT, + OPT_HEX_SUFFIXES, + OPT_HEX_SUFFIXES_SHORT + ]) + .help("use hex suffixes starting at 0, not alphabetic"), + ) + .arg( + Arg::new(OPT_HEX_SUFFIXES) + .long(OPT_HEX_SUFFIXES) + .default_missing_value("0") + .require_equals(true) + .num_args(0..=1) + .overrides_with_all([ + OPT_NUMERIC_SUFFIXES, + OPT_NUMERIC_SUFFIXES_SHORT, + OPT_HEX_SUFFIXES, + OPT_HEX_SUFFIXES_SHORT + ]) + .help("same as -x, but allow setting the start value"), ) .arg( Arg::new(OPT_SUFFIX_LENGTH) @@ -137,14 +182,6 @@ pub fn uu_app() -> Command { .default_value(OPT_DEFAULT_SUFFIX_LENGTH) .help("use suffixes of fixed length N. 0 implies dynamic length."), ) - .arg( - Arg::new(OPT_HEX_SUFFIXES) - .short('x') - .long(OPT_HEX_SUFFIXES) - .default_missing_value("0") - .num_args(0..=1) - .help("use hex suffixes instead of alphabetic"), - ) .arg( Arg::new(OPT_VERBOSE) .long(OPT_VERBOSE) @@ -409,22 +446,32 @@ impl Strategy { /// Parse the suffix type from the command-line arguments. fn suffix_type_from(matches: &ArgMatches) -> Result<(SuffixType, usize), SettingsError> { - if matches.value_source(OPT_NUMERIC_SUFFIXES) == Some(ValueSource::CommandLine) { - let suffix_start = matches.get_one::(OPT_NUMERIC_SUFFIXES); - let suffix_start = suffix_start.ok_or(SettingsError::SuffixNotParsable(String::new()))?; - let suffix_start = suffix_start - .parse() - .map_err(|_| SettingsError::SuffixNotParsable(suffix_start.to_string()))?; - Ok((SuffixType::Decimal, suffix_start)) - } else if matches.value_source(OPT_HEX_SUFFIXES) == Some(ValueSource::CommandLine) { - let suffix_start = matches.get_one::(OPT_HEX_SUFFIXES); - let suffix_start = suffix_start.ok_or(SettingsError::SuffixNotParsable(String::new()))?; - let suffix_start = usize::from_str_radix(suffix_start, 16) - .map_err(|_| SettingsError::SuffixNotParsable(suffix_start.to_string()))?; - Ok((SuffixType::Hexadecimal, suffix_start)) - } else { - // no numeric/hex suffix - Ok((SuffixType::Alphabetic, 0)) + // Check if the user is specifying one or more than one suffix + // Any combination of suffixes is allowed + // Since all suffixes are setup with 'overrides_with_all()' against themselves and each other, + // last one wins, all others are ignored + match ( + matches.get_one::(OPT_NUMERIC_SUFFIXES), + matches.get_one::(OPT_HEX_SUFFIXES), + matches.get_flag(OPT_NUMERIC_SUFFIXES_SHORT), + matches.get_flag(OPT_HEX_SUFFIXES_SHORT), + ) { + (Some(v), _, _, _) => { + let suffix_start = v; + let suffix_start = suffix_start + .parse::() + .map_err(|_| SettingsError::SuffixNotParsable(suffix_start.to_string()))?; + Ok((SuffixType::Decimal, suffix_start)) + } + (_, Some(v), _, _) => { + let suffix_start = v; + let suffix_start = usize::from_str_radix(suffix_start, 16) + .map_err(|_| SettingsError::SuffixNotParsable(suffix_start.to_string()))?; + Ok((SuffixType::Hexadecimal, suffix_start)) + } + (_, _, true, _) => Ok((SuffixType::Decimal, 0)), // short numeric suffix '-d', default start 0 + (_, _, _, true) => Ok((SuffixType::Hexadecimal, 0)), // short hex suffix '-x', default start 0 + _ => Ok((SuffixType::Alphabetic, 0)), // no numeric/hex suffix, using default alphabetic } } diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index c5f32482e..f3317d4c7 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes threebytes asciilowercase fghij klmno pqrst uvwxyz fivelines twohundredfortyonebytes onehundredlines nbbbb +// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes threebytes asciilowercase fghij klmno pqrst uvwxyz fivelines twohundredfortyonebytes onehundredlines nbbbb dxen use crate::common::util::{AtPath, TestScenario}; use rand::{thread_rng, Rng, SeedableRng}; @@ -715,7 +715,7 @@ fn test_multiple_of_input_chunk() { #[test] fn test_numeric_suffix() { let (at, mut ucmd) = at_and_ucmd!(); - ucmd.args(&["-n", "4", "--numeric-suffixes", "9", "threebytes.txt"]) + ucmd.args(&["-n", "4", "--numeric-suffixes=9", "threebytes.txt"]) .succeeds() .no_stdout() .no_stderr(); @@ -728,7 +728,7 @@ fn test_numeric_suffix() { #[test] fn test_hex_suffix() { let (at, mut ucmd) = at_and_ucmd!(); - ucmd.args(&["-n", "4", "--hex-suffixes", "9", "threebytes.txt"]) + ucmd.args(&["-n", "4", "--hex-suffixes=9", "threebytes.txt"]) .succeeds() .no_stdout() .no_stderr(); @@ -738,6 +738,190 @@ fn test_hex_suffix() { assert_eq!(at.read("x0c"), ""); } +#[test] +fn test_numeric_suffix_no_equal() { + new_ucmd!() + .args(&["-n", "4", "--numeric-suffixes", "9", "threebytes.txt"]) + .fails() + .stderr_contains("split: cannot open '9' for reading: No such file or directory"); +} + +#[test] +fn test_hex_suffix_no_equal() { + new_ucmd!() + .args(&["-n", "4", "--hex-suffixes", "9", "threebytes.txt"]) + .fails() + .stderr_contains("split: cannot open '9' for reading: No such file or directory"); +} + +/// Test for short numeric suffix not having any value +#[test] +fn test_short_numeric_suffix_no_value() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-l", "9", "-d", "onehundredlines.txt"]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("x00"), "00\n01\n02\n03\n04\n05\n06\n07\n08\n"); + assert_eq!(at.read("x01"), "09\n10\n11\n12\n13\n14\n15\n16\n17\n"); + assert_eq!(at.read("x02"), "18\n19\n20\n21\n22\n23\n24\n25\n26\n"); + assert_eq!(at.read("x03"), "27\n28\n29\n30\n31\n32\n33\n34\n35\n"); + assert_eq!(at.read("x04"), "36\n37\n38\n39\n40\n41\n42\n43\n44\n"); + assert_eq!(at.read("x05"), "45\n46\n47\n48\n49\n50\n51\n52\n53\n"); + assert_eq!(at.read("x06"), "54\n55\n56\n57\n58\n59\n60\n61\n62\n"); + assert_eq!(at.read("x07"), "63\n64\n65\n66\n67\n68\n69\n70\n71\n"); + assert_eq!(at.read("x08"), "72\n73\n74\n75\n76\n77\n78\n79\n80\n"); + assert_eq!(at.read("x09"), "81\n82\n83\n84\n85\n86\n87\n88\n89\n"); + assert_eq!(at.read("x10"), "90\n91\n92\n93\n94\n95\n96\n97\n98\n"); + assert_eq!(at.read("x11"), "99\n"); +} + +/// Test for long numeric suffix not having any value +#[test] +fn test_numeric_suffix_no_value() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-l", "9", "--numeric-suffixes", "onehundredlines.txt"]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("x00"), "00\n01\n02\n03\n04\n05\n06\n07\n08\n"); + assert_eq!(at.read("x01"), "09\n10\n11\n12\n13\n14\n15\n16\n17\n"); + assert_eq!(at.read("x02"), "18\n19\n20\n21\n22\n23\n24\n25\n26\n"); + assert_eq!(at.read("x03"), "27\n28\n29\n30\n31\n32\n33\n34\n35\n"); + assert_eq!(at.read("x04"), "36\n37\n38\n39\n40\n41\n42\n43\n44\n"); + assert_eq!(at.read("x05"), "45\n46\n47\n48\n49\n50\n51\n52\n53\n"); + assert_eq!(at.read("x06"), "54\n55\n56\n57\n58\n59\n60\n61\n62\n"); + assert_eq!(at.read("x07"), "63\n64\n65\n66\n67\n68\n69\n70\n71\n"); + assert_eq!(at.read("x08"), "72\n73\n74\n75\n76\n77\n78\n79\n80\n"); + assert_eq!(at.read("x09"), "81\n82\n83\n84\n85\n86\n87\n88\n89\n"); + assert_eq!(at.read("x10"), "90\n91\n92\n93\n94\n95\n96\n97\n98\n"); + assert_eq!(at.read("x11"), "99\n"); +} + +/// Test for short hex suffix not having any value +#[test] +fn test_short_hex_suffix_no_value() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-l", "9", "-x", "onehundredlines.txt"]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("x00"), "00\n01\n02\n03\n04\n05\n06\n07\n08\n"); + assert_eq!(at.read("x01"), "09\n10\n11\n12\n13\n14\n15\n16\n17\n"); + assert_eq!(at.read("x02"), "18\n19\n20\n21\n22\n23\n24\n25\n26\n"); + assert_eq!(at.read("x03"), "27\n28\n29\n30\n31\n32\n33\n34\n35\n"); + assert_eq!(at.read("x04"), "36\n37\n38\n39\n40\n41\n42\n43\n44\n"); + assert_eq!(at.read("x05"), "45\n46\n47\n48\n49\n50\n51\n52\n53\n"); + assert_eq!(at.read("x06"), "54\n55\n56\n57\n58\n59\n60\n61\n62\n"); + assert_eq!(at.read("x07"), "63\n64\n65\n66\n67\n68\n69\n70\n71\n"); + assert_eq!(at.read("x08"), "72\n73\n74\n75\n76\n77\n78\n79\n80\n"); + assert_eq!(at.read("x09"), "81\n82\n83\n84\n85\n86\n87\n88\n89\n"); + assert_eq!(at.read("x0a"), "90\n91\n92\n93\n94\n95\n96\n97\n98\n"); + assert_eq!(at.read("x0b"), "99\n"); +} + +/// Test for long hex suffix not having any value +#[test] +fn test_hex_suffix_no_value() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-l", "9", "--hex-suffixes", "onehundredlines.txt"]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("x00"), "00\n01\n02\n03\n04\n05\n06\n07\n08\n"); + assert_eq!(at.read("x01"), "09\n10\n11\n12\n13\n14\n15\n16\n17\n"); + assert_eq!(at.read("x02"), "18\n19\n20\n21\n22\n23\n24\n25\n26\n"); + assert_eq!(at.read("x03"), "27\n28\n29\n30\n31\n32\n33\n34\n35\n"); + assert_eq!(at.read("x04"), "36\n37\n38\n39\n40\n41\n42\n43\n44\n"); + assert_eq!(at.read("x05"), "45\n46\n47\n48\n49\n50\n51\n52\n53\n"); + assert_eq!(at.read("x06"), "54\n55\n56\n57\n58\n59\n60\n61\n62\n"); + assert_eq!(at.read("x07"), "63\n64\n65\n66\n67\n68\n69\n70\n71\n"); + assert_eq!(at.read("x08"), "72\n73\n74\n75\n76\n77\n78\n79\n80\n"); + assert_eq!(at.read("x09"), "81\n82\n83\n84\n85\n86\n87\n88\n89\n"); + assert_eq!(at.read("x0a"), "90\n91\n92\n93\n94\n95\n96\n97\n98\n"); + assert_eq!(at.read("x0b"), "99\n"); +} + +/// Test for short numeric suffix having value provided after space - should fail +#[test] +fn test_short_numeric_suffix_with_value_spaced() { + new_ucmd!() + .args(&["-n", "4", "-d", "9", "threebytes.txt"]) + .fails() + .stderr_contains("split: cannot open '9' for reading: No such file or directory"); +} + +/// Test for short numeric suffix having value provided after space - should fail +#[test] +fn test_short_hex_suffix_with_value_spaced() { + new_ucmd!() + .args(&["-n", "4", "-x", "9", "threebytes.txt"]) + .fails() + .stderr_contains("split: cannot open '9' for reading: No such file or directory"); +} + +/// Test for some combined short options +#[test] +fn test_short_combination() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-dxen", "4", "threebytes.txt"]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("x00"), "a"); + assert_eq!(at.read("x01"), "b"); + assert_eq!(at.read("x02"), "c"); + assert_eq!(at.file_exists("x03"), false); +} + +/// Test for the last effective suffix, ignoring all others - numeric long last +/// Any combination of short and long (as well as duplicates) should be allowed +#[test] +fn test_effective_suffix_numeric_last() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&[ + "-n", + "4", + "--numeric-suffixes=7", + "--hex-suffixes=4", + "-d", + "-x", + "--numeric-suffixes=9", + "threebytes.txt", + ]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("x09"), "a"); + assert_eq!(at.read("x10"), "b"); + assert_eq!(at.read("x11"), "c"); + assert_eq!(at.read("x12"), ""); +} + +/// Test for the last effective suffix, ignoring all others - hex long last +/// Any combination of short and long (as well as duplicates) should be allowed +#[test] +fn test_effective_suffix_hex_last() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&[ + "-n", + "4", + "--hex-suffixes=7", + "--numeric-suffixes=4", + "-x", + "-d", + "--hex-suffixes=9", + "threebytes.txt", + ]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("x09"), "a"); + assert_eq!(at.read("x0a"), "b"); + assert_eq!(at.read("x0b"), "c"); + assert_eq!(at.read("x0c"), ""); +} + #[test] fn test_round_robin() { let (at, mut ucmd) = at_and_ucmd!(); From 71c4d9f407b3487e43ca76dc92768495cdc98fe9 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Mon, 28 Aug 2023 10:36:01 +0200 Subject: [PATCH 092/370] website: fix changelog config --- oranda.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/oranda.json b/oranda.json index 7c52ddc27..0a6856a88 100644 --- a/oranda.json +++ b/oranda.json @@ -6,7 +6,9 @@ "path_prefix": "coreutils" }, "components": { - "changelog": true + "changelog": { + "read_changelog_file": false + } }, "styles": { "theme": "light", From 4623575a6641bba9c4b45303d28386f7e92cc2b1 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Mon, 28 Aug 2023 22:51:45 +0200 Subject: [PATCH 093/370] echo: fix wrapping behavior of octal sequences --- src/uu/echo/src/echo.rs | 109 ++++++++++++++++++------------------- tests/by-util/test_echo.rs | 17 ++++++ 2 files changed, 71 insertions(+), 55 deletions(-) diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index cd9467714..4aba703a1 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -21,73 +21,72 @@ mod options { pub const DISABLE_BACKSLASH_ESCAPE: &str = "disable_backslash_escape"; } -fn parse_code( - input: &mut Peekable, - base: u32, - max_digits: u32, - bits_per_digit: u32, -) -> Option { - let mut ret = 0x8000_0000; - for _ in 0..max_digits { - match input.peek().and_then(|c| c.to_digit(base)) { - Some(n) => ret = (ret << bits_per_digit) | n, +/// Parse the numeric part of the `\xHHH` and `\0NNN` escape sequences +fn parse_code(input: &mut Peekable, base: u8, max_digits: u32) -> Option { + // All arithmetic on `ret` needs to be wrapping, because octal input can + // take 3 digits, which is 9 bits, and therefore more than what fits in a + // `u8`. GNU just seems to wrap these values. + // Note that if we instead make `ret` a `u32` and use `char::from_u32` will + // yield incorrect results because it will interpret values larger than + // `u8::MAX` as unicode. + let mut ret = input.peek().and_then(|c| c.to_digit(base as u32))? as u8; + + // We can safely ifgnore the None case because we just peeked it. + let _ = input.next(); + + for _ in 1..max_digits { + match input.peek().and_then(|c| c.to_digit(base as u32)) { + Some(n) => ret = ret.wrapping_mul(base).wrapping_add(n as u8), None => break, } - input.next(); + // We can safely ifgnore the None case because we just peeked it. + let _ = input.next(); } - std::char::from_u32(ret) + + Some(ret.into()) } fn print_escaped(input: &str, mut output: impl Write) -> io::Result { - let mut should_stop = false; - - let mut buffer = ['\\'; 2]; - - // TODO `cargo +nightly clippy` complains that `.peek()` is never - // called on `iter`. However, `peek()` is called inside the - // `parse_code()` function that borrows `iter`. let mut iter = input.chars().peekable(); - while let Some(mut c) = iter.next() { - let mut start = 1; - - if c == '\\' { - if let Some(next) = iter.next() { - c = match next { - '\\' => '\\', - 'a' => '\x07', - 'b' => '\x08', - 'c' => { - should_stop = true; - break; - } - 'e' => '\x1b', - 'f' => '\x0c', - 'n' => '\n', - 'r' => '\r', - 't' => '\t', - 'v' => '\x0b', - 'x' => parse_code(&mut iter, 16, 2, 4).unwrap_or_else(|| { - start = 0; - next - }), - '0' => parse_code(&mut iter, 8, 3, 3).unwrap_or('\0'), - _ => { - start = 0; - next - } - }; - } + while let Some(c) = iter.next() { + if c != '\\' { + write!(output, "{c}")?; + continue; } - buffer[1] = c; - - // because printing char slices is apparently not available in the standard library - for ch in &buffer[start..] { - write!(output, "{ch}")?; + if let Some(next) = iter.next() { + let unescaped = match next { + '\\' => '\\', + 'a' => '\x07', + 'b' => '\x08', + 'c' => return Ok(true), + 'e' => '\x1b', + 'f' => '\x0c', + 'n' => '\n', + 'r' => '\r', + 't' => '\t', + 'v' => '\x0b', + 'x' => { + if let Some(c) = parse_code(&mut iter, 16, 2) { + c + } else { + write!(output, "\\")?; + 'x' + } + } + '0' => parse_code(&mut iter, 8, 3).unwrap_or('\0'), + c => { + write!(output, "\\")?; + c + } + }; + write!(output, "{unescaped}")?; + } else { + write!(output, "\\")?; } } - Ok(should_stop) + Ok(false) } #[uucore::main] diff --git a/tests/by-util/test_echo.rs b/tests/by-util/test_echo.rs index 3a8e7f86b..82137c715 100644 --- a/tests/by-util/test_echo.rs +++ b/tests/by-util/test_echo.rs @@ -236,3 +236,20 @@ fn test_hyphen_values_between() { .success() .stdout_is("dumdum dum dum dum -e dum\n"); } + +#[test] +fn wrapping_octal() { + // Some odd behavior of GNU. Values of \0400 and greater do not fit in the + // u8 that we write to stdout. So we test that it wraps: + // + // We give it this input: + // \o501 = 1_0100_0001 (yes, **9** bits) + // This should be wrapped into: + // \o101 = 'A' = 0100_0001, + // because we only write a single character + new_ucmd!() + .arg("-e") + .arg("\\0501") + .succeeds() + .stdout_is("A\n"); +} From 2f35989ac34cda92b65328d325bdc615057e2dbe Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Mon, 28 Aug 2023 18:26:48 -0400 Subject: [PATCH 094/370] split: comments --- src/uu/split/src/split.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 77c87e7f5..698c7818c 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -108,7 +108,6 @@ fn handle_obsolete(args: &[String]) -> (Vec, Option) { v.push(arg.to_owned()); } } - // println!("{:#?} , {:#?}", v, obs_lines); (v, obs_lines) } @@ -465,8 +464,7 @@ impl Strategy { // Check that the user is not specifying more than one strategy. // // Note: right now, this exact behavior cannot be handled by - // `ArgGroup` since `ArgGroup` considers a default value `Arg` - // as "defined". + // overrides_with_all() due to obsolete lines value option match ( obs_lines, matches.value_source(OPT_LINES) == Some(ValueSource::CommandLine), From 93a54f36f3e71c06cdf13d6bd7cabb5645d0c480 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Mon, 28 Aug 2023 23:34:16 +0200 Subject: [PATCH 095/370] hashsum: change debug to display format with --tag --- src/uu/hashsum/src/hashsum.rs | 2 +- tests/by-util/test_hashsum.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index 1931c7d79..f8f00f011 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -744,7 +744,7 @@ where ) .map_err_context(|| "failed to read input".to_string())?; if options.tag { - println!("{} ({:?}) = {}", options.algoname, filename.display(), sum); + println!("{} ({}) = {}", options.algoname, filename.display(), sum); } else if options.nonames { println!("{sum}"); } else if options.zero { diff --git a/tests/by-util/test_hashsum.rs b/tests/by-util/test_hashsum.rs index 4bf06308d..31471495b 100644 --- a/tests/by-util/test_hashsum.rs +++ b/tests/by-util/test_hashsum.rs @@ -355,3 +355,19 @@ fn test_check_md5sum_mixed_format() { fn test_invalid_arg() { new_ucmd!().arg("--definitely-invalid").fails().code_is(1); } + +#[test] +fn test_tag() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + at.write("foobar", "foo bar\n"); + scene + .ccmd("sha256sum") + .arg("--tag") + .arg("foobar") + .succeeds() + .stdout_is( + "SHA256 (foobar) = 1f2ec52b774368781bed1d1fb140a92e0eb6348090619c9291f9a5a3c8e8d151\n", + ); +} From 0aeed9310061ae862cc890d8910a8893e8c26154 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:51:18 +0000 Subject: [PATCH 096/370] chore(deps): update rust crate chrono to ^0.4.27 --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f538cb841..9b1b3ade3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -240,14 +240,14 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "f56b4c72906975ca04becb8a30e102dfecddd0c06181e3e95ddc444be28881f8" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "winapi", + "windows-targets 0.48.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 7a10995ef..6b381cccb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -263,7 +263,7 @@ binary-heap-plus = "0.5.0" bstr = "1.6" bytecount = "0.6.3" byteorder = "1.4.3" -chrono = { version = "^0.4.26", default-features = false, features = [ +chrono = { version = "^0.4.27", default-features = false, features = [ "std", "alloc", "clock", From 837e0681af73be25fe7f9bf533b232f534a71887 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 29 Aug 2023 19:29:35 +0200 Subject: [PATCH 097/370] upgrade to GNU/coreutils 9.4 --- .github/workflows/GnuTests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/GnuTests.yml b/.github/workflows/GnuTests.yml index eb3e22a80..ccb5a6f74 100644 --- a/.github/workflows/GnuTests.yml +++ b/.github/workflows/GnuTests.yml @@ -42,7 +42,7 @@ jobs: outputs path_GNU path_GNU_tests path_reference path_UUTILS # repo_default_branch="${{ github.event.repository.default_branch }}" - repo_GNU_ref="v9.3" + repo_GNU_ref="v9.4" repo_reference_branch="${{ github.event.repository.default_branch }}" outputs repo_default_branch repo_GNU_ref repo_reference_branch # @@ -315,7 +315,7 @@ jobs: with: repository: 'coreutils/coreutils' path: 'gnu' - ref: 'v9.3' + ref: 'v9.4' submodules: recursive - uses: dtolnay/rust-toolchain@master with: From e79753c1cf25db25104e853e52e7f687dd776cfb Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Tue, 29 Aug 2023 13:58:26 -0400 Subject: [PATCH 098/370] split: refactor handle_obsolete() function --- src/uu/split/src/split.rs | 73 +++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 698c7818c..876d04606 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -72,43 +72,50 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { /// `split -x300e -22 file` would mean `split -x -e -l 22 file` (last obsolete lines option wins) /// following GNU `split` behavior fn handle_obsolete(args: &[String]) -> (Vec, Option) { - let mut v: Vec = vec![]; let mut obs_lines = None; - for arg in args.iter() { - let slice = &arg; - if slice.starts_with('-') && !slice.starts_with("--") { - // start of the short option string - // extract numeric part and filter it out - let mut obs_lines_extracted: Vec = vec![]; - let filtered_slice: Vec = slice - .chars() - .filter(|c| { - if c.is_ascii_digit() { - obs_lines_extracted.push(*c); - false - } else { - true - } - }) - .collect(); + let filtered_args = args + .iter() + .filter_map(|slice| { + if slice.starts_with('-') && !slice.starts_with("--") { + // start of the short option string + // extract numeric part and filter it out + let mut obs_lines_extracted: Vec = vec![]; + let filtered_slice: Vec = slice + .chars() + .filter(|c| { + if c.is_ascii_digit() { + obs_lines_extracted.push(*c); + false + } else { + true + } + }) + .collect(); - if filtered_slice.get(1).is_some() { - // there were some short options in front of obsolete lines number - // i.e. '-xd100' or similar + if obs_lines_extracted.is_empty() { + // no obsolete lines value found/extracted + Some(slice.to_owned()) + } else { + // obsolete lines value was extracted + obs_lines = Some(obs_lines_extracted.iter().collect()); + if filtered_slice.get(1).is_some() { + // there were some short options in front of or after obsolete lines value + // i.e. '-xd100' or '-100de' or similar, which after extraction of obsolete lines value + // would look like '-xd' or '-de' or similar + // preserve it + Some(filtered_slice.iter().collect()) + } else { + None + } + } + } else { + // not a short option // preserve it - v.push(filtered_slice.iter().collect()); + Some(slice.to_owned()) } - if !obs_lines_extracted.is_empty() { - // obsolete lines value was extracted - obs_lines = Some(obs_lines_extracted.iter().collect()); - } - } else { - // not a short option - // preserve it - v.push(arg.to_owned()); - } - } - (v, obs_lines) + }) + .collect(); + (filtered_args, obs_lines) } pub fn uu_app() -> Command { From 15c7170d20c532889ac8f3470c5d59bc12d10f2a Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Tue, 29 Aug 2023 15:49:47 -0400 Subject: [PATCH 099/370] split: fix for GNU Tests regression + tests --- src/uu/split/src/split.rs | 15 ++++++--- tests/by-util/test_split.rs | 65 +++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 4 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 876d04606..dae24d36b 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -76,8 +76,16 @@ fn handle_obsolete(args: &[String]) -> (Vec, Option) { let filtered_args = args .iter() .filter_map(|slice| { - if slice.starts_with('-') && !slice.starts_with("--") { + if slice.starts_with('-') + && !slice.starts_with("--") + && !slice.starts_with("-a") + && !slice.starts_with("-b") + && !slice.starts_with("-C") + && !slice.starts_with("-l") + && !slice.starts_with("-n") + { // start of the short option string + // that can have obsolete lines option value in it // extract numeric part and filter it out let mut obs_lines_extracted: Vec = vec![]; let filtered_slice: Vec = slice @@ -102,15 +110,14 @@ fn handle_obsolete(args: &[String]) -> (Vec, Option) { // there were some short options in front of or after obsolete lines value // i.e. '-xd100' or '-100de' or similar, which after extraction of obsolete lines value // would look like '-xd' or '-de' or similar - // preserve it Some(filtered_slice.iter().collect()) } else { None } } } else { - // not a short option - // preserve it + // either not a short option + // or a short option that cannot have obsolete lines value in it Some(slice.to_owned()) } }) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index aabfcbe90..9fba2177e 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -170,6 +170,22 @@ fn test_split_str_prefixed_chunks_by_bytes() { assert_eq!(glob.collate(), at.read_bytes(name)); } +// Test short bytes option concatenated with value +#[test] +fn test_split_by_bytes_short_concatenated_with_value() { + let (at, mut ucmd) = at_and_ucmd!(); + let name = "split_by_bytes_short_concatenated_with_value"; + RandomFile::new(&at, name).add_bytes(10000); + ucmd.args(&["-b1000", name]).succeeds(); + + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 10); + for filename in glob.collect() { + assert_eq!(glob.directory.metadata(&filename).len(), 1000); + } + assert_eq!(glob.collate(), at.read_bytes(name)); +} + // This is designed to test what happens when the desired part size is not a // multiple of the buffer size and we hopefully don't overshoot the desired part // size. @@ -326,6 +342,19 @@ fn test_split_lines_number() { .stderr_only("split: invalid number of lines: 'file'\n"); } +// Test short lines option with value concatenated +#[test] +fn test_split_lines_short_concatenated_with_value() { + let (at, mut ucmd) = at_and_ucmd!(); + let name = "split_num_prefixed_chunks_by_lines"; + RandomFile::new(&at, name).add_lines(10000); + ucmd.args(&["-l1000", name]).succeeds(); + + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 10); + assert_eq!(glob.collate(), at.read_bytes(name)); +} + /// Test for obsolete lines option standalone #[test] fn test_split_obs_lines_standalone() { @@ -692,6 +721,19 @@ fn test_invalid_suffix_length() { .stderr_contains("invalid suffix length: 'xyz'"); } +// Test short suffix length option with value concatenated +#[test] +fn test_split_suffix_length_short_concatenated_with_value() { + let (at, mut ucmd) = at_and_ucmd!(); + let name = "split_num_prefixed_chunks_by_lines"; + RandomFile::new(&at, name).add_lines(10000); + ucmd.args(&["-a4", name]).succeeds(); + + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]][[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 10); + assert_eq!(glob.collate(), at.read_bytes(name)); +} + #[test] fn test_include_newlines() { let (at, mut ucmd) = at_and_ucmd!(); @@ -710,6 +752,19 @@ fn test_include_newlines() { assert_eq!(s, "5\n"); } +// Test short number of chunks option concatenated with value +#[test] +fn test_split_number_chunks_short_concatenated_with_value() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-n3", "threebytes.txt"]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("xaa"), "a"); + assert_eq!(at.read("xab"), "b"); + assert_eq!(at.read("xac"), "c"); +} + #[test] fn test_allow_empty_files() { let (at, mut ucmd) = at_and_ucmd!(); @@ -784,6 +839,16 @@ fn test_line_bytes() { assert_eq!(at.read("xad"), "ee\n"); } +#[test] +fn test_line_bytes_concatenated_with_value() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-C8", "letters.txt"]).succeeds(); + assert_eq!(at.read("xaa"), "aaaaaaaa"); + assert_eq!(at.read("xab"), "a\nbbbb\n"); + 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!(); From 1ad10dd371cfe341993c23d302c7a002a85953ae Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Tue, 29 Aug 2023 21:54:19 +0200 Subject: [PATCH 100/370] echo: add support for \NNN octal escape sequence --- src/uu/echo/src/echo.rs | 10 ++++++++++ tests/by-util/test_echo.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index 4aba703a1..565166842 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -54,6 +54,16 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result { continue; } + // This is for the \NNN syntax for octal sequences. + // Note that '0' is intentionally omitted because that + // would be the \0NNN syntax. + if let Some('1'..='8') = iter.peek() { + if let Some(parsed) = parse_code(&mut iter, 8, 3) { + write!(output, "{parsed}")?; + continue; + } + } + if let Some(next) = iter.next() { let unescaped = match next { '\\' => '\\', diff --git a/tests/by-util/test_echo.rs b/tests/by-util/test_echo.rs index 82137c715..7de963973 100644 --- a/tests/by-util/test_echo.rs +++ b/tests/by-util/test_echo.rs @@ -253,3 +253,30 @@ fn wrapping_octal() { .succeeds() .stdout_is("A\n"); } + +#[test] +fn old_octal_syntax() { + new_ucmd!() + .arg("-e") + .arg("\\1foo") + .succeeds() + .stdout_is("\x01foo\n"); + + new_ucmd!() + .arg("-e") + .arg("\\43foo") + .succeeds() + .stdout_is("#foo\n"); + + new_ucmd!() + .arg("-e") + .arg("\\101foo") + .succeeds() + .stdout_is("Afoo\n"); + + new_ucmd!() + .arg("-e") + .arg("\\1011") + .succeeds() + .stdout_is("A1\n"); +} From 7f905a3b8d6d08c271d71b25dcba3d9559f83959 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Tue, 29 Aug 2023 16:35:00 -0400 Subject: [PATCH 101/370] split: edge case for obs lines within combined shorts + test --- src/uu/split/src/split.rs | 9 ++++++++- tests/by-util/test_split.rs | 21 +++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index dae24d36b..afe635456 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -88,13 +88,20 @@ fn handle_obsolete(args: &[String]) -> (Vec, Option) { // that can have obsolete lines option value in it // extract numeric part and filter it out let mut obs_lines_extracted: Vec = vec![]; + let mut obs_lines_end_reached = false; let filtered_slice: Vec = slice .chars() .filter(|c| { - if c.is_ascii_digit() { + // To correctly process scenario like '-x200a4' + // we need to stop extracting digits once alphabetic character is encountered + // after we already have something in obs_lines_extracted + if c.is_ascii_digit() && !obs_lines_end_reached { obs_lines_extracted.push(*c); false } else { + if !obs_lines_extracted.is_empty() { + obs_lines_end_reached = true; + } true } }) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 9fba2177e..3280fff67 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -170,7 +170,7 @@ fn test_split_str_prefixed_chunks_by_bytes() { assert_eq!(glob.collate(), at.read_bytes(name)); } -// Test short bytes option concatenated with value +/// Test short bytes option concatenated with value #[test] fn test_split_by_bytes_short_concatenated_with_value() { let (at, mut ucmd) = at_and_ucmd!(); @@ -342,7 +342,7 @@ fn test_split_lines_number() { .stderr_only("split: invalid number of lines: 'file'\n"); } -// Test short lines option with value concatenated +/// Test short lines option with value concatenated #[test] fn test_split_lines_short_concatenated_with_value() { let (at, mut ucmd) = at_and_ucmd!(); @@ -401,6 +401,19 @@ fn test_split_obs_lines_within_combined_shorts() { assert_eq!(glob.collate(), at.read_bytes(name)) } +/// Test for obsolete lines option as part of combined short options with tailing suffix length with value +#[test] +fn test_split_obs_lines_within_combined_shorts_tailing_suffix_length() { + let (at, mut ucmd) = at_and_ucmd!(); + let name = "obs-lines-combined-shorts-tailing-suffix-length"; + RandomFile::new(&at, name).add_lines(1000); + ucmd.args(&["-d200a4", name]).succeeds(); + + let glob = Glob::new(&at, ".", r"x\d\d\d\d$"); + assert_eq!(glob.count(), 5); + assert_eq!(glob.collate(), at.read_bytes(name)); +} + /// Test for obsolete lines option starts as part of combined short options #[test] fn test_split_obs_lines_starts_combined_shorts() { @@ -721,7 +734,7 @@ fn test_invalid_suffix_length() { .stderr_contains("invalid suffix length: 'xyz'"); } -// Test short suffix length option with value concatenated +/// Test short suffix length option with value concatenated #[test] fn test_split_suffix_length_short_concatenated_with_value() { let (at, mut ucmd) = at_and_ucmd!(); @@ -752,7 +765,7 @@ fn test_include_newlines() { assert_eq!(s, "5\n"); } -// Test short number of chunks option concatenated with value +/// Test short number of chunks option concatenated with value #[test] fn test_split_number_chunks_short_concatenated_with_value() { let (at, mut ucmd) = at_and_ucmd!(); From cf91a1cc95eb322476c8217be5d8e0795565754b Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 29 Aug 2023 21:41:42 +0200 Subject: [PATCH 102/370] Adjust the paths to the path after the 9.4 release --- util/build-gnu.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index d852ed66f..19e307ab6 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -130,33 +130,33 @@ grep -rl 'path_prepend_' tests/* | xargs sed -i 's| path_prepend_ ./src||' # Remove tests checking for --version & --help # Not really interesting for us and logs are too big sed -i -e '/tests\/misc\/invalid-opt.pl/ D' \ - -e '/tests\/misc\/help-version.sh/ D' \ - -e '/tests\/misc\/help-version-getopt.sh/ D' \ + -e '/tests\/help\/help-version.sh/ D' \ + -e '/tests\/test\/help-version-getopt.sh/ D' \ Makefile # logs are clotted because of this test -sed -i -e '/tests\/misc\/seq-precision.sh/ D' \ +sed -i -e '/tests\/seq\/seq-precision.sh/ D' \ Makefile # printf doesn't limit the values used in its arg, so this produced ~2GB of output -sed -i '/INT_OFLOW/ D' tests/misc/printf.sh +sed -i '/INT_OFLOW/ D' tests/printf/printf.sh # Use the system coreutils where the test fails due to error in a util that is not the one being tested -sed -i 's|stat|/usr/bin/stat|' tests/touch/60-seconds.sh tests/misc/sort-compress-proc.sh +sed -i 's|stat|/usr/bin/stat|' tests/touch/60-seconds.sh tests/sort/sort-compress-proc.sh sed -i 's|ls -|/usr/bin/ls -|' tests/cp/same-file.sh tests/misc/mknod.sh tests/mv/part-symlink.sh -sed -i 's|chmod |/usr/bin/chmod |' tests/du/inacc-dir.sh tests/tail-2/tail-n0f.sh tests/cp/fail-perm.sh tests/mv/i-2.sh tests/misc/shuf.sh -sed -i 's|sort |/usr/bin/sort |' tests/ls/hyperlink.sh tests/misc/test-N.sh -sed -i 's|split |/usr/bin/split |' tests/misc/factor-parallel.sh -sed -i 's|id -|/usr/bin/id -|' tests/misc/runcon-no-reorder.sh +sed -i 's|chmod |/usr/bin/chmod |' tests/du/inacc-dir.sh tests/tail/tail-n0f.sh tests/cp/fail-perm.sh tests/mv/i-2.sh tests/shuf/shuf.sh +sed -i 's|sort |/usr/bin/sort |' tests/ls/hyperlink.sh tests/test/test-N.sh +sed -i 's|split |/usr/bin/split |' tests/factor/factor-parallel.sh +sed -i 's|id -|/usr/bin/id -|' tests/runcon/runcon-no-reorder.sh # tests/ls/abmon-align.sh - https://github.com/uutils/coreutils/issues/3505 -sed -i 's|touch |/usr/bin/touch |' tests/cp/reflink-perm.sh tests/ls/block-size.sh tests/mv/update.sh tests/misc/ls-time.sh tests/misc/stat-nanoseconds.sh tests/misc/time-style.sh tests/misc/test-N.sh tests/ls/abmon-align.sh +sed -i 's|touch |/usr/bin/touch |' tests/cp/reflink-perm.sh tests/ls/block-size.sh tests/mv/update.sh tests/ls/ls-time.sh tests/stat/stat-nanoseconds.sh tests/misc/time-style.sh tests/test/test-N.sh tests/ls/abmon-align.sh sed -i 's|ln -|/usr/bin/ln -|' tests/cp/link-deref.sh sed -i 's|cp |/usr/bin/cp |' tests/mv/hard-2.sh -sed -i 's|paste |/usr/bin/paste |' tests/misc/od-endian.sh -sed -i 's|timeout |/usr/bin/timeout |' tests/tail-2/follow-stdin.sh +sed -i 's|paste |/usr/bin/paste |' tests/od/od-endian.sh +sed -i 's|timeout |/usr/bin/timeout |' tests/tail/follow-stdin.sh # Add specific timeout to tests that currently hang to limit time spent waiting -sed -i 's|\(^\s*\)seq \$|\1/usr/bin/timeout 0.1 seq \$|' tests/misc/seq-precision.sh tests/misc/seq-long-double.sh +sed -i 's|\(^\s*\)seq \$|\1/usr/bin/timeout 0.1 seq \$|' tests/seq/seq-precision.sh tests/seq/seq-long-double.sh # Remove dup of /usr/bin/ when executed several times grep -rlE '/usr/bin/\s?/usr/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/bin/\s?/usr/bin/|/usr/bin/|g' @@ -181,7 +181,7 @@ sed -i -e "s|rm: cannot remove 'rel': Permission denied|rm: cannot remove 'rel': # overlay-headers.sh test intends to check for inotify events, # however there's a bug because `---dis` is an alias for: `---disable-inotify` -sed -i -e "s|---dis ||g" tests/tail-2/overlay-headers.sh +sed -i -e "s|---dis ||g" tests/tail/overlay-headers.sh test -f "${UU_BUILD_DIR}/getlimits" || cp src/getlimits "${UU_BUILD_DIR}" @@ -238,11 +238,11 @@ sed -i -e "s/Try 'mv --help' for more information/For more information, try '--h # GNU doesn't support width > INT_MAX # disable these test cases -sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/misc/printf-cov.pl +sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/printf/printf-cov.pl sed -i -e "s/du: invalid -t argument/du: invalid --threshold argument/" -e "s/du: option requires an argument/error: a value is required for '--threshold ' but none was supplied/" -e "/Try 'du --help' for more information./d" tests/du/threshold.sh # disable two kind of tests: # "hostid BEFORE --help" doesn't fail for GNU. we fail. we are probably doing better # "hostid BEFORE --help AFTER " same for this -sed -i -e "s/env \$prog \$BEFORE \$opt > out2/env \$prog \$BEFORE \$opt > out2 #/" -e "s/env \$prog \$BEFORE \$opt AFTER > out3/env \$prog \$BEFORE \$opt AFTER > out3 #/" -e "s/compare exp out2/compare exp out2 #/" -e "s/compare exp out3/compare exp out3 #/" tests/misc/help-version-getopt.sh +sed -i -e "s/env \$prog \$BEFORE \$opt > out2/env \$prog \$BEFORE \$opt > out2 #/" -e "s/env \$prog \$BEFORE \$opt AFTER > out3/env \$prog \$BEFORE \$opt AFTER > out3 #/" -e "s/compare exp out2/compare exp out2 #/" -e "s/compare exp out3/compare exp out3 #/" tests/help/help-version-getopt.sh From ef564d2cd1cadcca1ec3e3f4a622520c572b79fb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 30 Aug 2023 07:46:54 +0000 Subject: [PATCH 103/370] chore(deps): update davidanson/markdownlint-cli2-action action to v12 --- .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 78b1faa55..fe72de110 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -326,7 +326,7 @@ jobs: shell: bash run: | RUSTDOCFLAGS="-Dwarnings" cargo doc ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --no-deps --workspace --document-private-items - - uses: DavidAnson/markdownlint-cli2-action@v11 + - uses: DavidAnson/markdownlint-cli2-action@v12 with: command: fix globs: | From 3e953779ae8af10959a7ace729413bc285d893d3 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 30 Aug 2023 10:30:36 +0200 Subject: [PATCH 104/370] Update util/build-gnu.sh Co-authored-by: Daniel Hofstetter --- util/build-gnu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 19e307ab6..a3dd0b9ad 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -131,7 +131,7 @@ grep -rl 'path_prepend_' tests/* | xargs sed -i 's| path_prepend_ ./src||' # Not really interesting for us and logs are too big sed -i -e '/tests\/misc\/invalid-opt.pl/ D' \ -e '/tests\/help\/help-version.sh/ D' \ - -e '/tests\/test\/help-version-getopt.sh/ D' \ + -e '/tests\/help\/help-version-getopt.sh/ D' \ Makefile # logs are clotted because of this test From b2ebe6a1d180fca68b5891ecf542f956e7df8331 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 30 Aug 2023 11:15:11 -0400 Subject: [PATCH 105/370] build-gnu.sh: target GNU release v9.4 --- util/build-gnu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index a6d8de29e..21a231bc0 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -32,7 +32,7 @@ fi ### -release_tag_GNU="v9.3" +release_tag_GNU="v9.4" if test ! -d "${path_GNU}"; then echo "Could not find GNU coreutils (expected at '${path_GNU}')" From 9a67393c444891f989949cb02005ccf9b33af2d4 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Wed, 30 Aug 2023 17:46:09 +0200 Subject: [PATCH 106/370] factor: short circuit on write error, but not on parse error --- src/uu/factor/src/cli.rs | 57 ++++++++++++++++-------------------- tests/by-util/test_factor.rs | 31 ++++++++++++++++++++ 2 files changed, 56 insertions(+), 32 deletions(-) diff --git a/src/uu/factor/src/cli.rs b/src/uu/factor/src/cli.rs index bfc4ede15..63a0632a3 100644 --- a/src/uu/factor/src/cli.rs +++ b/src/uu/factor/src/cli.rs @@ -3,8 +3,6 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use std::error::Error; -use std::fmt::Write as FmtWrite; use std::io::BufRead; use std::io::{self, stdin, stdout, Write}; @@ -12,7 +10,7 @@ mod factor; use clap::{crate_version, Arg, ArgAction, Command}; pub use factor::*; use uucore::display::Quotable; -use uucore::error::UResult; +use uucore::error::{set_exit_code, FromIo, UResult}; use uucore::{format_usage, help_about, help_usage, show_error, show_warning}; mod miller_rabin; @@ -32,26 +30,27 @@ mod options { fn print_factors_str( num_str: &str, w: &mut io::BufWriter, - factors_buffer: &mut String, print_exponents: bool, -) -> Result<(), Box> { - num_str - .trim() - .parse::() - .map_err(|e| e.into()) - .and_then(|x| { - factors_buffer.clear(); - // If print_exponents is true, use the alternate format specifier {:#} from fmt to print the factors - // of x in the form of p^e. - if print_exponents { - writeln!(factors_buffer, "{}:{:#}", x, factor(x))?; - } else { - writeln!(factors_buffer, "{}:{}", x, factor(x))?; - } - w.write_all(factors_buffer.as_bytes())?; - w.flush()?; - Ok(()) - }) +) -> io::Result<()> { + let x = match num_str.trim().parse::() { + Ok(x) => x, + Err(e) => { + // We return Ok() instead of Err(), because it's non-fatal and we should try the next + // number. + show_warning!("{}: {}", num_str.maybe_quote(), e); + set_exit_code(1); + return Ok(()); + } + }; + + // If print_exponents is true, use the alternate format specifier {:#} from fmt to print the factors + // of x in the form of p^e. + if print_exponents { + writeln!(w, "{}:{:#}", x, factor(x))?; + } else { + writeln!(w, "{}:{}", x, factor(x))?; + } + w.flush() } #[uucore::main] @@ -64,25 +63,19 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let stdout = stdout(); // We use a smaller buffer here to pass a gnu test. 4KiB appears to be the default pipe size for bash. let mut w = io::BufWriter::with_capacity(4 * 1024, stdout.lock()); - let mut factors_buffer = String::new(); if let Some(values) = matches.get_many::(options::NUMBER) { for number in values { - if let Err(e) = print_factors_str(number, &mut w, &mut factors_buffer, print_exponents) - { - show_warning!("{}: {}", number.maybe_quote(), e); - } + print_factors_str(number, &mut w, print_exponents) + .map_err_context(|| "write error".into())?; } } else { let stdin = stdin(); let lines = stdin.lock().lines(); for line in lines { for number in line.unwrap().split_whitespace() { - if let Err(e) = - print_factors_str(number, &mut w, &mut factors_buffer, print_exponents) - { - show_warning!("{}: {}", number.maybe_quote(), e); - } + print_factors_str(number, &mut w, print_exponents) + .map_err_context(|| "write error".into())?; } } } diff --git a/tests/by-util/test_factor.rs b/tests/by-util/test_factor.rs index 2a11363b7..3326a1ace 100644 --- a/tests/by-util/test_factor.rs +++ b/tests/by-util/test_factor.rs @@ -337,6 +337,37 @@ fn test_primes_with_exponents() { .stdout_is(String::from_utf8(output_string.as_bytes().to_owned()).unwrap()); } +#[test] +fn fails_on_invalid_number() { + new_ucmd!().arg("not-a-valid-number").fails(); + new_ucmd!() + .arg("not-a-valid-number") + .arg("12") + .fails() + .stdout_contains("12: 2 2 3"); +} + +#[test] +#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))] +fn short_circuit_write_error() { + use std::fs::OpenOptions; + + // Check that the error is printed exactly once and factor does not move on + // to the next number when a write error happens. + // + // Note: Technically, GNU prints the error twice, not because it does not + // short circuit the error, but because it always prints the error twice, + // for any number of inputs. That's silly behavior and printing once is + // clearly better. + let f = OpenOptions::new().write(true).open("/dev/full").unwrap(); + new_ucmd!() + .arg("12") + .arg("10") + .set_stdout(f) + .fails() + .stderr_is("factor: write error: No space left on device\n"); +} + const PRIMES_BY_BITS: &[&[u64]] = &[ PRIMES14, PRIMES15, PRIMES16, PRIMES17, PRIMES18, PRIMES19, PRIMES20, PRIMES21, PRIMES22, PRIMES23, PRIMES24, PRIMES25, PRIMES26, PRIMES27, PRIMES28, PRIMES29, PRIMES30, PRIMES31, From 0d4db7fc9564a11ca9a3c0a9ad398b64302c833e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 30 Aug 2023 22:40:44 +0000 Subject: [PATCH 107/370] chore(deps): update rust crate chrono to ^0.4.28 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b1b3ade3..23869b79f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -240,9 +240,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.27" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56b4c72906975ca04becb8a30e102dfecddd0c06181e3e95ddc444be28881f8" +checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index 6b381cccb..a9a6a1579 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -263,7 +263,7 @@ binary-heap-plus = "0.5.0" bstr = "1.6" bytecount = "0.6.3" byteorder = "1.4.3" -chrono = { version = "^0.4.27", default-features = false, features = [ +chrono = { version = "^0.4.28", default-features = false, features = [ "std", "alloc", "clock", From 6f37b4b4cfcbe45725d91d63dadabd1aa9873a2b Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 30 Aug 2023 19:29:57 -0400 Subject: [PATCH 108/370] split: hyphenated values + tests --- src/uu/split/src/split.rs | 50 ++++++++++++++++++++--- tests/by-util/test_split.rs | 81 ++++++++++++++++++++++++++++++++++--- 2 files changed, 120 insertions(+), 11 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index afe635456..7834dfe68 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -73,11 +73,18 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { /// following GNU `split` behavior fn handle_obsolete(args: &[String]) -> (Vec, Option) { let mut obs_lines = None; + let mut preceding_long_opt_req_value = false; + let mut preceding_short_opt_req_value = false; let filtered_args = args .iter() .filter_map(|slice| { + let filter: Option; + // check if the slice is a true short option (and not hyphen prefixed value of an option) + // and if so, a short option that can contain obsolete lines value if slice.starts_with('-') && !slice.starts_with("--") + && !preceding_long_opt_req_value + && !preceding_short_opt_req_value && !slice.starts_with("-a") && !slice.starts_with("-b") && !slice.starts_with("-C") @@ -109,7 +116,7 @@ fn handle_obsolete(args: &[String]) -> (Vec, Option) { if obs_lines_extracted.is_empty() { // no obsolete lines value found/extracted - Some(slice.to_owned()) + filter = Some(slice.to_owned()); } else { // obsolete lines value was extracted obs_lines = Some(obs_lines_extracted.iter().collect()); @@ -117,16 +124,41 @@ fn handle_obsolete(args: &[String]) -> (Vec, Option) { // there were some short options in front of or after obsolete lines value // i.e. '-xd100' or '-100de' or similar, which after extraction of obsolete lines value // would look like '-xd' or '-de' or similar - Some(filtered_slice.iter().collect()) + filter = Some(filtered_slice.iter().collect()); } else { - None + filter = None; } } } else { // either not a short option // or a short option that cannot have obsolete lines value in it - Some(slice.to_owned()) + filter = Some(slice.to_owned()); } + // capture if current slice is a preceding long option that requires value and does not use '=' to assign that value + // following slice should be treaded as value for this option + // even if it starts with '-' (which would be treated as hyphen prefixed value) + if slice.starts_with("--") { + preceding_long_opt_req_value = &slice[2..] == OPT_BYTES + || &slice[2..] == OPT_LINE_BYTES + || &slice[2..] == OPT_LINES + || &slice[2..] == OPT_ADDITIONAL_SUFFIX + || &slice[2..] == OPT_FILTER + || &slice[2..] == OPT_NUMBER + || &slice[2..] == OPT_SUFFIX_LENGTH; + } + // capture if current slice is a preceding short option that requires value and does not have value in the same slice (value separated by whitespace) + // following slice should be treaded as value for this option + // even if it starts with '-' (which would be treated as hyphen prefixed value) + preceding_short_opt_req_value = + slice == "-b" || slice == "-C" || slice == "-l" || slice == "-n" || slice == "-a"; + // slice is a value + // reset preceding option flags + if !slice.starts_with('-') { + preceding_short_opt_req_value = false; + preceding_long_opt_req_value = false; + } + // return filter + filter }) .collect(); (filtered_args, obs_lines) @@ -144,6 +176,7 @@ pub fn uu_app() -> Command { Arg::new(OPT_BYTES) .short('b') .long(OPT_BYTES) + .allow_hyphen_values(true) .value_name("SIZE") .help("put SIZE bytes per output file"), ) @@ -151,14 +184,15 @@ pub fn uu_app() -> Command { Arg::new(OPT_LINE_BYTES) .short('C') .long(OPT_LINE_BYTES) + .allow_hyphen_values(true) .value_name("SIZE") - .default_value("2") .help("put at most SIZE bytes of lines per output file"), ) .arg( Arg::new(OPT_LINES) .short('l') .long(OPT_LINES) + .allow_hyphen_values(true) .value_name("NUMBER") .default_value("1000") .help("put NUMBER lines/records per output file"), @@ -167,6 +201,7 @@ pub fn uu_app() -> Command { Arg::new(OPT_NUMBER) .short('n') .long(OPT_NUMBER) + .allow_hyphen_values(true) .value_name("CHUNKS") .help("generate CHUNKS output files; see explanation below"), ) @@ -174,6 +209,7 @@ pub fn uu_app() -> Command { .arg( Arg::new(OPT_ADDITIONAL_SUFFIX) .long(OPT_ADDITIONAL_SUFFIX) + .allow_hyphen_values(true) .value_name("SUFFIX") .default_value("") .help("additional SUFFIX to append to output file names"), @@ -181,6 +217,7 @@ pub fn uu_app() -> Command { .arg( Arg::new(OPT_FILTER) .long(OPT_FILTER) + .allow_hyphen_values(true) .value_name("COMMAND") .value_hint(clap::ValueHint::CommandName) .help( @@ -250,9 +287,10 @@ pub fn uu_app() -> Command { Arg::new(OPT_SUFFIX_LENGTH) .short('a') .long(OPT_SUFFIX_LENGTH) + .allow_hyphen_values(true) .value_name("N") .default_value(OPT_DEFAULT_SUFFIX_LENGTH) - .help("use suffixes of fixed length N. 0 implies dynamic length."), + .help("use suffixes of fixed length N. 0 implies dynamic length, starting with 2"), ) .arg( Arg::new(OPT_VERBOSE) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 3280fff67..466dabda9 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -254,6 +254,18 @@ fn test_additional_suffix_no_slash() { .usage_error("invalid suffix 'a/b', contains directory separator"); } +#[test] +fn test_split_additional_suffix_hyphen_value() { + let (at, mut ucmd) = at_and_ucmd!(); + let name = "split_additional_suffix"; + RandomFile::new(&at, name).add_lines(2000); + ucmd.args(&["--additional-suffix", "-300", name]).succeeds(); + + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]-300$"); + assert_eq!(glob.count(), 2); + assert_eq!(glob.collate(), at.read_bytes(name)); +} + // note: the test_filter* tests below are unix-only // windows support has been waived for now because of the difficulty of getting // the `cmd` call right @@ -436,9 +448,9 @@ fn test_split_obs_lines_starts_combined_shorts() { /// Test for using both obsolete lines (standalone) option and short/long lines option simultaneously #[test] fn test_split_both_lines_and_obs_lines_standalone() { - // This test will ensure that if both lines option '-l' or '--lines' - // and obsolete lines option '-100' are used - // it fails + // This test will ensure that: + // if both lines option '-l' or '--lines' (with value) and obsolete lines option '-100' are used - it fails + // if standalone lines option is used incorrectly and treated as a hyphen prefixed value of other option - it fails let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; at.touch("file"); @@ -455,18 +467,77 @@ fn test_split_both_lines_and_obs_lines_standalone() { .fails() .code_is(1) .stderr_contains("split: cannot split in more than one way\n"); +} + +/// Test for using obsolete lines option incorrectly, so it is treated as a hyphen prefixed value of other option +#[test] +fn test_split_obs_lines_as_other_option_value() { + // This test will ensure that: + // if obsolete lines option is used incorrectly and treated as a hyphen prefixed value of other option - it fails + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.touch("file"); + scene .ucmd() .args(&["--lines", "-200", "file"]) .fails() .code_is(1) - .stderr_contains("split: cannot split in more than one way\n"); + .stderr_contains("split: invalid number of lines: '-200'\n"); scene .ucmd() .args(&["-l", "-200", "file"]) .fails() .code_is(1) - .stderr_contains("split: cannot split in more than one way\n"); + .stderr_contains("split: invalid number of lines: '-200'\n"); + scene + .ucmd() + .args(&["-a", "-200", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: invalid suffix length: '-200'\n"); + scene + .ucmd() + .args(&["--suffix-length", "-d200e", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: invalid suffix length: '-d200e'\n"); + scene + .ucmd() + .args(&["-C", "-200", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: invalid number of bytes: '-200'\n"); + scene + .ucmd() + .args(&["--line-bytes", "-x200a4", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: invalid number of bytes: '-x200a4'\n"); + scene + .ucmd() + .args(&["-b", "-200", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: invalid number of bytes: '-200'\n"); + scene + .ucmd() + .args(&["--bytes", "-200xd", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: invalid number of bytes: '-200xd'\n"); + scene + .ucmd() + .args(&["-n", "-200", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: invalid number of chunks: -200\n"); + scene + .ucmd() + .args(&["--number", "-e200", "file"]) + .fails() + .code_is(1) + .stderr_contains("split: invalid number of chunks: -e200\n"); } /// Test for using more than one obsolete lines option (standalone) From 843540d05fafe427ed34d7b8b546357d327d3df5 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 31 Aug 2023 09:21:59 +0200 Subject: [PATCH 109/370] fix a typo --- util/build-gnu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 21a231bc0..157265f61 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -38,7 +38,7 @@ if test ! -d "${path_GNU}"; then echo "Could not find GNU coreutils (expected at '${path_GNU}')" echo "Run the following to download into the expected path:" echo "git clone --recurse-submodules https://github.com/coreutils/coreutils.git \"${path_GNU}\"" - echo "After downloading GNU coreutils to \"${path_GNU}\" run the following commands to cheout latest release tag" + echo "After downloading GNU coreutils to \"${path_GNU}\" run the following commands to checkout latest release tag" echo "cd \"${path_GNU}\"" echo "git fetch --all --tags" echo "git checkout tags/${release_tag_GNU}" From fb1c663724e5c1b563a466536046c58be79af45d Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 31 Aug 2023 16:26:07 +0200 Subject: [PATCH 110/370] uucore: make deps of "sum" feature optional --- src/uucore/Cargo.toml | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index d376e807a..823591084 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -40,16 +40,16 @@ libc = { workspace = true, optional = true } once_cell = { workspace = true } os_display = "0.1.3" -digest = { workspace = true } -hex = { workspace = true } -memchr = { workspace = true } -md-5 = { workspace = true } -sha1 = { workspace = true } -sha2 = { workspace = true } -sha3 = { workspace = true } -blake2b_simd = { workspace = true } -blake3 = { workspace = true } -sm3 = { workspace = true } +digest = { workspace = true, optional = true } +hex = { workspace = true, optional = true } +memchr = { workspace = true, optional = true } +md-5 = { workspace = true, optional = true } +sha1 = { workspace = true, optional = true } +sha2 = { workspace = true, optional = true } +sha3 = { workspace = true, optional = true } +blake2b_simd = { workspace = true, optional = true } +blake3 = { workspace = true, optional = true } +sm3 = { workspace = true, optional = true } [target.'cfg(unix)'.dependencies] walkdir = { workspace = true, optional = true } @@ -86,4 +86,15 @@ utf8 = [] utmpx = ["time", "time/macros", "libc", "dns-lookup"] wide = [] pipes = [] -sum = [] +sum = [ + "digest", + "hex", + "memchr", + "md-5", + "sha1", + "sha2", + "sha3", + "blake2b_simd", + "blake3", + "sm3", +] From 5bfe9b19ef775adf40c3e915a731611dbc4a6256 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Thu, 31 Aug 2023 14:46:56 -0400 Subject: [PATCH 111/370] split: avoid using `collect_lossy` + test for invalid UTF8 arguments --- src/uu/split/src/split.rs | 167 +++++++++++++++++++----------------- tests/by-util/test_split.rs | 45 ++++++++++ 2 files changed, 134 insertions(+), 78 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 7834dfe68..68692d03c 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -13,6 +13,7 @@ use crate::filenames::FilenameIterator; use crate::filenames::SuffixType; use clap::{crate_version, parser::ValueSource, Arg, ArgAction, ArgMatches, Command}; use std::env; +use std::ffi::OsString; use std::fmt; use std::fs::{metadata, File}; use std::io; @@ -52,9 +53,8 @@ const AFTER_HELP: &str = help_section!("after help", "split.md"); #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let args = args.collect_lossy(); - - let (args, obs_lines) = handle_obsolete(&args[..]); + + let (args, obs_lines) = handle_obsolete(args); let matches = uu_app().try_get_matches_from(args)?; @@ -71,91 +71,102 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { /// `split -x300e file` would mean `split -x -l 300 -e file` /// `split -x300e -22 file` would mean `split -x -e -l 22 file` (last obsolete lines option wins) /// following GNU `split` behavior -fn handle_obsolete(args: &[String]) -> (Vec, Option) { +fn handle_obsolete(args: impl uucore::Args) -> (Vec, Option) { let mut obs_lines = None; let mut preceding_long_opt_req_value = false; let mut preceding_short_opt_req_value = false; let filtered_args = args - .iter() - .filter_map(|slice| { - let filter: Option; - // check if the slice is a true short option (and not hyphen prefixed value of an option) - // and if so, a short option that can contain obsolete lines value - if slice.starts_with('-') - && !slice.starts_with("--") - && !preceding_long_opt_req_value - && !preceding_short_opt_req_value - && !slice.starts_with("-a") - && !slice.starts_with("-b") - && !slice.starts_with("-C") - && !slice.starts_with("-l") - && !slice.starts_with("-n") - { - // start of the short option string - // that can have obsolete lines option value in it - // extract numeric part and filter it out - let mut obs_lines_extracted: Vec = vec![]; - let mut obs_lines_end_reached = false; - let filtered_slice: Vec = slice - .chars() - .filter(|c| { - // To correctly process scenario like '-x200a4' - // we need to stop extracting digits once alphabetic character is encountered - // after we already have something in obs_lines_extracted - if c.is_ascii_digit() && !obs_lines_end_reached { - obs_lines_extracted.push(*c); - false - } else { - if !obs_lines_extracted.is_empty() { - obs_lines_end_reached = true; + .filter_map(|os_slice| { + let filter: Option; + if let Some(slice) = os_slice.to_str() { + // check if the slice is a true short option (and not hyphen prefixed value of an option) + // and if so, a short option that can contain obsolete lines value + if slice.starts_with('-') + && !slice.starts_with("--") + && !preceding_long_opt_req_value + && !preceding_short_opt_req_value + && !slice.starts_with("-a") + && !slice.starts_with("-b") + && !slice.starts_with("-C") + && !slice.starts_with("-l") + && !slice.starts_with("-n") + { + // start of the short option string + // that can have obsolete lines option value in it + // extract numeric part and filter it out + let mut obs_lines_extracted: Vec = vec![]; + let mut obs_lines_end_reached = false; + let filtered_slice: Vec = slice + .chars() + .filter(|c| { + // To correctly process scenario like '-x200a4' + // we need to stop extracting digits once alphabetic character is encountered + // after we already have something in obs_lines_extracted + if c.is_ascii_digit() && !obs_lines_end_reached { + obs_lines_extracted.push(*c); + false + } else { + if !obs_lines_extracted.is_empty() { + obs_lines_end_reached = true; + } + true } - true - } - }) - .collect(); + }) + .collect(); - if obs_lines_extracted.is_empty() { - // no obsolete lines value found/extracted - filter = Some(slice.to_owned()); - } else { - // obsolete lines value was extracted - obs_lines = Some(obs_lines_extracted.iter().collect()); - if filtered_slice.get(1).is_some() { - // there were some short options in front of or after obsolete lines value - // i.e. '-xd100' or '-100de' or similar, which after extraction of obsolete lines value - // would look like '-xd' or '-de' or similar - filter = Some(filtered_slice.iter().collect()); + if obs_lines_extracted.is_empty() { + // no obsolete lines value found/extracted + filter = Some(OsString::from(slice)); } else { - filter = None; + // obsolete lines value was extracted + obs_lines = Some(obs_lines_extracted.iter().collect()); + if filtered_slice.get(1).is_some() { + // there were some short options in front of or after obsolete lines value + // i.e. '-xd100' or '-100de' or similar, which after extraction of obsolete lines value + // would look like '-xd' or '-de' or similar + let filtered_slice: String = filtered_slice.iter().collect(); + filter = Some(OsString::from(filtered_slice)); + } else { + filter = None; + } } + } else { + // either not a short option + // or a short option that cannot have obsolete lines value in it + filter = Some(OsString::from(slice)); + } + // capture if current slice is a preceding long option that requires value and does not use '=' to assign that value + // following slice should be treaded as value for this option + // even if it starts with '-' (which would be treated as hyphen prefixed value) + if slice.starts_with("--") { + preceding_long_opt_req_value = &slice[2..] == OPT_BYTES + || &slice[2..] == OPT_LINE_BYTES + || &slice[2..] == OPT_LINES + || &slice[2..] == OPT_ADDITIONAL_SUFFIX + || &slice[2..] == OPT_FILTER + || &slice[2..] == OPT_NUMBER + || &slice[2..] == OPT_SUFFIX_LENGTH; + } + // capture if current slice is a preceding short option that requires value and does not have value in the same slice (value separated by whitespace) + // following slice should be treaded as value for this option + // even if it starts with '-' (which would be treated as hyphen prefixed value) + preceding_short_opt_req_value = slice == "-b" + || slice == "-C" + || slice == "-l" + || slice == "-n" + || slice == "-a"; + // slice is a value + // reset preceding option flags + if !slice.starts_with('-') { + preceding_short_opt_req_value = false; + preceding_long_opt_req_value = false; } } else { - // either not a short option - // or a short option that cannot have obsolete lines value in it - filter = Some(slice.to_owned()); - } - // capture if current slice is a preceding long option that requires value and does not use '=' to assign that value - // following slice should be treaded as value for this option - // even if it starts with '-' (which would be treated as hyphen prefixed value) - if slice.starts_with("--") { - preceding_long_opt_req_value = &slice[2..] == OPT_BYTES - || &slice[2..] == OPT_LINE_BYTES - || &slice[2..] == OPT_LINES - || &slice[2..] == OPT_ADDITIONAL_SUFFIX - || &slice[2..] == OPT_FILTER - || &slice[2..] == OPT_NUMBER - || &slice[2..] == OPT_SUFFIX_LENGTH; - } - // capture if current slice is a preceding short option that requires value and does not have value in the same slice (value separated by whitespace) - // following slice should be treaded as value for this option - // even if it starts with '-' (which would be treated as hyphen prefixed value) - preceding_short_opt_req_value = - slice == "-b" || slice == "-C" || slice == "-l" || slice == "-n" || slice == "-a"; - // slice is a value - // reset preceding option flags - if !slice.starts_with('-') { - preceding_short_opt_req_value = false; - preceding_long_opt_req_value = false; + // Cannot cleanly convert os_slice to UTF-8 + // Do not process and return as-is + // This will cause failure later on, but we should not handle it here + // and let clap panic on invalid UTF-8 argument + filter = Some(os_slice); } // return filter filter diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 466dabda9..d24d2cf54 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -9,6 +9,7 @@ use rand::{thread_rng, Rng, SeedableRng}; use regex::Regex; #[cfg(not(windows))] use std::env; +use std::ffi::OsStr; use std::path::Path; use std::{ fs::{read_dir, File}, @@ -1287,3 +1288,47 @@ fn test_split_invalid_input() { .no_stdout() .stderr_contains("split: invalid number of chunks: 0"); } + +/// Test if there are invalid (non UTF-8) in the arguments - unix +/// clap is expected to fail/panic +#[cfg(unix)] +#[test] +fn test_split_non_utf8_argument_unix() { + use std::os::unix::ffi::OsStrExt; + + let (at, mut ucmd) = at_and_ucmd!(); + let name = "test_split_non_utf8_argument"; + let opt = OsStr::from_bytes("--additional-suffix".as_bytes()); + RandomFile::new(&at, name).add_lines(2000); + // Here, the values 0x66 and 0x6f correspond to 'f' and 'o' + // respectively. The value 0x80 is a lone continuation byte, invalid + // in a UTF-8 sequence. + let opt_value = [0x66, 0x6f, 0x80, 0x6f]; + let opt_value = OsStr::from_bytes(&opt_value[..]); + let name = OsStr::from_bytes(name.as_bytes()); + ucmd.args(&[opt, opt_value, name]) + .fails() + .stderr_contains("error: invalid UTF-8 was detected in one or more arguments"); +} + +/// Test if there are invalid (non UTF-8) in the arguments - windows +/// clap is expected to fail/panic +#[cfg(windows)] +#[test] +fn test_split_non_utf8_argument_windows() { + use std::os::windows::prelude::*; + + let (at, mut ucmd) = at_and_ucmd!(); + let name = "test_split_non_utf8_argument"; + let opt = OsStr::from_bytes("--additional-suffix".as_bytes()); + RandomFile::new(&at, name).add_lines(2000); + // Here the values 0x0066 and 0x006f correspond to 'f' and 'o' + // respectively. The value 0xD800 is a lone surrogate half, invalid + // in a UTF-16 sequence. + let opt_value = [0x0066, 0x006f, 0xD800, 0x006f]; + let opt_value = OsString::from_wide(&opt_value[..]); + let name = OsStr::from_bytes(name.as_bytes()); + ucmd.args(&[opt, opt_value, name]) + .fails() + .stderr_contains("error: invalid UTF-8 was detected in one or more arguments"); +} From 271a108fa9e1ea75ed8c6e42c2a207a6da935c81 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Thu, 31 Aug 2023 15:37:42 -0400 Subject: [PATCH 112/370] split: formatting --- src/uu/split/src/split.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 68692d03c..d76bfb2de 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -53,7 +53,6 @@ const AFTER_HELP: &str = help_section!("after help", "split.md"); #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let (args, obs_lines) = handle_obsolete(args); let matches = uu_app().try_get_matches_from(args)?; From d2812cbbc387b7dc3ad8f5f31863aad09ce1e6ad Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Thu, 31 Aug 2023 16:04:44 -0400 Subject: [PATCH 113/370] split: disable windows test for invalid UTF8 --- tests/by-util/test_split.rs | 44 +++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index d24d2cf54..aef9ea040 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -9,7 +9,6 @@ use rand::{thread_rng, Rng, SeedableRng}; use regex::Regex; #[cfg(not(windows))] use std::env; -use std::ffi::OsStr; use std::path::Path; use std::{ fs::{read_dir, File}, @@ -1294,6 +1293,7 @@ fn test_split_invalid_input() { #[cfg(unix)] #[test] fn test_split_non_utf8_argument_unix() { + use std::ffi::OsStr; use std::os::unix::ffi::OsStrExt; let (at, mut ucmd) = at_and_ucmd!(); @@ -1311,24 +1311,26 @@ fn test_split_non_utf8_argument_unix() { .stderr_contains("error: invalid UTF-8 was detected in one or more arguments"); } -/// Test if there are invalid (non UTF-8) in the arguments - windows -/// clap is expected to fail/panic -#[cfg(windows)] -#[test] -fn test_split_non_utf8_argument_windows() { - use std::os::windows::prelude::*; +// Test if there are invalid (non UTF-8) in the arguments - windows +// clap is expected to fail/panic +// comment it out for now +// #[cfg(windows)] +// #[test] +// fn test_split_non_utf8_argument_windows() { +// use std::ffi::OsString; +// use std::os::windows::prelude::*; - let (at, mut ucmd) = at_and_ucmd!(); - let name = "test_split_non_utf8_argument"; - let opt = OsStr::from_bytes("--additional-suffix".as_bytes()); - RandomFile::new(&at, name).add_lines(2000); - // Here the values 0x0066 and 0x006f correspond to 'f' and 'o' - // respectively. The value 0xD800 is a lone surrogate half, invalid - // in a UTF-16 sequence. - let opt_value = [0x0066, 0x006f, 0xD800, 0x006f]; - let opt_value = OsString::from_wide(&opt_value[..]); - let name = OsStr::from_bytes(name.as_bytes()); - ucmd.args(&[opt, opt_value, name]) - .fails() - .stderr_contains("error: invalid UTF-8 was detected in one or more arguments"); -} +// let (at, mut ucmd) = at_and_ucmd!(); +// let name = "test_split_non_utf8_argument"; +// let opt = OsStr::from_bytes("--additional-suffix".as_bytes()); +// RandomFile::new(&at, name).add_lines(2000); +// // Here the values 0x0066 and 0x006f correspond to 'f' and 'o' +// // respectively. The value 0xD800 is a lone surrogate half, invalid +// // in a UTF-16 sequence. +// let opt_value = [0x0066, 0x006f, 0xD800, 0x006f]; +// let opt_value = OsString::from_wide(&opt_value[..]); +// let name = OsStr::from_bytes(name.as_bytes()); +// ucmd.args(&[opt, opt_value, name]) +// .fails() +// .stderr_contains("error: invalid UTF-8 was detected in one or more arguments"); +// } From 4f465eb76cd200a64dd309c3d8dc20bbbe37fc2d Mon Sep 17 00:00:00 2001 From: XXIV <13811862+thechampagne@users.noreply.github.com> Date: Thu, 31 Aug 2023 23:44:45 +0300 Subject: [PATCH 114/370] remove unnecessary heap allocation --- src/uucore/src/lib/features/entries.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uucore/src/lib/features/entries.rs b/src/uucore/src/lib/features/entries.rs index c06c5116e..29c9b4372 100644 --- a/src/uucore/src/lib/features/entries.rs +++ b/src/uucore/src/lib/features/entries.rs @@ -218,7 +218,7 @@ impl Passwd { let mut ngroups: c_int = 8; let mut ngroups_old: c_int; let mut groups = vec![0; ngroups.try_into().unwrap()]; - let name = CString::new(self.name.clone()).unwrap(); + let name = CString::new(self.name.as_bytes()).unwrap(); loop { ngroups_old = ngroups; if unsafe { getgrouplist(name.as_ptr(), self.gid, groups.as_mut_ptr(), &mut ngroups) } From e597189be7555164fc7f57df0b03f1ae788901ea Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Thu, 31 Aug 2023 20:48:44 -0400 Subject: [PATCH 115/370] split: fixed windows test for invalid unicode args --- tests/by-util/test_split.rs | 45 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index aef9ea040..965f2733e 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -1290,8 +1290,8 @@ fn test_split_invalid_input() { /// Test if there are invalid (non UTF-8) in the arguments - unix /// clap is expected to fail/panic -#[cfg(unix)] #[test] +#[cfg(unix)] fn test_split_non_utf8_argument_unix() { use std::ffi::OsStr; use std::os::unix::ffi::OsStrExt; @@ -1311,26 +1311,25 @@ fn test_split_non_utf8_argument_unix() { .stderr_contains("error: invalid UTF-8 was detected in one or more arguments"); } -// Test if there are invalid (non UTF-8) in the arguments - windows -// clap is expected to fail/panic -// comment it out for now -// #[cfg(windows)] -// #[test] -// fn test_split_non_utf8_argument_windows() { -// use std::ffi::OsString; -// use std::os::windows::prelude::*; +/// Test if there are invalid (non UTF-8) in the arguments - windows +/// clap is expected to fail/panic +#[test] +#[cfg(windows)] +fn test_split_non_utf8_argument_windows() { + use std::ffi::OsString; + use std::os::windows::ffi::OsStringExt; -// let (at, mut ucmd) = at_and_ucmd!(); -// let name = "test_split_non_utf8_argument"; -// let opt = OsStr::from_bytes("--additional-suffix".as_bytes()); -// RandomFile::new(&at, name).add_lines(2000); -// // Here the values 0x0066 and 0x006f correspond to 'f' and 'o' -// // respectively. The value 0xD800 is a lone surrogate half, invalid -// // in a UTF-16 sequence. -// let opt_value = [0x0066, 0x006f, 0xD800, 0x006f]; -// let opt_value = OsString::from_wide(&opt_value[..]); -// let name = OsStr::from_bytes(name.as_bytes()); -// ucmd.args(&[opt, opt_value, name]) -// .fails() -// .stderr_contains("error: invalid UTF-8 was detected in one or more arguments"); -// } + let (at, mut ucmd) = at_and_ucmd!(); + let name = "test_split_non_utf8_argument"; + let opt = OsString::from("--additional-suffix"); + RandomFile::new(&at, name).add_lines(2000); + // Here the values 0x0066 and 0x006f correspond to 'f' and 'o' + // respectively. The value 0xD800 is a lone surrogate half, invalid + // in a UTF-16 sequence. + let opt_value = [0x0066, 0x006f, 0xD800, 0x006f]; + let opt_value = OsString::from_wide(&opt_value[..]); + let name = OsString::from(name); + ucmd.args(&[opt, opt_value, name]) + .fails() + .stderr_contains("error: invalid UTF-8 was detected in one or more arguments"); +} From 2e715083082e5a729d8804c0b2a430c08e762607 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 1 Sep 2023 09:42:26 +0200 Subject: [PATCH 116/370] uucore: make "dunce" optional --- src/uucore/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 823591084..8557d2fd4 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -21,7 +21,7 @@ path = "src/lib/lib.rs" clap = { workspace = true } uucore_procs = { workspace = true } dns-lookup = { version = "2.0.2", optional = true } -dunce = "1.0.4" +dunce = { version = "1.0.4", optional = true } wild = "2.1" glob = { workspace = true } # * optional @@ -73,7 +73,7 @@ default = [] # * non-default features encoding = ["data-encoding", "data-encoding-macro", "z85", "thiserror"] entries = ["libc"] -fs = ["libc", "winapi-util", "windows-sys"] +fs = ["dunce", "libc", "winapi-util", "windows-sys"] fsext = ["libc", "time", "windows-sys"] lines = [] memo = ["itertools"] From b41ff2ed7f918d2e5bb1e922db101704bcd03eab Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 1 Sep 2023 16:08:07 +0200 Subject: [PATCH 117/370] uucore: turn backup_control into a feature --- src/uu/cp/Cargo.toml | 8 +++++++- src/uu/install/Cargo.toml | 8 +++++++- src/uu/ln/Cargo.toml | 2 +- src/uu/mv/Cargo.toml | 2 +- src/uucore/Cargo.toml | 1 + src/uucore/src/lib/features.rs | 2 ++ src/uucore/src/lib/{mods => features}/backup_control.rs | 0 src/uucore/src/lib/lib.rs | 3 ++- src/uucore/src/lib/mods.rs | 1 - 9 files changed, 21 insertions(+), 6 deletions(-) rename src/uucore/src/lib/{mods => features}/backup_control.rs (100%) diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index c768bde0c..5b5c9c0d1 100644 --- a/src/uu/cp/Cargo.toml +++ b/src/uu/cp/Cargo.toml @@ -24,7 +24,13 @@ filetime = { workspace = true } libc = { workspace = true } quick-error = { workspace = true } selinux = { workspace = true, optional = true } -uucore = { workspace = true, features = ["entries", "fs", "perms", "mode"] } +uucore = { workspace = true, features = [ + "backup-control", + "entries", + "fs", + "perms", + "mode", +] } walkdir = { workspace = true } indicatif = { workspace = true } diff --git a/src/uu/install/Cargo.toml b/src/uu/install/Cargo.toml index 8228e0d20..f24c7c40d 100644 --- a/src/uu/install/Cargo.toml +++ b/src/uu/install/Cargo.toml @@ -19,7 +19,13 @@ clap = { workspace = true } filetime = { workspace = true } file_diff = { workspace = true } libc = { workspace = true } -uucore = { workspace = true, features = ["fs", "mode", "perms", "entries"] } +uucore = { workspace = true, features = [ + "backup-control", + "fs", + "mode", + "perms", + "entries", +] } [[bin]] name = "install" diff --git a/src/uu/ln/Cargo.toml b/src/uu/ln/Cargo.toml index 7674129f3..d66338d44 100644 --- a/src/uu/ln/Cargo.toml +++ b/src/uu/ln/Cargo.toml @@ -16,7 +16,7 @@ path = "src/ln.rs" [dependencies] clap = { workspace = true } -uucore = { workspace = true, features = ["fs"] } +uucore = { workspace = true, features = ["backup-control", "fs"] } [[bin]] name = "ln" diff --git a/src/uu/mv/Cargo.toml b/src/uu/mv/Cargo.toml index ab90e4509..970707853 100644 --- a/src/uu/mv/Cargo.toml +++ b/src/uu/mv/Cargo.toml @@ -18,7 +18,7 @@ path = "src/mv.rs" clap = { workspace = true } fs_extra = { workspace = true } indicatif = { workspace = true } -uucore = { workspace = true, features = ["fs"] } +uucore = { workspace = true, features = ["backup-control", "fs"] } [[bin]] name = "mv" diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 823591084..6b3c87b52 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -71,6 +71,7 @@ windows-sys = { workspace = true, optional = true, default-features = false, fea [features] default = [] # * non-default features +backup-control = [] encoding = ["data-encoding", "data-encoding-macro", "z85", "thiserror"] entries = ["libc"] fs = ["libc", "winapi-util", "windows-sys"] diff --git a/src/uucore/src/lib/features.rs b/src/uucore/src/lib/features.rs index 8abccee26..0a23b9dd9 100644 --- a/src/uucore/src/lib/features.rs +++ b/src/uucore/src/lib/features.rs @@ -4,6 +4,8 @@ // file that was distributed with this source code. // features ~ feature-gated modules (core/bundler file) +#[cfg(feature = "backup-control")] +pub mod backup_control; #[cfg(feature = "encoding")] pub mod encoding; #[cfg(feature = "fs")] diff --git a/src/uucore/src/lib/mods/backup_control.rs b/src/uucore/src/lib/features/backup_control.rs similarity index 100% rename from src/uucore/src/lib/mods/backup_control.rs rename to src/uucore/src/lib/features/backup_control.rs diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 49505438f..818b7bd3f 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -20,7 +20,6 @@ mod parser; // string parsing modules pub use uucore_procs::*; // * cross-platform modules -pub use crate::mods::backup_control; pub use crate::mods::display; pub use crate::mods::error; pub use crate::mods::line_ending; @@ -38,6 +37,8 @@ pub use crate::parser::parse_time; pub use crate::parser::shortcut_value_parser; // * feature-gated modules +#[cfg(feature = "backup-control")] +pub use crate::features::backup_control; #[cfg(feature = "encoding")] pub use crate::features::encoding; #[cfg(feature = "fs")] diff --git a/src/uucore/src/lib/mods.rs b/src/uucore/src/lib/mods.rs index cb66c0041..6dd49438f 100644 --- a/src/uucore/src/lib/mods.rs +++ b/src/uucore/src/lib/mods.rs @@ -4,7 +4,6 @@ // file that was distributed with this source code. // mods ~ cross-platforms modules (core/bundler file) -pub mod backup_control; pub mod display; pub mod error; pub mod line_ending; From b405d4e6cc1f5f30a7619c4a8a5f52e044a2bfff Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 2 Sep 2023 14:38:27 +0200 Subject: [PATCH 118/370] uucore: turn update_control into a feature --- src/uu/cp/Cargo.toml | 1 + src/uu/mv/Cargo.toml | 6 +++++- src/uucore/Cargo.toml | 9 +++++---- src/uucore/src/lib/features.rs | 2 ++ src/uucore/src/lib/{mods => features}/update_control.rs | 0 src/uucore/src/lib/lib.rs | 3 ++- src/uucore/src/lib/mods.rs | 1 - 7 files changed, 15 insertions(+), 7 deletions(-) rename src/uucore/src/lib/{mods => features}/update_control.rs (100%) diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index 5b5c9c0d1..83f8dd5c9 100644 --- a/src/uu/cp/Cargo.toml +++ b/src/uu/cp/Cargo.toml @@ -30,6 +30,7 @@ uucore = { workspace = true, features = [ "fs", "perms", "mode", + "update-control", ] } walkdir = { workspace = true } indicatif = { workspace = true } diff --git a/src/uu/mv/Cargo.toml b/src/uu/mv/Cargo.toml index 970707853..25fa272d6 100644 --- a/src/uu/mv/Cargo.toml +++ b/src/uu/mv/Cargo.toml @@ -18,7 +18,11 @@ path = "src/mv.rs" clap = { workspace = true } fs_extra = { workspace = true } indicatif = { workspace = true } -uucore = { workspace = true, features = ["backup-control", "fs"] } +uucore = { workspace = true, features = [ + "backup-control", + "fs", + "update-control", +] } [[bin]] name = "mv" diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index f53b011f5..ad26d3bca 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -80,13 +80,10 @@ lines = [] memo = ["itertools"] mode = ["libc"] perms = ["libc", "walkdir"] +pipes = [] process = ["libc"] ringbuffer = [] signals = [] -utf8 = [] -utmpx = ["time", "time/macros", "libc", "dns-lookup"] -wide = [] -pipes = [] sum = [ "digest", "hex", @@ -99,3 +96,7 @@ sum = [ "blake3", "sm3", ] +update-control = [] +utf8 = [] +utmpx = ["time", "time/macros", "libc", "dns-lookup"] +wide = [] diff --git a/src/uucore/src/lib/features.rs b/src/uucore/src/lib/features.rs index 0a23b9dd9..c2dc975dc 100644 --- a/src/uucore/src/lib/features.rs +++ b/src/uucore/src/lib/features.rs @@ -22,6 +22,8 @@ pub mod ringbuffer; pub mod sum; #[cfg(feature = "memo")] mod tokenize; +#[cfg(feature = "update-control")] +pub mod update_control; // * (platform-specific) feature-gated modules // ** non-windows (i.e. Unix + Fuchsia) diff --git a/src/uucore/src/lib/mods/update_control.rs b/src/uucore/src/lib/features/update_control.rs similarity index 100% rename from src/uucore/src/lib/mods/update_control.rs rename to src/uucore/src/lib/features/update_control.rs diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 818b7bd3f..30ebae254 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -27,7 +27,6 @@ pub use crate::mods::os; pub use crate::mods::panic; pub use crate::mods::quoting_style; pub use crate::mods::ranges; -pub use crate::mods::update_control; pub use crate::mods::version_cmp; // * string parsing modules @@ -53,6 +52,8 @@ pub use crate::features::memo; pub use crate::features::ringbuffer; #[cfg(feature = "sum")] pub use crate::features::sum; +#[cfg(feature = "update-control")] +pub use crate::features::update_control; // * (platform-specific) feature-gated modules // ** non-windows (i.e. Unix + Fuchsia) diff --git a/src/uucore/src/lib/mods.rs b/src/uucore/src/lib/mods.rs index 6dd49438f..99055d014 100644 --- a/src/uucore/src/lib/mods.rs +++ b/src/uucore/src/lib/mods.rs @@ -10,7 +10,6 @@ pub mod line_ending; pub mod os; pub mod panic; pub mod ranges; -pub mod update_control; pub mod version_cmp; // dir and vdir also need access to the quoting_style module pub mod quoting_style; From be3aac924b921d5172ad525ec7739ba35c762b88 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 2 Sep 2023 16:02:14 +0200 Subject: [PATCH 119/370] mknod: remove unnecessary "not" in test --- src/uu/mknod/src/parsemode.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/mknod/src/parsemode.rs b/src/uu/mknod/src/parsemode.rs index 0ec80c6b4..adacaa45b 100644 --- a/src/uu/mknod/src/parsemode.rs +++ b/src/uu/mknod/src/parsemode.rs @@ -43,7 +43,7 @@ mod test { assert_eq!(super::parse_mode("u+x").unwrap(), 0o766); assert_eq!( super::parse_mode("+x").unwrap(), - if !is_wsl() { 0o777 } else { 0o776 } + if is_wsl() { 0o776 } else { 0o777 } ); assert_eq!(super::parse_mode("a-w").unwrap(), 0o444); assert_eq!(super::parse_mode("g-r").unwrap(), 0o626); From cad6a06862538c638eed50c78578b62ac4dd7952 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 2 Sep 2023 16:37:00 +0000 Subject: [PATCH 120/370] chore(deps): update rust crate regex to 1.9.5 --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23869b79f..4f30a9220 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1299,9 +1299,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e" [[package]] name = "memmap2" @@ -1758,9 +1758,9 @@ checksum = "f1bfbf25d7eb88ddcbb1ec3d755d0634da8f7657b2cb8b74089121409ab8228f" [[package]] name = "regex" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", @@ -1770,9 +1770,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", diff --git a/Cargo.toml b/Cargo.toml index a9a6a1579..3adac7a9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -311,7 +311,7 @@ rand = { version = "0.8", features = ["small_rng"] } rand_core = "0.6" rayon = "1.7" redox_syscall = "0.3" -regex = "1.9.4" +regex = "1.9.5" rstest = "0.18.2" rust-ini = "0.19.0" same-file = "1.0.6" From cb8c0e79e2d9dc3ba72d97cc35e9ab9c952e976b Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 2 Sep 2023 18:46:18 +0200 Subject: [PATCH 121/370] cp: finish progress bar to make it always show up --- src/uu/cp/src/cp.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 5be613ec6..7dbf8aedb 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1242,6 +1242,11 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult seen_sources.insert(source); } } + + if let Some(pb) = progress_bar { + pb.finish(); + } + if non_fatal_errors { Err(Error::NotAllFilesCopied) } else { From 9844f1f07d135c57a2d07db812de16ca0721165d Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 3 Sep 2023 14:42:54 +0200 Subject: [PATCH 122/370] 0.0.20 => 0.0.21 --- Cargo.lock | 216 ++++++++++++------------- Cargo.toml | 208 ++++++++++++------------ 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/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/dir/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 | 4 +- src/uu/stdbuf/src/libstdbuf/Cargo.toml | 2 +- src/uu/stty/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/vdir/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 | 2 +- src/uucore_procs/Cargo.toml | 4 +- src/uuhelp_parser/Cargo.toml | 2 +- util/update-version.sh | 4 +- 110 files changed, 323 insertions(+), 323 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f30a9220..f4885faa0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -379,7 +379,7 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "coreutils" -version = "0.0.20" +version = "0.0.21" dependencies = [ "chrono", "clap", @@ -2266,7 +2266,7 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uu_arch" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "platform-info", @@ -2275,7 +2275,7 @@ dependencies = [ [[package]] name = "uu_base32" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2283,7 +2283,7 @@ dependencies = [ [[package]] name = "uu_base64" -version = "0.0.20" +version = "0.0.21" dependencies = [ "uu_base32", "uucore", @@ -2291,7 +2291,7 @@ dependencies = [ [[package]] name = "uu_basename" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2299,7 +2299,7 @@ dependencies = [ [[package]] name = "uu_basenc" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uu_base32", @@ -2308,7 +2308,7 @@ dependencies = [ [[package]] name = "uu_cat" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "is-terminal", @@ -2319,7 +2319,7 @@ dependencies = [ [[package]] name = "uu_chcon" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "fts-sys", @@ -2331,7 +2331,7 @@ dependencies = [ [[package]] name = "uu_chgrp" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2339,7 +2339,7 @@ dependencies = [ [[package]] name = "uu_chmod" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2348,7 +2348,7 @@ dependencies = [ [[package]] name = "uu_chown" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "uu_chroot" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2364,7 +2364,7 @@ dependencies = [ [[package]] name = "uu_cksum" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "hex", @@ -2373,7 +2373,7 @@ dependencies = [ [[package]] name = "uu_comm" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2381,7 +2381,7 @@ dependencies = [ [[package]] name = "uu_cp" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "exacl", @@ -2397,7 +2397,7 @@ dependencies = [ [[package]] name = "uu_csplit" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "regex", @@ -2407,7 +2407,7 @@ dependencies = [ [[package]] name = "uu_cut" -version = "0.0.20" +version = "0.0.21" dependencies = [ "bstr", "clap", @@ -2418,7 +2418,7 @@ dependencies = [ [[package]] name = "uu_date" -version = "0.0.20" +version = "0.0.21" dependencies = [ "chrono", "clap", @@ -2430,7 +2430,7 @@ dependencies = [ [[package]] name = "uu_dd" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "gcd", @@ -2442,7 +2442,7 @@ dependencies = [ [[package]] name = "uu_df" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "tempfile", @@ -2452,7 +2452,7 @@ dependencies = [ [[package]] name = "uu_dir" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uu_ls", @@ -2461,7 +2461,7 @@ dependencies = [ [[package]] name = "uu_dircolors" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2469,7 +2469,7 @@ dependencies = [ [[package]] name = "uu_dirname" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2477,7 +2477,7 @@ dependencies = [ [[package]] name = "uu_du" -version = "0.0.20" +version = "0.0.21" dependencies = [ "chrono", "clap", @@ -2488,7 +2488,7 @@ dependencies = [ [[package]] name = "uu_echo" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2496,7 +2496,7 @@ dependencies = [ [[package]] name = "uu_env" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "nix", @@ -2506,7 +2506,7 @@ dependencies = [ [[package]] name = "uu_expand" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "unicode-width", @@ -2515,7 +2515,7 @@ dependencies = [ [[package]] name = "uu_expr" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "num-bigint", @@ -2526,7 +2526,7 @@ dependencies = [ [[package]] name = "uu_factor" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "coz", @@ -2539,7 +2539,7 @@ dependencies = [ [[package]] name = "uu_false" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2547,7 +2547,7 @@ dependencies = [ [[package]] name = "uu_fmt" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "unicode-width", @@ -2556,7 +2556,7 @@ dependencies = [ [[package]] name = "uu_fold" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2564,7 +2564,7 @@ dependencies = [ [[package]] name = "uu_groups" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2572,7 +2572,7 @@ dependencies = [ [[package]] name = "uu_hashsum" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "hex", @@ -2583,7 +2583,7 @@ dependencies = [ [[package]] name = "uu_head" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "memchr", @@ -2592,7 +2592,7 @@ dependencies = [ [[package]] name = "uu_hostid" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2601,7 +2601,7 @@ dependencies = [ [[package]] name = "uu_hostname" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "hostname", @@ -2611,7 +2611,7 @@ dependencies = [ [[package]] name = "uu_id" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "selinux", @@ -2620,7 +2620,7 @@ dependencies = [ [[package]] name = "uu_install" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "file_diff", @@ -2631,7 +2631,7 @@ dependencies = [ [[package]] name = "uu_join" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "memchr", @@ -2640,7 +2640,7 @@ dependencies = [ [[package]] name = "uu_kill" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "nix", @@ -2649,7 +2649,7 @@ dependencies = [ [[package]] name = "uu_link" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2657,7 +2657,7 @@ dependencies = [ [[package]] name = "uu_ln" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2665,7 +2665,7 @@ dependencies = [ [[package]] name = "uu_logname" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2674,7 +2674,7 @@ dependencies = [ [[package]] name = "uu_ls" -version = "0.0.20" +version = "0.0.21" dependencies = [ "chrono", "clap", @@ -2692,7 +2692,7 @@ dependencies = [ [[package]] name = "uu_mkdir" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2700,7 +2700,7 @@ dependencies = [ [[package]] name = "uu_mkfifo" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2709,7 +2709,7 @@ dependencies = [ [[package]] name = "uu_mknod" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2718,7 +2718,7 @@ dependencies = [ [[package]] name = "uu_mktemp" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "rand", @@ -2728,7 +2728,7 @@ dependencies = [ [[package]] name = "uu_more" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "crossterm", @@ -2741,7 +2741,7 @@ dependencies = [ [[package]] name = "uu_mv" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "fs_extra", @@ -2751,7 +2751,7 @@ dependencies = [ [[package]] name = "uu_nice" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2761,7 +2761,7 @@ dependencies = [ [[package]] name = "uu_nl" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "regex", @@ -2770,7 +2770,7 @@ dependencies = [ [[package]] name = "uu_nohup" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "is-terminal", @@ -2780,7 +2780,7 @@ dependencies = [ [[package]] name = "uu_nproc" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2789,7 +2789,7 @@ dependencies = [ [[package]] name = "uu_numfmt" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2797,7 +2797,7 @@ dependencies = [ [[package]] name = "uu_od" -version = "0.0.20" +version = "0.0.21" dependencies = [ "byteorder", "clap", @@ -2807,7 +2807,7 @@ dependencies = [ [[package]] name = "uu_paste" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2815,7 +2815,7 @@ dependencies = [ [[package]] name = "uu_pathchk" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2824,7 +2824,7 @@ dependencies = [ [[package]] name = "uu_pinky" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2832,7 +2832,7 @@ dependencies = [ [[package]] name = "uu_pr" -version = "0.0.20" +version = "0.0.21" dependencies = [ "chrono", "clap", @@ -2844,7 +2844,7 @@ dependencies = [ [[package]] name = "uu_printenv" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2852,7 +2852,7 @@ dependencies = [ [[package]] name = "uu_printf" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2860,7 +2860,7 @@ dependencies = [ [[package]] name = "uu_ptx" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "regex", @@ -2869,7 +2869,7 @@ dependencies = [ [[package]] name = "uu_pwd" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2877,7 +2877,7 @@ dependencies = [ [[package]] name = "uu_readlink" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2885,7 +2885,7 @@ dependencies = [ [[package]] name = "uu_realpath" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2893,7 +2893,7 @@ dependencies = [ [[package]] name = "uu_relpath" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -2901,7 +2901,7 @@ dependencies = [ [[package]] name = "uu_rm" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2912,7 +2912,7 @@ dependencies = [ [[package]] name = "uu_rmdir" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2921,7 +2921,7 @@ dependencies = [ [[package]] name = "uu_runcon" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2932,7 +2932,7 @@ dependencies = [ [[package]] name = "uu_seq" -version = "0.0.20" +version = "0.0.21" dependencies = [ "bigdecimal", "clap", @@ -2943,7 +2943,7 @@ dependencies = [ [[package]] name = "uu_shred" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -2953,7 +2953,7 @@ dependencies = [ [[package]] name = "uu_shuf" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "memchr", @@ -2964,7 +2964,7 @@ dependencies = [ [[package]] name = "uu_sleep" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "fundu", @@ -2973,7 +2973,7 @@ dependencies = [ [[package]] name = "uu_sort" -version = "0.0.20" +version = "0.0.21" dependencies = [ "binary-heap-plus", "clap", @@ -2992,7 +2992,7 @@ dependencies = [ [[package]] name = "uu_split" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "memchr", @@ -3001,7 +3001,7 @@ dependencies = [ [[package]] name = "uu_stat" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -3009,7 +3009,7 @@ dependencies = [ [[package]] name = "uu_stdbuf" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "tempfile", @@ -3019,7 +3019,7 @@ dependencies = [ [[package]] name = "uu_stdbuf_libstdbuf" -version = "0.0.20" +version = "0.0.21" dependencies = [ "cpp", "cpp_build", @@ -3029,7 +3029,7 @@ dependencies = [ [[package]] name = "uu_stty" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "nix", @@ -3038,7 +3038,7 @@ dependencies = [ [[package]] name = "uu_sum" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -3046,7 +3046,7 @@ dependencies = [ [[package]] name = "uu_sync" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -3057,7 +3057,7 @@ dependencies = [ [[package]] name = "uu_tac" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "memchr", @@ -3068,7 +3068,7 @@ dependencies = [ [[package]] name = "uu_tail" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "fundu", @@ -3085,7 +3085,7 @@ dependencies = [ [[package]] name = "uu_tee" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -3094,7 +3094,7 @@ dependencies = [ [[package]] name = "uu_test" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -3104,7 +3104,7 @@ dependencies = [ [[package]] name = "uu_timeout" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -3114,7 +3114,7 @@ dependencies = [ [[package]] name = "uu_touch" -version = "0.0.20" +version = "0.0.21" dependencies = [ "chrono", "clap", @@ -3126,7 +3126,7 @@ dependencies = [ [[package]] name = "uu_tr" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "nom", @@ -3135,7 +3135,7 @@ dependencies = [ [[package]] name = "uu_true" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -3143,7 +3143,7 @@ dependencies = [ [[package]] name = "uu_truncate" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -3151,7 +3151,7 @@ dependencies = [ [[package]] name = "uu_tsort" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -3159,7 +3159,7 @@ dependencies = [ [[package]] name = "uu_tty" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "is-terminal", @@ -3169,7 +3169,7 @@ dependencies = [ [[package]] name = "uu_uname" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "platform-info", @@ -3178,7 +3178,7 @@ dependencies = [ [[package]] name = "uu_unexpand" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "unicode-width", @@ -3187,7 +3187,7 @@ dependencies = [ [[package]] name = "uu_uniq" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -3195,7 +3195,7 @@ dependencies = [ [[package]] name = "uu_unlink" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -3203,7 +3203,7 @@ dependencies = [ [[package]] name = "uu_uptime" -version = "0.0.20" +version = "0.0.21" dependencies = [ "chrono", "clap", @@ -3212,7 +3212,7 @@ dependencies = [ [[package]] name = "uu_users" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -3220,7 +3220,7 @@ dependencies = [ [[package]] name = "uu_vdir" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uu_ls", @@ -3229,7 +3229,7 @@ dependencies = [ [[package]] name = "uu_wc" -version = "0.0.20" +version = "0.0.21" dependencies = [ "bytecount", "clap", @@ -3242,7 +3242,7 @@ dependencies = [ [[package]] name = "uu_who" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "uucore", @@ -3250,7 +3250,7 @@ dependencies = [ [[package]] name = "uu_whoami" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "libc", @@ -3260,7 +3260,7 @@ dependencies = [ [[package]] name = "uu_yes" -version = "0.0.20" +version = "0.0.21" dependencies = [ "clap", "itertools", @@ -3270,7 +3270,7 @@ dependencies = [ [[package]] name = "uucore" -version = "0.0.20" +version = "0.0.21" dependencies = [ "blake2b_simd", "blake3", @@ -3306,7 +3306,7 @@ dependencies = [ [[package]] name = "uucore_procs" -version = "0.0.20" +version = "0.0.21" dependencies = [ "proc-macro2", "quote", @@ -3315,7 +3315,7 @@ dependencies = [ [[package]] name = "uuhelp_parser" -version = "0.0.20" +version = "0.0.21" [[package]] name = "uuid" diff --git a/Cargo.toml b/Cargo.toml index 3adac7a9f..320aa0f43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ [package] name = "coreutils" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "coreutils ~ GNU coreutils (updated); implemented as universal (cross-platform) utils, written in Rust" @@ -363,110 +363,110 @@ zip = { workspace = true, optional = true } uuhelp_parser = { optional = true, version = ">=0.0.19", path = "src/uuhelp_parser" } # * uutils -uu_test = { optional = true, version = "0.0.20", package = "uu_test", path = "src/uu/test" } +uu_test = { optional = true, version = "0.0.21", package = "uu_test", path = "src/uu/test" } # -arch = { optional = true, version = "0.0.20", package = "uu_arch", path = "src/uu/arch" } -base32 = { optional = true, version = "0.0.20", package = "uu_base32", path = "src/uu/base32" } -base64 = { optional = true, version = "0.0.20", package = "uu_base64", path = "src/uu/base64" } -basename = { optional = true, version = "0.0.20", package = "uu_basename", path = "src/uu/basename" } -basenc = { optional = true, version = "0.0.20", package = "uu_basenc", path = "src/uu/basenc" } -cat = { optional = true, version = "0.0.20", package = "uu_cat", path = "src/uu/cat" } -chcon = { optional = true, version = "0.0.20", package = "uu_chcon", path = "src/uu/chcon" } -chgrp = { optional = true, version = "0.0.20", package = "uu_chgrp", path = "src/uu/chgrp" } -chmod = { optional = true, version = "0.0.20", package = "uu_chmod", path = "src/uu/chmod" } -chown = { optional = true, version = "0.0.20", package = "uu_chown", path = "src/uu/chown" } -chroot = { optional = true, version = "0.0.20", package = "uu_chroot", path = "src/uu/chroot" } -cksum = { optional = true, version = "0.0.20", package = "uu_cksum", path = "src/uu/cksum" } -comm = { optional = true, version = "0.0.20", package = "uu_comm", path = "src/uu/comm" } -cp = { optional = true, version = "0.0.20", package = "uu_cp", path = "src/uu/cp" } -csplit = { optional = true, version = "0.0.20", package = "uu_csplit", path = "src/uu/csplit" } -cut = { optional = true, version = "0.0.20", package = "uu_cut", path = "src/uu/cut" } -date = { optional = true, version = "0.0.20", package = "uu_date", path = "src/uu/date" } -dd = { optional = true, version = "0.0.20", package = "uu_dd", path = "src/uu/dd" } -df = { optional = true, version = "0.0.20", package = "uu_df", path = "src/uu/df" } -dir = { optional = true, version = "0.0.20", package = "uu_dir", path = "src/uu/dir" } -dircolors = { optional = true, version = "0.0.20", package = "uu_dircolors", path = "src/uu/dircolors" } -dirname = { optional = true, version = "0.0.20", package = "uu_dirname", path = "src/uu/dirname" } -du = { optional = true, version = "0.0.20", package = "uu_du", path = "src/uu/du" } -echo = { optional = true, version = "0.0.20", package = "uu_echo", path = "src/uu/echo" } -env = { optional = true, version = "0.0.20", package = "uu_env", path = "src/uu/env" } -expand = { optional = true, version = "0.0.20", package = "uu_expand", path = "src/uu/expand" } -expr = { optional = true, version = "0.0.20", package = "uu_expr", path = "src/uu/expr" } -factor = { optional = true, version = "0.0.20", package = "uu_factor", path = "src/uu/factor" } -false = { optional = true, version = "0.0.20", package = "uu_false", path = "src/uu/false" } -fmt = { optional = true, version = "0.0.20", package = "uu_fmt", path = "src/uu/fmt" } -fold = { optional = true, version = "0.0.20", package = "uu_fold", path = "src/uu/fold" } -groups = { optional = true, version = "0.0.20", package = "uu_groups", path = "src/uu/groups" } -hashsum = { optional = true, version = "0.0.20", package = "uu_hashsum", path = "src/uu/hashsum" } -head = { optional = true, version = "0.0.20", package = "uu_head", path = "src/uu/head" } -hostid = { optional = true, version = "0.0.20", package = "uu_hostid", path = "src/uu/hostid" } -hostname = { optional = true, version = "0.0.20", package = "uu_hostname", path = "src/uu/hostname" } -id = { optional = true, version = "0.0.20", package = "uu_id", path = "src/uu/id" } -install = { optional = true, version = "0.0.20", package = "uu_install", path = "src/uu/install" } -join = { optional = true, version = "0.0.20", package = "uu_join", path = "src/uu/join" } -kill = { optional = true, version = "0.0.20", package = "uu_kill", path = "src/uu/kill" } -link = { optional = true, version = "0.0.20", package = "uu_link", path = "src/uu/link" } -ln = { optional = true, version = "0.0.20", package = "uu_ln", path = "src/uu/ln" } -ls = { optional = true, version = "0.0.20", package = "uu_ls", path = "src/uu/ls" } -logname = { optional = true, version = "0.0.20", package = "uu_logname", path = "src/uu/logname" } -mkdir = { optional = true, version = "0.0.20", package = "uu_mkdir", path = "src/uu/mkdir" } -mkfifo = { optional = true, version = "0.0.20", package = "uu_mkfifo", path = "src/uu/mkfifo" } -mknod = { optional = true, version = "0.0.20", package = "uu_mknod", path = "src/uu/mknod" } -mktemp = { optional = true, version = "0.0.20", package = "uu_mktemp", path = "src/uu/mktemp" } -more = { optional = true, version = "0.0.20", package = "uu_more", path = "src/uu/more" } -mv = { optional = true, version = "0.0.20", package = "uu_mv", path = "src/uu/mv" } -nice = { optional = true, version = "0.0.20", package = "uu_nice", path = "src/uu/nice" } -nl = { optional = true, version = "0.0.20", package = "uu_nl", path = "src/uu/nl" } -nohup = { optional = true, version = "0.0.20", package = "uu_nohup", path = "src/uu/nohup" } -nproc = { optional = true, version = "0.0.20", package = "uu_nproc", path = "src/uu/nproc" } -numfmt = { optional = true, version = "0.0.20", package = "uu_numfmt", path = "src/uu/numfmt" } -od = { optional = true, version = "0.0.20", package = "uu_od", path = "src/uu/od" } -paste = { optional = true, version = "0.0.20", package = "uu_paste", path = "src/uu/paste" } -pathchk = { optional = true, version = "0.0.20", package = "uu_pathchk", path = "src/uu/pathchk" } -pinky = { optional = true, version = "0.0.20", package = "uu_pinky", path = "src/uu/pinky" } -pr = { optional = true, version = "0.0.20", package = "uu_pr", path = "src/uu/pr" } -printenv = { optional = true, version = "0.0.20", package = "uu_printenv", path = "src/uu/printenv" } -printf = { optional = true, version = "0.0.20", package = "uu_printf", path = "src/uu/printf" } -ptx = { optional = true, version = "0.0.20", package = "uu_ptx", path = "src/uu/ptx" } -pwd = { optional = true, version = "0.0.20", package = "uu_pwd", path = "src/uu/pwd" } -readlink = { optional = true, version = "0.0.20", package = "uu_readlink", path = "src/uu/readlink" } -realpath = { optional = true, version = "0.0.20", package = "uu_realpath", path = "src/uu/realpath" } -relpath = { optional = true, version = "0.0.20", package = "uu_relpath", path = "src/uu/relpath" } -rm = { optional = true, version = "0.0.20", package = "uu_rm", path = "src/uu/rm" } -rmdir = { optional = true, version = "0.0.20", package = "uu_rmdir", path = "src/uu/rmdir" } -runcon = { optional = true, version = "0.0.20", package = "uu_runcon", path = "src/uu/runcon" } -seq = { optional = true, version = "0.0.20", package = "uu_seq", path = "src/uu/seq" } -shred = { optional = true, version = "0.0.20", package = "uu_shred", path = "src/uu/shred" } -shuf = { optional = true, version = "0.0.20", package = "uu_shuf", path = "src/uu/shuf" } -sleep = { optional = true, version = "0.0.20", package = "uu_sleep", path = "src/uu/sleep" } -sort = { optional = true, version = "0.0.20", package = "uu_sort", path = "src/uu/sort" } -split = { optional = true, version = "0.0.20", package = "uu_split", path = "src/uu/split" } -stat = { optional = true, version = "0.0.20", package = "uu_stat", path = "src/uu/stat" } -stdbuf = { optional = true, version = "0.0.20", package = "uu_stdbuf", path = "src/uu/stdbuf" } -stty = { optional = true, version = "0.0.20", package = "uu_stty", path = "src/uu/stty" } -sum = { optional = true, version = "0.0.20", package = "uu_sum", path = "src/uu/sum" } -sync = { optional = true, version = "0.0.20", package = "uu_sync", path = "src/uu/sync" } -tac = { optional = true, version = "0.0.20", package = "uu_tac", path = "src/uu/tac" } -tail = { optional = true, version = "0.0.20", package = "uu_tail", path = "src/uu/tail" } -tee = { optional = true, version = "0.0.20", package = "uu_tee", path = "src/uu/tee" } -timeout = { optional = true, version = "0.0.20", package = "uu_timeout", path = "src/uu/timeout" } -touch = { optional = true, version = "0.0.20", package = "uu_touch", path = "src/uu/touch" } -tr = { optional = true, version = "0.0.20", package = "uu_tr", path = "src/uu/tr" } -true = { optional = true, version = "0.0.20", package = "uu_true", path = "src/uu/true" } -truncate = { optional = true, version = "0.0.20", package = "uu_truncate", path = "src/uu/truncate" } -tsort = { optional = true, version = "0.0.20", package = "uu_tsort", path = "src/uu/tsort" } -tty = { optional = true, version = "0.0.20", package = "uu_tty", path = "src/uu/tty" } -uname = { optional = true, version = "0.0.20", package = "uu_uname", path = "src/uu/uname" } -unexpand = { optional = true, version = "0.0.20", package = "uu_unexpand", path = "src/uu/unexpand" } -uniq = { optional = true, version = "0.0.20", package = "uu_uniq", path = "src/uu/uniq" } -unlink = { optional = true, version = "0.0.20", package = "uu_unlink", path = "src/uu/unlink" } -uptime = { optional = true, version = "0.0.20", package = "uu_uptime", path = "src/uu/uptime" } -users = { optional = true, version = "0.0.20", package = "uu_users", path = "src/uu/users" } -vdir = { optional = true, version = "0.0.20", package = "uu_vdir", path = "src/uu/vdir" } -wc = { optional = true, version = "0.0.20", package = "uu_wc", path = "src/uu/wc" } -who = { optional = true, version = "0.0.20", package = "uu_who", path = "src/uu/who" } -whoami = { optional = true, version = "0.0.20", package = "uu_whoami", path = "src/uu/whoami" } -yes = { optional = true, version = "0.0.20", package = "uu_yes", path = "src/uu/yes" } +arch = { optional = true, version = "0.0.21", package = "uu_arch", path = "src/uu/arch" } +base32 = { optional = true, version = "0.0.21", package = "uu_base32", path = "src/uu/base32" } +base64 = { optional = true, version = "0.0.21", package = "uu_base64", path = "src/uu/base64" } +basename = { optional = true, version = "0.0.21", package = "uu_basename", path = "src/uu/basename" } +basenc = { optional = true, version = "0.0.21", package = "uu_basenc", path = "src/uu/basenc" } +cat = { optional = true, version = "0.0.21", package = "uu_cat", path = "src/uu/cat" } +chcon = { optional = true, version = "0.0.21", package = "uu_chcon", path = "src/uu/chcon" } +chgrp = { optional = true, version = "0.0.21", package = "uu_chgrp", path = "src/uu/chgrp" } +chmod = { optional = true, version = "0.0.21", package = "uu_chmod", path = "src/uu/chmod" } +chown = { optional = true, version = "0.0.21", package = "uu_chown", path = "src/uu/chown" } +chroot = { optional = true, version = "0.0.21", package = "uu_chroot", path = "src/uu/chroot" } +cksum = { optional = true, version = "0.0.21", package = "uu_cksum", path = "src/uu/cksum" } +comm = { optional = true, version = "0.0.21", package = "uu_comm", path = "src/uu/comm" } +cp = { optional = true, version = "0.0.21", package = "uu_cp", path = "src/uu/cp" } +csplit = { optional = true, version = "0.0.21", package = "uu_csplit", path = "src/uu/csplit" } +cut = { optional = true, version = "0.0.21", package = "uu_cut", path = "src/uu/cut" } +date = { optional = true, version = "0.0.21", package = "uu_date", path = "src/uu/date" } +dd = { optional = true, version = "0.0.21", package = "uu_dd", path = "src/uu/dd" } +df = { optional = true, version = "0.0.21", package = "uu_df", path = "src/uu/df" } +dir = { optional = true, version = "0.0.21", package = "uu_dir", path = "src/uu/dir" } +dircolors = { optional = true, version = "0.0.21", package = "uu_dircolors", path = "src/uu/dircolors" } +dirname = { optional = true, version = "0.0.21", package = "uu_dirname", path = "src/uu/dirname" } +du = { optional = true, version = "0.0.21", package = "uu_du", path = "src/uu/du" } +echo = { optional = true, version = "0.0.21", package = "uu_echo", path = "src/uu/echo" } +env = { optional = true, version = "0.0.21", package = "uu_env", path = "src/uu/env" } +expand = { optional = true, version = "0.0.21", package = "uu_expand", path = "src/uu/expand" } +expr = { optional = true, version = "0.0.21", package = "uu_expr", path = "src/uu/expr" } +factor = { optional = true, version = "0.0.21", package = "uu_factor", path = "src/uu/factor" } +false = { optional = true, version = "0.0.21", package = "uu_false", path = "src/uu/false" } +fmt = { optional = true, version = "0.0.21", package = "uu_fmt", path = "src/uu/fmt" } +fold = { optional = true, version = "0.0.21", package = "uu_fold", path = "src/uu/fold" } +groups = { optional = true, version = "0.0.21", package = "uu_groups", path = "src/uu/groups" } +hashsum = { optional = true, version = "0.0.21", package = "uu_hashsum", path = "src/uu/hashsum" } +head = { optional = true, version = "0.0.21", package = "uu_head", path = "src/uu/head" } +hostid = { optional = true, version = "0.0.21", package = "uu_hostid", path = "src/uu/hostid" } +hostname = { optional = true, version = "0.0.21", package = "uu_hostname", path = "src/uu/hostname" } +id = { optional = true, version = "0.0.21", package = "uu_id", path = "src/uu/id" } +install = { optional = true, version = "0.0.21", package = "uu_install", path = "src/uu/install" } +join = { optional = true, version = "0.0.21", package = "uu_join", path = "src/uu/join" } +kill = { optional = true, version = "0.0.21", package = "uu_kill", path = "src/uu/kill" } +link = { optional = true, version = "0.0.21", package = "uu_link", path = "src/uu/link" } +ln = { optional = true, version = "0.0.21", package = "uu_ln", path = "src/uu/ln" } +ls = { optional = true, version = "0.0.21", package = "uu_ls", path = "src/uu/ls" } +logname = { optional = true, version = "0.0.21", package = "uu_logname", path = "src/uu/logname" } +mkdir = { optional = true, version = "0.0.21", package = "uu_mkdir", path = "src/uu/mkdir" } +mkfifo = { optional = true, version = "0.0.21", package = "uu_mkfifo", path = "src/uu/mkfifo" } +mknod = { optional = true, version = "0.0.21", package = "uu_mknod", path = "src/uu/mknod" } +mktemp = { optional = true, version = "0.0.21", package = "uu_mktemp", path = "src/uu/mktemp" } +more = { optional = true, version = "0.0.21", package = "uu_more", path = "src/uu/more" } +mv = { optional = true, version = "0.0.21", package = "uu_mv", path = "src/uu/mv" } +nice = { optional = true, version = "0.0.21", package = "uu_nice", path = "src/uu/nice" } +nl = { optional = true, version = "0.0.21", package = "uu_nl", path = "src/uu/nl" } +nohup = { optional = true, version = "0.0.21", package = "uu_nohup", path = "src/uu/nohup" } +nproc = { optional = true, version = "0.0.21", package = "uu_nproc", path = "src/uu/nproc" } +numfmt = { optional = true, version = "0.0.21", package = "uu_numfmt", path = "src/uu/numfmt" } +od = { optional = true, version = "0.0.21", package = "uu_od", path = "src/uu/od" } +paste = { optional = true, version = "0.0.21", package = "uu_paste", path = "src/uu/paste" } +pathchk = { optional = true, version = "0.0.21", package = "uu_pathchk", path = "src/uu/pathchk" } +pinky = { optional = true, version = "0.0.21", package = "uu_pinky", path = "src/uu/pinky" } +pr = { optional = true, version = "0.0.21", package = "uu_pr", path = "src/uu/pr" } +printenv = { optional = true, version = "0.0.21", package = "uu_printenv", path = "src/uu/printenv" } +printf = { optional = true, version = "0.0.21", package = "uu_printf", path = "src/uu/printf" } +ptx = { optional = true, version = "0.0.21", package = "uu_ptx", path = "src/uu/ptx" } +pwd = { optional = true, version = "0.0.21", package = "uu_pwd", path = "src/uu/pwd" } +readlink = { optional = true, version = "0.0.21", package = "uu_readlink", path = "src/uu/readlink" } +realpath = { optional = true, version = "0.0.21", package = "uu_realpath", path = "src/uu/realpath" } +relpath = { optional = true, version = "0.0.21", package = "uu_relpath", path = "src/uu/relpath" } +rm = { optional = true, version = "0.0.21", package = "uu_rm", path = "src/uu/rm" } +rmdir = { optional = true, version = "0.0.21", package = "uu_rmdir", path = "src/uu/rmdir" } +runcon = { optional = true, version = "0.0.21", package = "uu_runcon", path = "src/uu/runcon" } +seq = { optional = true, version = "0.0.21", package = "uu_seq", path = "src/uu/seq" } +shred = { optional = true, version = "0.0.21", package = "uu_shred", path = "src/uu/shred" } +shuf = { optional = true, version = "0.0.21", package = "uu_shuf", path = "src/uu/shuf" } +sleep = { optional = true, version = "0.0.21", package = "uu_sleep", path = "src/uu/sleep" } +sort = { optional = true, version = "0.0.21", package = "uu_sort", path = "src/uu/sort" } +split = { optional = true, version = "0.0.21", package = "uu_split", path = "src/uu/split" } +stat = { optional = true, version = "0.0.21", package = "uu_stat", path = "src/uu/stat" } +stdbuf = { optional = true, version = "0.0.21", package = "uu_stdbuf", path = "src/uu/stdbuf" } +stty = { optional = true, version = "0.0.21", package = "uu_stty", path = "src/uu/stty" } +sum = { optional = true, version = "0.0.21", package = "uu_sum", path = "src/uu/sum" } +sync = { optional = true, version = "0.0.21", package = "uu_sync", path = "src/uu/sync" } +tac = { optional = true, version = "0.0.21", package = "uu_tac", path = "src/uu/tac" } +tail = { optional = true, version = "0.0.21", package = "uu_tail", path = "src/uu/tail" } +tee = { optional = true, version = "0.0.21", package = "uu_tee", path = "src/uu/tee" } +timeout = { optional = true, version = "0.0.21", package = "uu_timeout", path = "src/uu/timeout" } +touch = { optional = true, version = "0.0.21", package = "uu_touch", path = "src/uu/touch" } +tr = { optional = true, version = "0.0.21", package = "uu_tr", path = "src/uu/tr" } +true = { optional = true, version = "0.0.21", package = "uu_true", path = "src/uu/true" } +truncate = { optional = true, version = "0.0.21", package = "uu_truncate", path = "src/uu/truncate" } +tsort = { optional = true, version = "0.0.21", package = "uu_tsort", path = "src/uu/tsort" } +tty = { optional = true, version = "0.0.21", package = "uu_tty", path = "src/uu/tty" } +uname = { optional = true, version = "0.0.21", package = "uu_uname", path = "src/uu/uname" } +unexpand = { optional = true, version = "0.0.21", package = "uu_unexpand", path = "src/uu/unexpand" } +uniq = { optional = true, version = "0.0.21", package = "uu_uniq", path = "src/uu/uniq" } +unlink = { optional = true, version = "0.0.21", package = "uu_unlink", path = "src/uu/unlink" } +uptime = { optional = true, version = "0.0.21", package = "uu_uptime", path = "src/uu/uptime" } +users = { optional = true, version = "0.0.21", package = "uu_users", path = "src/uu/users" } +vdir = { optional = true, version = "0.0.21", package = "uu_vdir", path = "src/uu/vdir" } +wc = { optional = true, version = "0.0.21", package = "uu_wc", path = "src/uu/wc" } +who = { optional = true, version = "0.0.21", package = "uu_who", path = "src/uu/who" } +whoami = { optional = true, version = "0.0.21", package = "uu_whoami", path = "src/uu/whoami" } +yes = { optional = true, version = "0.0.21", package = "uu_yes", path = "src/uu/yes" } # this breaks clippy linting with: "tests/by-util/test_factor_benches.rs: No such file or directory (os error 2)" # factor_benches = { optional = true, version = "0.0.0", package = "uu_factor_benches", path = "tests/benches/factor" } diff --git a/src/uu/arch/Cargo.toml b/src/uu/arch/Cargo.toml index 35e7e3892..cd12cb4d4 100644 --- a/src/uu/arch/Cargo.toml +++ b/src/uu/arch/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_arch" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "arch ~ (uutils) display machine architecture" diff --git a/src/uu/base32/Cargo.toml b/src/uu/base32/Cargo.toml index 97c853eb6..044b92d23 100644 --- a/src/uu/base32/Cargo.toml +++ b/src/uu/base32/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_base32" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "base32 ~ (uutils) decode/encode input (base32-encoding)" diff --git a/src/uu/base64/Cargo.toml b/src/uu/base64/Cargo.toml index ef4a063fe..3bc045152 100644 --- a/src/uu/base64/Cargo.toml +++ b/src/uu/base64/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_base64" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "base64 ~ (uutils) decode/encode input (base64-encoding)" diff --git a/src/uu/basename/Cargo.toml b/src/uu/basename/Cargo.toml index 4fd2b6f8c..878a5d9e1 100644 --- a/src/uu/basename/Cargo.toml +++ b/src/uu/basename/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_basename" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "basename ~ (uutils) display PATHNAME with leading directory components removed" diff --git a/src/uu/basenc/Cargo.toml b/src/uu/basenc/Cargo.toml index 4676a6d8f..92912e5df 100644 --- a/src/uu/basenc/Cargo.toml +++ b/src/uu/basenc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_basenc" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "basenc ~ (uutils) decode/encode input" diff --git a/src/uu/cat/Cargo.toml b/src/uu/cat/Cargo.toml index 636e3bfef..d67cd1b25 100644 --- a/src/uu/cat/Cargo.toml +++ b/src/uu/cat/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cat" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "cat ~ (uutils) concatenate and display input" diff --git a/src/uu/chcon/Cargo.toml b/src/uu/chcon/Cargo.toml index f621aa012..c83c8abfc 100644 --- a/src/uu/chcon/Cargo.toml +++ b/src/uu/chcon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chcon" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "chcon ~ (uutils) change file security context" diff --git a/src/uu/chgrp/Cargo.toml b/src/uu/chgrp/Cargo.toml index 9ca3dc26a..7f43e8466 100644 --- a/src/uu/chgrp/Cargo.toml +++ b/src/uu/chgrp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chgrp" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "chgrp ~ (uutils) change the group ownership of FILE" diff --git a/src/uu/chmod/Cargo.toml b/src/uu/chmod/Cargo.toml index a788e83ca..2a9c73d9d 100644 --- a/src/uu/chmod/Cargo.toml +++ b/src/uu/chmod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chmod" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "chmod ~ (uutils) change mode of FILE" diff --git a/src/uu/chown/Cargo.toml b/src/uu/chown/Cargo.toml index 3b92e288e..82b32875d 100644 --- a/src/uu/chown/Cargo.toml +++ b/src/uu/chown/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chown" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "chown ~ (uutils) change the ownership of FILE" diff --git a/src/uu/chroot/Cargo.toml b/src/uu/chroot/Cargo.toml index d2f58320d..3c836add8 100644 --- a/src/uu/chroot/Cargo.toml +++ b/src/uu/chroot/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chroot" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "chroot ~ (uutils) run COMMAND under a new root directory" diff --git a/src/uu/cksum/Cargo.toml b/src/uu/cksum/Cargo.toml index 70886df05..49a881f70 100644 --- a/src/uu/cksum/Cargo.toml +++ b/src/uu/cksum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cksum" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "cksum ~ (uutils) display CRC and size of input" diff --git a/src/uu/comm/Cargo.toml b/src/uu/comm/Cargo.toml index b86aa4902..e4a1dac82 100644 --- a/src/uu/comm/Cargo.toml +++ b/src/uu/comm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_comm" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "comm ~ (uutils) compare sorted inputs" diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index 83f8dd5c9..177525ff5 100644 --- a/src/uu/cp/Cargo.toml +++ b/src/uu/cp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cp" -version = "0.0.20" +version = "0.0.21" authors = [ "Jordy Dickinson ", "Joshua S. Miller ", diff --git a/src/uu/csplit/Cargo.toml b/src/uu/csplit/Cargo.toml index 051f567b4..ba051ff8a 100644 --- a/src/uu/csplit/Cargo.toml +++ b/src/uu/csplit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_csplit" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "csplit ~ (uutils) Output pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output" diff --git a/src/uu/cut/Cargo.toml b/src/uu/cut/Cargo.toml index 6f37aa336..be3ffe7f0 100644 --- a/src/uu/cut/Cargo.toml +++ b/src/uu/cut/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cut" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "cut ~ (uutils) display byte/field columns of input lines" diff --git a/src/uu/date/Cargo.toml b/src/uu/date/Cargo.toml index de5b5f2a2..7590b0b74 100644 --- a/src/uu/date/Cargo.toml +++ b/src/uu/date/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore datetime [package] name = "uu_date" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "date ~ (uutils) display or set the current time" diff --git a/src/uu/dd/Cargo.toml b/src/uu/dd/Cargo.toml index 0a69ae374..482128e1d 100644 --- a/src/uu/dd/Cargo.toml +++ b/src/uu/dd/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dd" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "dd ~ (uutils) copy and convert files" diff --git a/src/uu/df/Cargo.toml b/src/uu/df/Cargo.toml index 047fe9be0..b547a35d5 100644 --- a/src/uu/df/Cargo.toml +++ b/src/uu/df/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_df" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "df ~ (uutils) display file system information" diff --git a/src/uu/dir/Cargo.toml b/src/uu/dir/Cargo.toml index 7bd144f02..9cc5fbde4 100644 --- a/src/uu/dir/Cargo.toml +++ b/src/uu/dir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dir" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "shortcut to ls -C -b" diff --git a/src/uu/dircolors/Cargo.toml b/src/uu/dircolors/Cargo.toml index f490a4728..9248f5ea1 100644 --- a/src/uu/dircolors/Cargo.toml +++ b/src/uu/dircolors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dircolors" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "dircolors ~ (uutils) display commands to set LS_COLORS" diff --git a/src/uu/dirname/Cargo.toml b/src/uu/dirname/Cargo.toml index 4ac789937..6de444499 100644 --- a/src/uu/dirname/Cargo.toml +++ b/src/uu/dirname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dirname" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "dirname ~ (uutils) display parent directory of PATHNAME" diff --git a/src/uu/du/Cargo.toml b/src/uu/du/Cargo.toml index 041efeaad..c87595db6 100644 --- a/src/uu/du/Cargo.toml +++ b/src/uu/du/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_du" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "du ~ (uutils) display disk usage" diff --git a/src/uu/echo/Cargo.toml b/src/uu/echo/Cargo.toml index a95bcbe82..5d27bae1b 100644 --- a/src/uu/echo/Cargo.toml +++ b/src/uu/echo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_echo" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "echo ~ (uutils) display TEXT" diff --git a/src/uu/env/Cargo.toml b/src/uu/env/Cargo.toml index 551249b77..b2854edbf 100644 --- a/src/uu/env/Cargo.toml +++ b/src/uu/env/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_env" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "env ~ (uutils) set each NAME to VALUE in the environment and run COMMAND" diff --git a/src/uu/expand/Cargo.toml b/src/uu/expand/Cargo.toml index 894a21be0..58647d8e9 100644 --- a/src/uu/expand/Cargo.toml +++ b/src/uu/expand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_expand" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "expand ~ (uutils) convert input tabs to spaces" diff --git a/src/uu/expr/Cargo.toml b/src/uu/expr/Cargo.toml index 3ea796ee0..ae31c6690 100644 --- a/src/uu/expr/Cargo.toml +++ b/src/uu/expr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_expr" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "expr ~ (uutils) display the value of EXPRESSION" diff --git a/src/uu/factor/Cargo.toml b/src/uu/factor/Cargo.toml index c97dbcba4..57b5e9d54 100644 --- a/src/uu/factor/Cargo.toml +++ b/src/uu/factor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_factor" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "factor ~ (uutils) display the prime factors of each NUMBER" diff --git a/src/uu/false/Cargo.toml b/src/uu/false/Cargo.toml index 9eb0ccbb1..80f3553c0 100644 --- a/src/uu/false/Cargo.toml +++ b/src/uu/false/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_false" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "false ~ (uutils) do nothing and fail" diff --git a/src/uu/fmt/Cargo.toml b/src/uu/fmt/Cargo.toml index cabb144cf..5b181937b 100644 --- a/src/uu/fmt/Cargo.toml +++ b/src/uu/fmt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_fmt" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "fmt ~ (uutils) reformat each paragraph of input" diff --git a/src/uu/fold/Cargo.toml b/src/uu/fold/Cargo.toml index a476e0f13..ff2f2f6d5 100644 --- a/src/uu/fold/Cargo.toml +++ b/src/uu/fold/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_fold" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "fold ~ (uutils) wrap each line of input" diff --git a/src/uu/groups/Cargo.toml b/src/uu/groups/Cargo.toml index 989dc9c11..d503d3e83 100644 --- a/src/uu/groups/Cargo.toml +++ b/src/uu/groups/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_groups" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "groups ~ (uutils) display group memberships for USERNAME" diff --git a/src/uu/hashsum/Cargo.toml b/src/uu/hashsum/Cargo.toml index cca2dbfe1..1b075fb48 100644 --- a/src/uu/hashsum/Cargo.toml +++ b/src/uu/hashsum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hashsum" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "hashsum ~ (uutils) display or check input digests" diff --git a/src/uu/head/Cargo.toml b/src/uu/head/Cargo.toml index 6326fcd8b..bdbe45dc1 100644 --- a/src/uu/head/Cargo.toml +++ b/src/uu/head/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_head" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "head ~ (uutils) display the first lines of input" diff --git a/src/uu/hostid/Cargo.toml b/src/uu/hostid/Cargo.toml index 298a9da69..f34fee820 100644 --- a/src/uu/hostid/Cargo.toml +++ b/src/uu/hostid/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hostid" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "hostid ~ (uutils) display the numeric identifier of the current host" diff --git a/src/uu/hostname/Cargo.toml b/src/uu/hostname/Cargo.toml index d28f2511f..8e36e672a 100644 --- a/src/uu/hostname/Cargo.toml +++ b/src/uu/hostname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hostname" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "hostname ~ (uutils) display or set the host name of the current host" diff --git a/src/uu/id/Cargo.toml b/src/uu/id/Cargo.toml index bd80a447c..77cda20be 100644 --- a/src/uu/id/Cargo.toml +++ b/src/uu/id/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_id" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "id ~ (uutils) display user and group information for USER" diff --git a/src/uu/install/Cargo.toml b/src/uu/install/Cargo.toml index f24c7c40d..e66cbeb72 100644 --- a/src/uu/install/Cargo.toml +++ b/src/uu/install/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_install" -version = "0.0.20" +version = "0.0.21" authors = ["Ben Eills ", "uutils developers"] license = "MIT" description = "install ~ (uutils) copy files from SOURCE to DESTINATION (with specified attributes)" diff --git a/src/uu/join/Cargo.toml b/src/uu/join/Cargo.toml index a06303c24..971f8e455 100644 --- a/src/uu/join/Cargo.toml +++ b/src/uu/join/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_join" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "join ~ (uutils) merge lines from inputs with matching join fields" diff --git a/src/uu/kill/Cargo.toml b/src/uu/kill/Cargo.toml index 8db333e4a..a675f00ed 100644 --- a/src/uu/kill/Cargo.toml +++ b/src/uu/kill/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_kill" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "kill ~ (uutils) send a signal to a process" diff --git a/src/uu/link/Cargo.toml b/src/uu/link/Cargo.toml index abac74b3f..2406476ca 100644 --- a/src/uu/link/Cargo.toml +++ b/src/uu/link/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_link" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "link ~ (uutils) create a hard (file system) link to FILE" diff --git a/src/uu/ln/Cargo.toml b/src/uu/ln/Cargo.toml index d66338d44..6488963cc 100644 --- a/src/uu/ln/Cargo.toml +++ b/src/uu/ln/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ln" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "ln ~ (uutils) create a (file system) link to TARGET" diff --git a/src/uu/logname/Cargo.toml b/src/uu/logname/Cargo.toml index 85cfb766a..29116455b 100644 --- a/src/uu/logname/Cargo.toml +++ b/src/uu/logname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_logname" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "logname ~ (uutils) display the login name of the current user" diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index 6122460fc..b1114644d 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ls" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "ls ~ (uutils) display directory contents" diff --git a/src/uu/mkdir/Cargo.toml b/src/uu/mkdir/Cargo.toml index d971d4eaf..c1a6ce2a8 100644 --- a/src/uu/mkdir/Cargo.toml +++ b/src/uu/mkdir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mkdir" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "mkdir ~ (uutils) create DIRECTORY" diff --git a/src/uu/mkfifo/Cargo.toml b/src/uu/mkfifo/Cargo.toml index 21b00ffe7..0c28f52de 100644 --- a/src/uu/mkfifo/Cargo.toml +++ b/src/uu/mkfifo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mkfifo" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "mkfifo ~ (uutils) create FIFOs (named pipes)" diff --git a/src/uu/mknod/Cargo.toml b/src/uu/mknod/Cargo.toml index 266c23629..a230bec74 100644 --- a/src/uu/mknod/Cargo.toml +++ b/src/uu/mknod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mknod" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "mknod ~ (uutils) create special file NAME of TYPE" diff --git a/src/uu/mktemp/Cargo.toml b/src/uu/mktemp/Cargo.toml index 9d4825559..5dbc8492a 100644 --- a/src/uu/mktemp/Cargo.toml +++ b/src/uu/mktemp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mktemp" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "mktemp ~ (uutils) create and display a temporary file or directory from TEMPLATE" diff --git a/src/uu/more/Cargo.toml b/src/uu/more/Cargo.toml index 0b7eb0763..ef2240133 100644 --- a/src/uu/more/Cargo.toml +++ b/src/uu/more/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_more" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "more ~ (uutils) input perusal filter" diff --git a/src/uu/mv/Cargo.toml b/src/uu/mv/Cargo.toml index 25fa272d6..b7fcf2d10 100644 --- a/src/uu/mv/Cargo.toml +++ b/src/uu/mv/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mv" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "mv ~ (uutils) move (rename) SOURCE to DESTINATION" diff --git a/src/uu/nice/Cargo.toml b/src/uu/nice/Cargo.toml index 1f6a560ff..65e1520d1 100644 --- a/src/uu/nice/Cargo.toml +++ b/src/uu/nice/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nice" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "nice ~ (uutils) run PROGRAM with modified scheduling priority" diff --git a/src/uu/nl/Cargo.toml b/src/uu/nl/Cargo.toml index 376600703..db2bfacbd 100644 --- a/src/uu/nl/Cargo.toml +++ b/src/uu/nl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nl" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "nl ~ (uutils) display input with added line numbers" diff --git a/src/uu/nohup/Cargo.toml b/src/uu/nohup/Cargo.toml index b7e4c395a..2a454b9f4 100644 --- a/src/uu/nohup/Cargo.toml +++ b/src/uu/nohup/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nohup" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "nohup ~ (uutils) run COMMAND, ignoring hangup signals" diff --git a/src/uu/nproc/Cargo.toml b/src/uu/nproc/Cargo.toml index 7fad14274..b6052de2e 100644 --- a/src/uu/nproc/Cargo.toml +++ b/src/uu/nproc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nproc" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "nproc ~ (uutils) display the number of processing units available" diff --git a/src/uu/numfmt/Cargo.toml b/src/uu/numfmt/Cargo.toml index 6cf0f4320..c334a53e3 100644 --- a/src/uu/numfmt/Cargo.toml +++ b/src/uu/numfmt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_numfmt" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "numfmt ~ (uutils) reformat NUMBER" diff --git a/src/uu/od/Cargo.toml b/src/uu/od/Cargo.toml index 7bb597ab3..d369456f3 100644 --- a/src/uu/od/Cargo.toml +++ b/src/uu/od/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_od" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "od ~ (uutils) display formatted representation of input" diff --git a/src/uu/paste/Cargo.toml b/src/uu/paste/Cargo.toml index 7d6ed229e..d93d4cbb6 100644 --- a/src/uu/paste/Cargo.toml +++ b/src/uu/paste/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_paste" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "paste ~ (uutils) merge lines from inputs" diff --git a/src/uu/pathchk/Cargo.toml b/src/uu/pathchk/Cargo.toml index b8f4f0310..f62c027c4 100644 --- a/src/uu/pathchk/Cargo.toml +++ b/src/uu/pathchk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pathchk" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "pathchk ~ (uutils) diagnose invalid or non-portable PATHNAME" diff --git a/src/uu/pinky/Cargo.toml b/src/uu/pinky/Cargo.toml index 8566faf68..f6d291e26 100644 --- a/src/uu/pinky/Cargo.toml +++ b/src/uu/pinky/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pinky" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "pinky ~ (uutils) display user information" diff --git a/src/uu/pr/Cargo.toml b/src/uu/pr/Cargo.toml index 71e843a84..4453d1cba 100644 --- a/src/uu/pr/Cargo.toml +++ b/src/uu/pr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pr" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "pr ~ (uutils) convert text files for printing" diff --git a/src/uu/printenv/Cargo.toml b/src/uu/printenv/Cargo.toml index 11666bd61..729658110 100644 --- a/src/uu/printenv/Cargo.toml +++ b/src/uu/printenv/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_printenv" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "printenv ~ (uutils) display value of environment VAR" diff --git a/src/uu/printf/Cargo.toml b/src/uu/printf/Cargo.toml index eefcf33c0..d55d3732a 100644 --- a/src/uu/printf/Cargo.toml +++ b/src/uu/printf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_printf" -version = "0.0.20" +version = "0.0.21" authors = ["Nathan Ross", "uutils developers"] license = "MIT" description = "printf ~ (uutils) FORMAT and display ARGUMENTS" diff --git a/src/uu/ptx/Cargo.toml b/src/uu/ptx/Cargo.toml index e9b11223c..96d635caf 100644 --- a/src/uu/ptx/Cargo.toml +++ b/src/uu/ptx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ptx" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "ptx ~ (uutils) display a permuted index of input" diff --git a/src/uu/pwd/Cargo.toml b/src/uu/pwd/Cargo.toml index 09989d079..1567a935f 100644 --- a/src/uu/pwd/Cargo.toml +++ b/src/uu/pwd/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pwd" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "pwd ~ (uutils) display current working directory" diff --git a/src/uu/readlink/Cargo.toml b/src/uu/readlink/Cargo.toml index ba407d9cc..309d40794 100644 --- a/src/uu/readlink/Cargo.toml +++ b/src/uu/readlink/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_readlink" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "readlink ~ (uutils) display resolved path of PATHNAME" diff --git a/src/uu/realpath/Cargo.toml b/src/uu/realpath/Cargo.toml index 802941cd1..e458bf89d 100644 --- a/src/uu/realpath/Cargo.toml +++ b/src/uu/realpath/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_realpath" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "realpath ~ (uutils) display resolved absolute path of PATHNAME" diff --git a/src/uu/relpath/Cargo.toml b/src/uu/relpath/Cargo.toml index 62d47e83a..0df32efd2 100644 --- a/src/uu/relpath/Cargo.toml +++ b/src/uu/relpath/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_relpath" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "relpath ~ (uutils) display relative path of PATHNAME_TO from PATHNAME_FROM" diff --git a/src/uu/rm/Cargo.toml b/src/uu/rm/Cargo.toml index 2807d2d5b..87fccbfa8 100644 --- a/src/uu/rm/Cargo.toml +++ b/src/uu/rm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_rm" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "rm ~ (uutils) remove PATHNAME" diff --git a/src/uu/rmdir/Cargo.toml b/src/uu/rmdir/Cargo.toml index 4579cce0a..41d2f7432 100644 --- a/src/uu/rmdir/Cargo.toml +++ b/src/uu/rmdir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_rmdir" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "rmdir ~ (uutils) remove empty DIRECTORY" diff --git a/src/uu/runcon/Cargo.toml b/src/uu/runcon/Cargo.toml index 9ea9dc769..ac4ec54d5 100644 --- a/src/uu/runcon/Cargo.toml +++ b/src/uu/runcon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_runcon" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "runcon ~ (uutils) run command with specified security context" diff --git a/src/uu/seq/Cargo.toml b/src/uu/seq/Cargo.toml index 2646d3609..f25d995a2 100644 --- a/src/uu/seq/Cargo.toml +++ b/src/uu/seq/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore bigdecimal [package] name = "uu_seq" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "seq ~ (uutils) display a sequence of numbers" diff --git a/src/uu/shred/Cargo.toml b/src/uu/shred/Cargo.toml index 81e49dc00..70045eaf0 100644 --- a/src/uu/shred/Cargo.toml +++ b/src/uu/shred/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_shred" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "shred ~ (uutils) hide former FILE contents with repeated overwrites" diff --git a/src/uu/shuf/Cargo.toml b/src/uu/shuf/Cargo.toml index 281e51d9e..2f0466b86 100644 --- a/src/uu/shuf/Cargo.toml +++ b/src/uu/shuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_shuf" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "shuf ~ (uutils) display random permutations of input lines" diff --git a/src/uu/sleep/Cargo.toml b/src/uu/sleep/Cargo.toml index f69678770..454f2297e 100644 --- a/src/uu/sleep/Cargo.toml +++ b/src/uu/sleep/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sleep" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "sleep ~ (uutils) pause for DURATION" diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index eb9cb9b59..359a2b012 100644 --- a/src/uu/sort/Cargo.toml +++ b/src/uu/sort/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sort" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "sort ~ (uutils) sort input lines" diff --git a/src/uu/split/Cargo.toml b/src/uu/split/Cargo.toml index 881e53e26..fb53914e2 100644 --- a/src/uu/split/Cargo.toml +++ b/src/uu/split/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_split" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "split ~ (uutils) split input into output files" diff --git a/src/uu/stat/Cargo.toml b/src/uu/stat/Cargo.toml index 91b479118..f258aca11 100644 --- a/src/uu/stat/Cargo.toml +++ b/src/uu/stat/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stat" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "stat ~ (uutils) display FILE status" diff --git a/src/uu/stdbuf/Cargo.toml b/src/uu/stdbuf/Cargo.toml index 66b74f9c5..f61014907 100644 --- a/src/uu/stdbuf/Cargo.toml +++ b/src/uu/stdbuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stdbuf" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "stdbuf ~ (uutils) run COMMAND with modified standard stream buffering" @@ -20,7 +20,7 @@ tempfile = { workspace = true } uucore = { workspace = true } [build-dependencies] -libstdbuf = { version = "0.0.20", package = "uu_stdbuf_libstdbuf", path = "src/libstdbuf" } +libstdbuf = { version = "0.0.21", package = "uu_stdbuf_libstdbuf", path = "src/libstdbuf" } [[bin]] name = "stdbuf" diff --git a/src/uu/stdbuf/src/libstdbuf/Cargo.toml b/src/uu/stdbuf/src/libstdbuf/Cargo.toml index 25104db2b..8061c61a6 100644 --- a/src/uu/stdbuf/src/libstdbuf/Cargo.toml +++ b/src/uu/stdbuf/src/libstdbuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stdbuf_libstdbuf" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "stdbuf/libstdbuf ~ (uutils); dynamic library required for stdbuf" diff --git a/src/uu/stty/Cargo.toml b/src/uu/stty/Cargo.toml index aadae6c92..eb86ae681 100644 --- a/src/uu/stty/Cargo.toml +++ b/src/uu/stty/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stty" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "stty ~ (uutils) print or change terminal characteristics" diff --git a/src/uu/sum/Cargo.toml b/src/uu/sum/Cargo.toml index 0879dd68f..aa722c694 100644 --- a/src/uu/sum/Cargo.toml +++ b/src/uu/sum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sum" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "sum ~ (uutils) display checksum and block counts for input" diff --git a/src/uu/sync/Cargo.toml b/src/uu/sync/Cargo.toml index 0a0695ed5..b74e076e5 100644 --- a/src/uu/sync/Cargo.toml +++ b/src/uu/sync/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sync" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "sync ~ (uutils) synchronize cache writes to storage" diff --git a/src/uu/tac/Cargo.toml b/src/uu/tac/Cargo.toml index 0decf6194..385ef37c8 100644 --- a/src/uu/tac/Cargo.toml +++ b/src/uu/tac/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "uu_tac" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "tac ~ (uutils) concatenate and display input lines in reverse order" diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index a22b148fe..792b7fcf1 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore (libs) kqueue fundu [package] name = "uu_tail" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "tail ~ (uutils) display the last lines of input" diff --git a/src/uu/tee/Cargo.toml b/src/uu/tee/Cargo.toml index 10fa63768..597299fc7 100644 --- a/src/uu/tee/Cargo.toml +++ b/src/uu/tee/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tee" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "tee ~ (uutils) display input and copy to FILE" diff --git a/src/uu/test/Cargo.toml b/src/uu/test/Cargo.toml index 4926bff32..fc70677a6 100644 --- a/src/uu/test/Cargo.toml +++ b/src/uu/test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_test" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "test ~ (uutils) evaluate comparison and file type expressions" diff --git a/src/uu/timeout/Cargo.toml b/src/uu/timeout/Cargo.toml index 452a5b04a..949ac9da5 100644 --- a/src/uu/timeout/Cargo.toml +++ b/src/uu/timeout/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_timeout" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "timeout ~ (uutils) run COMMAND with a DURATION time limit" diff --git a/src/uu/touch/Cargo.toml b/src/uu/touch/Cargo.toml index ce0752093..54682e1dd 100644 --- a/src/uu/touch/Cargo.toml +++ b/src/uu/touch/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore datetime [package] name = "uu_touch" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "touch ~ (uutils) change FILE timestamps" diff --git a/src/uu/tr/Cargo.toml b/src/uu/tr/Cargo.toml index 7bc942485..065fdab52 100644 --- a/src/uu/tr/Cargo.toml +++ b/src/uu/tr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tr" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "tr ~ (uutils) translate characters within input and display" diff --git a/src/uu/true/Cargo.toml b/src/uu/true/Cargo.toml index d70cc0d7a..432dfa54e 100644 --- a/src/uu/true/Cargo.toml +++ b/src/uu/true/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_true" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "true ~ (uutils) do nothing and succeed" diff --git a/src/uu/truncate/Cargo.toml b/src/uu/truncate/Cargo.toml index 4d756f46c..fbabe1fcd 100644 --- a/src/uu/truncate/Cargo.toml +++ b/src/uu/truncate/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_truncate" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "truncate ~ (uutils) truncate (or extend) FILE to SIZE" diff --git a/src/uu/tsort/Cargo.toml b/src/uu/tsort/Cargo.toml index 1e2b72d2f..2f276f98e 100644 --- a/src/uu/tsort/Cargo.toml +++ b/src/uu/tsort/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tsort" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "tsort ~ (uutils) topologically sort input (partially ordered) pairs" diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index f94026831..fde233250 100644 --- a/src/uu/tty/Cargo.toml +++ b/src/uu/tty/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tty" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "tty ~ (uutils) display the name of the terminal connected to standard input" diff --git a/src/uu/uname/Cargo.toml b/src/uu/uname/Cargo.toml index 1c0421c65..ccb3651ec 100644 --- a/src/uu/uname/Cargo.toml +++ b/src/uu/uname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uname" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "uname ~ (uutils) display system information" diff --git a/src/uu/unexpand/Cargo.toml b/src/uu/unexpand/Cargo.toml index 483881368..6a12d48ab 100644 --- a/src/uu/unexpand/Cargo.toml +++ b/src/uu/unexpand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_unexpand" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "unexpand ~ (uutils) convert input spaces to tabs" diff --git a/src/uu/uniq/Cargo.toml b/src/uu/uniq/Cargo.toml index b70cc993a..0afcffc11 100644 --- a/src/uu/uniq/Cargo.toml +++ b/src/uu/uniq/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uniq" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "uniq ~ (uutils) filter identical adjacent lines from input" diff --git a/src/uu/unlink/Cargo.toml b/src/uu/unlink/Cargo.toml index 401e0d591..ce86b81d8 100644 --- a/src/uu/unlink/Cargo.toml +++ b/src/uu/unlink/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_unlink" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "unlink ~ (uutils) remove a (file system) link to FILE" diff --git a/src/uu/uptime/Cargo.toml b/src/uu/uptime/Cargo.toml index 1835340ad..7bef7cc05 100644 --- a/src/uu/uptime/Cargo.toml +++ b/src/uu/uptime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uptime" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "uptime ~ (uutils) display dynamic system information" diff --git a/src/uu/users/Cargo.toml b/src/uu/users/Cargo.toml index 40341cf77..4701c694f 100644 --- a/src/uu/users/Cargo.toml +++ b/src/uu/users/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_users" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "users ~ (uutils) display names of currently logged-in users" diff --git a/src/uu/vdir/Cargo.toml b/src/uu/vdir/Cargo.toml index 55624dad8..dc57512b1 100644 --- a/src/uu/vdir/Cargo.toml +++ b/src/uu/vdir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_vdir" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "shortcut to ls -l -b" diff --git a/src/uu/wc/Cargo.toml b/src/uu/wc/Cargo.toml index 396a0f8dc..199cc4e0a 100644 --- a/src/uu/wc/Cargo.toml +++ b/src/uu/wc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_wc" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "wc ~ (uutils) display newline, word, and byte counts for input" diff --git a/src/uu/who/Cargo.toml b/src/uu/who/Cargo.toml index c727a3fc2..b8b90b2ef 100644 --- a/src/uu/who/Cargo.toml +++ b/src/uu/who/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_who" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "who ~ (uutils) display information about currently logged-in users" diff --git a/src/uu/whoami/Cargo.toml b/src/uu/whoami/Cargo.toml index 774831a66..331755a96 100644 --- a/src/uu/whoami/Cargo.toml +++ b/src/uu/whoami/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_whoami" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "whoami ~ (uutils) display user name of current effective user ID" diff --git a/src/uu/yes/Cargo.toml b/src/uu/yes/Cargo.toml index bd44c34f9..eff091551 100644 --- a/src/uu/yes/Cargo.toml +++ b/src/uu/yes/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_yes" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "yes ~ (uutils) repeatedly display a line with STRING (or 'y')" diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index ad26d3bca..79b7c39d7 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "uucore" -version = "0.0.20" +version = "0.0.21" authors = ["uutils developers"] license = "MIT" description = "uutils ~ 'core' uutils code library (cross-platform)" diff --git a/src/uucore_procs/Cargo.toml b/src/uucore_procs/Cargo.toml index 976ea014d..1ad4023f9 100644 --- a/src/uucore_procs/Cargo.toml +++ b/src/uucore_procs/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore uuhelp [package] name = "uucore_procs" -version = "0.0.20" +version = "0.0.21" authors = ["Roy Ivy III "] license = "MIT" description = "uutils ~ 'uucore' proc-macros" @@ -19,4 +19,4 @@ proc-macro = true [dependencies] proc-macro2 = "1.0" quote = "1.0" -uuhelp_parser = { path = "../uuhelp_parser", version = "0.0.20" } +uuhelp_parser = { path = "../uuhelp_parser", version = "0.0.21" } diff --git a/src/uuhelp_parser/Cargo.toml b/src/uuhelp_parser/Cargo.toml index 6a7aecd80..fdff271b0 100644 --- a/src/uuhelp_parser/Cargo.toml +++ b/src/uuhelp_parser/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore uuhelp [package] name = "uuhelp_parser" -version = "0.0.20" +version = "0.0.21" edition = "2021" license = "MIT" description = "A collection of functions to parse the markdown code of help files" diff --git a/util/update-version.sh b/util/update-version.sh index 8b6168782..6738f19b6 100755 --- a/util/update-version.sh +++ b/util/update-version.sh @@ -14,8 +14,8 @@ # 7) Run util/publish.sh --do-it # 8) In some cases, you might have to fix dependencies and run import -FROM="0.0.19" -TO="0.0.20" +FROM="0.0.20" +TO="0.0.21" PROGS=$(ls -1d src/uu/*/Cargo.toml src/uu/stdbuf/src/libstdbuf/Cargo.toml src/uucore/Cargo.toml Cargo.toml) From 183d465f74f4c818a6d8ccb6e580b17003d02ca3 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 3 Sep 2023 16:20:15 +0200 Subject: [PATCH 123/370] uucore: turn ranges into a feature --- src/uu/cut/Cargo.toml | 2 +- src/uu/numfmt/Cargo.toml | 2 +- src/uucore/Cargo.toml | 1 + src/uucore/src/lib/features.rs | 2 ++ src/uucore/src/lib/{mods => features}/ranges.rs | 0 src/uucore/src/lib/lib.rs | 3 ++- src/uucore/src/lib/mods.rs | 1 - 7 files changed, 7 insertions(+), 4 deletions(-) rename src/uucore/src/lib/{mods => features}/ranges.rs (100%) diff --git a/src/uu/cut/Cargo.toml b/src/uu/cut/Cargo.toml index be3ffe7f0..affeb3805 100644 --- a/src/uu/cut/Cargo.toml +++ b/src/uu/cut/Cargo.toml @@ -16,7 +16,7 @@ path = "src/cut.rs" [dependencies] clap = { workspace = true } -uucore = { workspace = true } +uucore = { workspace = true, features = ["ranges"] } memchr = { workspace = true } bstr = { workspace = true } is-terminal = { workspace = true } diff --git a/src/uu/numfmt/Cargo.toml b/src/uu/numfmt/Cargo.toml index c334a53e3..8fbf886a2 100644 --- a/src/uu/numfmt/Cargo.toml +++ b/src/uu/numfmt/Cargo.toml @@ -16,7 +16,7 @@ path = "src/numfmt.rs" [dependencies] clap = { workspace = true } -uucore = { workspace = true } +uucore = { workspace = true, features = ["ranges"] } [[bin]] name = "numfmt" diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 79b7c39d7..fcbfdeac7 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -82,6 +82,7 @@ mode = ["libc"] perms = ["libc", "walkdir"] pipes = [] process = ["libc"] +ranges = [] ringbuffer = [] signals = [] sum = [ diff --git a/src/uucore/src/lib/features.rs b/src/uucore/src/lib/features.rs index c2dc975dc..786a64682 100644 --- a/src/uucore/src/lib/features.rs +++ b/src/uucore/src/lib/features.rs @@ -16,6 +16,8 @@ pub mod fsext; pub mod lines; #[cfg(feature = "memo")] pub mod memo; +#[cfg(feature = "ranges")] +pub mod ranges; #[cfg(feature = "ringbuffer")] pub mod ringbuffer; #[cfg(feature = "sum")] diff --git a/src/uucore/src/lib/mods/ranges.rs b/src/uucore/src/lib/features/ranges.rs similarity index 100% rename from src/uucore/src/lib/mods/ranges.rs rename to src/uucore/src/lib/features/ranges.rs diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 30ebae254..5b9f4ae12 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -26,7 +26,6 @@ pub use crate::mods::line_ending; pub use crate::mods::os; pub use crate::mods::panic; pub use crate::mods::quoting_style; -pub use crate::mods::ranges; pub use crate::mods::version_cmp; // * string parsing modules @@ -48,6 +47,8 @@ pub use crate::features::fsext; pub use crate::features::lines; #[cfg(feature = "memo")] pub use crate::features::memo; +#[cfg(feature = "ranges")] +pub use crate::features::ranges; #[cfg(feature = "ringbuffer")] pub use crate::features::ringbuffer; #[cfg(feature = "sum")] diff --git a/src/uucore/src/lib/mods.rs b/src/uucore/src/lib/mods.rs index 99055d014..caa8fcb92 100644 --- a/src/uucore/src/lib/mods.rs +++ b/src/uucore/src/lib/mods.rs @@ -9,7 +9,6 @@ pub mod error; pub mod line_ending; pub mod os; pub mod panic; -pub mod ranges; pub mod version_cmp; // dir and vdir also need access to the quoting_style module pub mod quoting_style; From f0923094d21c34e32f77b55400f2063a446eff05 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 4 Sep 2023 07:18:18 +0200 Subject: [PATCH 124/370] Bump MSRV to 1.70 --- .clippy.toml | 2 +- .github/workflows/CICD.yml | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.clippy.toml b/.clippy.toml index bee70857b..814e40b69 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -1,2 +1,2 @@ -msrv = "1.64.0" +msrv = "1.70.0" cognitive-complexity-threshold = 10 diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index fe72de110..d387f566f 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -11,7 +11,7 @@ env: PROJECT_NAME: coreutils PROJECT_DESC: "Core universal (cross-platform) utilities" PROJECT_AUTH: "uutils" - RUST_MIN_SRV: "1.64.0" + RUST_MIN_SRV: "1.70.0" # * style job configuration STYLE_FAIL_ON_FAULT: true ## (bool) fail the build if a style job contains a fault (error or warning); may be overridden on a per-job basis diff --git a/Cargo.toml b/Cargo.toml index 320aa0f43..8d658c299 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ repository = "https://github.com/uutils/coreutils" readme = "README.md" keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"] categories = ["command-line-utilities"] -rust-version = "1.64.0" +rust-version = "1.70.0" edition = "2021" build = "build.rs" diff --git a/README.md b/README.md index c5b4609c9..4f341638b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ [![dependency status](https://deps.rs/repo/github/uutils/coreutils/status.svg)](https://deps.rs/repo/github/uutils/coreutils) [![CodeCov](https://codecov.io/gh/uutils/coreutils/branch/master/graph/badge.svg)](https://codecov.io/gh/uutils/coreutils) -![MSRV](https://img.shields.io/badge/MSRV-1.64.0-brightgreen) +![MSRV](https://img.shields.io/badge/MSRV-1.70.0-brightgreen) @@ -71,7 +71,7 @@ the [coreutils docs](https://github.com/uutils/uutils.github.io) repository. ### Rust Version uutils follows Rust's release channels and is tested against stable, beta and -nightly. The current Minimum Supported Rust Version (MSRV) is `1.64.0`. +nightly. The current Minimum Supported Rust Version (MSRV) is `1.70.0`. ## Building From 8920ac0123ceaec5a301e0e171d425b4bcbecd6f Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 4 Sep 2023 07:26:23 +0200 Subject: [PATCH 125/370] split: fix clippy warning in test --- tests/by-util/test_split.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index f3317d4c7..0b7bbfec6 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -871,7 +871,7 @@ fn test_short_combination() { assert_eq!(at.read("x00"), "a"); assert_eq!(at.read("x01"), "b"); assert_eq!(at.read("x02"), "c"); - assert_eq!(at.file_exists("x03"), false); + assert!(!at.file_exists("x03")); } /// Test for the last effective suffix, ignoring all others - numeric long last From c4c9c4730c5ebb830c995c42c590f1a9b2aba319 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 24 Aug 2023 18:30:39 +0000 Subject: [PATCH 126/370] chore(deps): update rust crate clap_complete to 4.4 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4885faa0..13008ab9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -286,9 +286,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.3.0" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a04ddfaacc3bc9e6ea67d024575fafc2a813027cf374b8f24f7bc233c6b6be12" +checksum = "586a385f7ef2f8b4d86bddaa0c094794e7ccbfe5ffef1f434fe928143fc783a5" dependencies = [ "clap", ] diff --git a/Cargo.toml b/Cargo.toml index 8d658c299..90ee3fb4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -269,7 +269,7 @@ chrono = { version = "^0.4.28", default-features = false, features = [ "clock", ] } clap = { version = "4.3", features = ["wrap_help", "cargo"] } -clap_complete = "4.3" +clap_complete = "4.4" clap_mangen = "0.2" compare = "0.1.0" coz = { version = "0.1.3" } From 4992cb9b8616af5dd9fe52daa1e61641e66f37f4 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 4 Sep 2023 10:35:17 +0200 Subject: [PATCH 127/370] Use std::io::IsTerminal instead of is-terminal --- Cargo.lock | 8 -------- Cargo.toml | 2 -- src/uu/cat/Cargo.toml | 1 - src/uu/cat/src/cat.rs | 3 +-- src/uu/cut/Cargo.toml | 1 - src/uu/cut/src/cut.rs | 3 +-- src/uu/ls/Cargo.toml | 1 - src/uu/ls/src/ls.rs | 3 +-- src/uu/more/Cargo.toml | 1 - src/uu/more/src/more.rs | 3 +-- src/uu/nohup/Cargo.toml | 1 - src/uu/nohup/src/nohup.rs | 3 +-- src/uu/tail/Cargo.toml | 1 - src/uu/tail/src/args.rs | 2 +- src/uu/tty/Cargo.toml | 1 - src/uu/tty/src/tty.rs | 3 +-- tests/by-util/test_more.rs | 2 +- 17 files changed, 8 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4885faa0..55879e585 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -389,7 +389,6 @@ dependencies = [ "filetime", "glob", "hex-literal", - "is-terminal", "libc", "nix", "once_cell", @@ -2311,7 +2310,6 @@ name = "uu_cat" version = "0.0.21" dependencies = [ "clap", - "is-terminal", "nix", "thiserror", "uucore", @@ -2411,7 +2409,6 @@ version = "0.0.21" dependencies = [ "bstr", "clap", - "is-terminal", "memchr", "uucore", ] @@ -2679,7 +2676,6 @@ dependencies = [ "chrono", "clap", "glob", - "is-terminal", "lscolors", "number_prefix", "once_cell", @@ -2732,7 +2728,6 @@ version = "0.0.21" dependencies = [ "clap", "crossterm", - "is-terminal", "nix", "unicode-segmentation", "unicode-width", @@ -2773,7 +2768,6 @@ name = "uu_nohup" version = "0.0.21" dependencies = [ "clap", - "is-terminal", "libc", "uucore", ] @@ -3072,7 +3066,6 @@ version = "0.0.21" dependencies = [ "clap", "fundu", - "is-terminal", "libc", "memchr", "notify", @@ -3162,7 +3155,6 @@ name = "uu_tty" version = "0.0.21" dependencies = [ "clap", - "is-terminal", "nix", "uucore", ] diff --git a/Cargo.toml b/Cargo.toml index 8d658c299..405ed08f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -286,7 +286,6 @@ gcd = "2.3" glob = "0.3.1" half = "2.2" indicatif = "0.17" -is-terminal = "0.4.9" itertools = "0.11.0" libc = "0.2.147" lscolors = { version = "0.15.0", default-features = false, features = [ @@ -491,7 +490,6 @@ time = { workspace = true, features = ["local-offset"] } unindent = "0.2" uucore = { workspace = true, features = ["entries", "process", "signals"] } walkdir = { workspace = true } -is-terminal = { workspace = true } hex-literal = "0.4.1" rstest = { workspace = true } diff --git a/src/uu/cat/Cargo.toml b/src/uu/cat/Cargo.toml index d67cd1b25..166e1823b 100644 --- a/src/uu/cat/Cargo.toml +++ b/src/uu/cat/Cargo.toml @@ -17,7 +17,6 @@ path = "src/cat.rs" [dependencies] clap = { workspace = true } thiserror = { workspace = true } -is-terminal = { workspace = true } uucore = { workspace = true, features = ["fs", "pipes"] } [target.'cfg(unix)'.dependencies] diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index 8ce805251..d49f4aa07 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -7,9 +7,8 @@ // last synced with: cat (GNU coreutils) 8.13 use clap::{crate_version, Arg, ArgAction, Command}; -use is_terminal::IsTerminal; use std::fs::{metadata, File}; -use std::io::{self, Read, Write}; +use std::io::{self, IsTerminal, Read, Write}; use thiserror::Error; use uucore::display::Quotable; use uucore::error::UResult; diff --git a/src/uu/cut/Cargo.toml b/src/uu/cut/Cargo.toml index affeb3805..a55ce7d58 100644 --- a/src/uu/cut/Cargo.toml +++ b/src/uu/cut/Cargo.toml @@ -19,7 +19,6 @@ clap = { workspace = true } uucore = { workspace = true, features = ["ranges"] } memchr = { workspace = true } bstr = { workspace = true } -is-terminal = { workspace = true } [[bin]] name = "cut" diff --git a/src/uu/cut/src/cut.rs b/src/uu/cut/src/cut.rs index 891281753..4d3145c05 100644 --- a/src/uu/cut/src/cut.rs +++ b/src/uu/cut/src/cut.rs @@ -7,9 +7,8 @@ use bstr::io::BufReadExt; use clap::{crate_version, Arg, ArgAction, Command}; -use is_terminal::IsTerminal; use std::fs::File; -use std::io::{stdin, stdout, BufReader, BufWriter, Read, Write}; +use std::io::{stdin, stdout, BufReader, BufWriter, IsTerminal, Read, Write}; use std::path::Path; use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError}; diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index b1114644d..f3fc2eb6b 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -25,7 +25,6 @@ glob = { workspace = true } lscolors = { workspace = true } uucore = { workspace = true, features = ["entries", "fs"] } once_cell = { workspace = true } -is-terminal = { workspace = true } selinux = { workspace = true, optional = true } [[bin]] diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 1f5165e83..652b978a5 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -10,12 +10,11 @@ use clap::{ crate_version, Arg, ArgAction, Command, }; use glob::{MatchOptions, Pattern}; -use is_terminal::IsTerminal; use lscolors::LsColors; use number_prefix::NumberPrefix; use once_cell::unsync::OnceCell; -use std::collections::HashSet; use std::num::IntErrorKind; +use std::{collections::HashSet, io::IsTerminal}; #[cfg(windows)] use std::os::windows::fs::MetadataExt; diff --git a/src/uu/more/Cargo.toml b/src/uu/more/Cargo.toml index ef2240133..bc0f25217 100644 --- a/src/uu/more/Cargo.toml +++ b/src/uu/more/Cargo.toml @@ -18,7 +18,6 @@ path = "src/more.rs" clap = { workspace = true } uucore = { workspace = true } crossterm = { workspace = true } -is-terminal = { workspace = true } unicode-width = { workspace = true } unicode-segmentation = { workspace = true } diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index 75cf79c07..02ed0feea 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -7,7 +7,7 @@ use std::{ fs::File, - io::{stdin, stdout, BufReader, Read, Stdout, Write}, + io::{stdin, stdout, BufReader, IsTerminal, Read, Stdout, Write}, path::Path, time::Duration, }; @@ -22,7 +22,6 @@ use crossterm::{ terminal::{self, Clear, ClearType}, }; -use is_terminal::IsTerminal; use unicode_segmentation::UnicodeSegmentation; use unicode_width::UnicodeWidthStr; use uucore::display::Quotable; diff --git a/src/uu/nohup/Cargo.toml b/src/uu/nohup/Cargo.toml index 2a454b9f4..9fbf125bf 100644 --- a/src/uu/nohup/Cargo.toml +++ b/src/uu/nohup/Cargo.toml @@ -17,7 +17,6 @@ path = "src/nohup.rs" [dependencies] clap = { workspace = true } libc = { workspace = true } -is-terminal = { workspace = true } uucore = { workspace = true, features = ["fs"] } [[bin]] diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index fdbed9395..c64f7bf71 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -6,14 +6,13 @@ // spell-checker:ignore (ToDO) execvp SIGHUP cproc vprocmgr cstrs homeout use clap::{crate_version, Arg, ArgAction, Command}; -use is_terminal::IsTerminal; use libc::{c_char, dup2, execvp, signal}; use libc::{SIGHUP, SIG_IGN}; use std::env; use std::ffi::CString; use std::fmt::{Display, Formatter}; use std::fs::{File, OpenOptions}; -use std::io::Error; +use std::io::{Error, IsTerminal}; use std::os::unix::prelude::*; use std::path::{Path, PathBuf}; use uucore::display::Quotable; diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index 792b7fcf1..5ff532e60 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -22,7 +22,6 @@ memchr = { workspace = true } notify = { workspace = true } uucore = { workspace = true } same-file = { workspace = true } -is-terminal = { workspace = true } fundu = { workspace = true } [target.'cfg(windows)'.dependencies] diff --git a/src/uu/tail/src/args.rs b/src/uu/tail/src/args.rs index 795652f26..388842a14 100644 --- a/src/uu/tail/src/args.rs +++ b/src/uu/tail/src/args.rs @@ -10,9 +10,9 @@ use crate::{parse, platform, Quotable}; use clap::{crate_version, value_parser}; use clap::{Arg, ArgAction, ArgMatches, Command}; use fundu::{DurationParser, SaturatingInto}; -use is_terminal::IsTerminal; use same_file::Handle; use std::ffi::OsString; +use std::io::IsTerminal; use std::time::Duration; use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::parse_size::{parse_size, ParseSizeError}; diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index fde233250..917d04c10 100644 --- a/src/uu/tty/Cargo.toml +++ b/src/uu/tty/Cargo.toml @@ -17,7 +17,6 @@ path = "src/tty.rs" [dependencies] clap = { workspace = true } nix = { workspace = true, features = ["term"] } -is-terminal = { workspace = true } uucore = { workspace = true, features = ["fs"] } [[bin]] diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index 96d851d37..efda4a7be 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -8,8 +8,7 @@ // spell-checker:ignore (ToDO) ttyname filedesc use clap::{crate_version, Arg, ArgAction, Command}; -use is_terminal::IsTerminal; -use std::io::Write; +use std::io::{IsTerminal, Write}; use std::os::unix::io::AsRawFd; use uucore::error::{set_exit_code, UResult}; use uucore::{format_usage, help_about, help_usage}; diff --git a/tests/by-util/test_more.rs b/tests/by-util/test_more.rs index b6ded2298..e80020d39 100644 --- a/tests/by-util/test_more.rs +++ b/tests/by-util/test_more.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. use crate::common::util::TestScenario; -use is_terminal::IsTerminal; +use std::io::IsTerminal; #[test] fn test_more_no_arg() { From 044e09786ea2b1a6182d5a751aa8d0db66ff19a2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 15:42:41 +0000 Subject: [PATCH 128/370] chore(deps): update actions/checkout action to v4 --- .github/workflows/CICD.yml | 36 +++++++++++++++--------------- .github/workflows/CheckScripts.yml | 4 ++-- .github/workflows/FixPR.yml | 4 ++-- .github/workflows/GnuTests.yml | 8 +++---- .github/workflows/android.yml | 2 +- .github/workflows/freebsd.yml | 4 ++-- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index d387f566f..27378cd96 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -30,7 +30,7 @@ jobs: name: Style/cargo-deny runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: EmbarkStudios/cargo-deny-action@v1 style_deps: @@ -47,7 +47,7 @@ jobs: - { os: macos-latest , features: "feat_Tier1,feat_require_unix,feat_require_unix_utmpx" } - { os: windows-latest , features: feat_os_windows } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly ## note: requires 'nightly' toolchain b/c `cargo-udeps` uses the `rustc` '-Z save-analysis' option ## * ... ref: @@ -91,7 +91,7 @@ jobs: job: - { os: ubuntu-latest , features: feat_os_unix } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: stable @@ -131,7 +131,7 @@ jobs: env: RUN_FOR: 60 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - name: Install `cargo-fuzz` run: cargo install cargo-fuzz @@ -182,7 +182,7 @@ jobs: - { os: macos-latest , features: feat_os_macos } - { os: windows-latest , features: feat_os_windows } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: stable @@ -238,7 +238,7 @@ jobs: job: - { os: ubuntu-latest , features: feat_os_unix } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Initialize workflow variables id: vars shell: bash @@ -292,7 +292,7 @@ jobs: # - { os: macos-latest , features: feat_os_macos } # - { os: windows-latest , features: feat_os_windows } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: stable @@ -345,7 +345,7 @@ jobs: job: - { os: ubuntu-latest , features: feat_os_unix } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.RUST_MIN_SRV }} @@ -413,7 +413,7 @@ jobs: job: - { os: ubuntu-latest , features: feat_os_unix } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - name: "`cargo update` testing" @@ -436,7 +436,7 @@ jobs: job: - { os: ubuntu-latest , features: feat_os_unix } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@nextest - uses: Swatinem/rust-cache@v2 @@ -490,7 +490,7 @@ jobs: - { os: macos-latest , features: feat_os_macos } - { os: windows-latest , features: feat_os_windows } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@nextest - uses: Swatinem/rust-cache@v2 @@ -517,7 +517,7 @@ jobs: - { os: macos-latest , features: feat_os_macos } - { os: windows-latest , features: feat_os_windows } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - uses: taiki-e/install-action@nextest - uses: Swatinem/rust-cache@v2 @@ -541,7 +541,7 @@ jobs: job: - { os: ubuntu-latest , features: feat_os_unix } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - name: Run sccache-cache @@ -661,7 +661,7 @@ jobs: - { os: windows-latest , target: x86_64-pc-windows-gnu , features: feat_os_windows } ## note: requires rust >= 1.43.0 to link correctly - { os: windows-latest , target: x86_64-pc-windows-msvc , features: feat_os_windows } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.RUST_MIN_SRV }} @@ -920,7 +920,7 @@ jobs: run: | ## VARs setup echo "TEST_SUMMARY_FILE=busybox-result.json" >> $GITHUB_OUTPUT - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 @@ -1000,7 +1000,7 @@ jobs: outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } TEST_SUMMARY_FILE="toybox-result.json" outputs TEST_SUMMARY_FILE - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.RUST_MIN_SRV }} @@ -1071,7 +1071,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Check run: npx --yes @taplo/cli fmt --check @@ -1091,7 +1091,7 @@ jobs: - { os: macos-latest , features: macos, toolchain: nightly } - { os: windows-latest , features: windows, toolchain: nightly-x86_64-pc-windows-gnu } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.job.toolchain }} diff --git a/.github/workflows/CheckScripts.yml b/.github/workflows/CheckScripts.yml index e1b3b24d2..98ae6cb75 100644 --- a/.github/workflows/CheckScripts.yml +++ b/.github/workflows/CheckScripts.yml @@ -29,7 +29,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run ShellCheck uses: ludeeus/action-shellcheck@master env: @@ -50,7 +50,7 @@ jobs: contents: write pull-requests: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup shfmt uses: mfinelli/setup-shfmt@v2 - name: Run shfmt diff --git a/.github/workflows/FixPR.yml b/.github/workflows/FixPR.yml index 97b0be34a..7f5e5234d 100644 --- a/.github/workflows/FixPR.yml +++ b/.github/workflows/FixPR.yml @@ -26,7 +26,7 @@ jobs: job: - { os: ubuntu-latest , features: feat_os_unix } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Initialize job variables id: vars shell: bash @@ -85,7 +85,7 @@ jobs: job: - { os: ubuntu-latest , features: feat_os_unix } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Initialize job variables id: vars shell: bash diff --git a/.github/workflows/GnuTests.yml b/.github/workflows/GnuTests.yml index ccb5a6f74..61f30eba4 100644 --- a/.github/workflows/GnuTests.yml +++ b/.github/workflows/GnuTests.yml @@ -55,7 +55,7 @@ jobs: TEST_FULL_SUMMARY_FILE='gnu-full-result.json' outputs SUITE_LOG_FILE ROOT_SUITE_LOG_FILE TEST_FILESET_PREFIX TEST_FILESET_SUFFIX TEST_LOGS_GLOB TEST_SUMMARY_FILE TEST_FULL_SUMMARY_FILE - name: Checkout code (uutil) - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: '${{ steps.vars.outputs.path_UUTILS }}' - uses: dtolnay/rust-toolchain@master @@ -66,7 +66,7 @@ jobs: with: workspaces: "./${{ steps.vars.outputs.path_UUTILS }} -> target" - name: Checkout code (GNU coreutils) - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: 'coreutils/coreutils' path: '${{ steps.vars.outputs.path_GNU }}' @@ -307,11 +307,11 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout code uutil - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: 'uutils' - name: Checkout GNU coreutils - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: 'coreutils/coreutils' path: 'gnu' diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a6929b171..5834aceff 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -26,7 +26,7 @@ jobs: env: TERMUX: v0.118.0 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Restore AVD cache uses: actions/cache/restore@v3 id: avd-cache diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index 095ec3230..5af3da320 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -30,7 +30,7 @@ jobs: SCCACHE_GHA_ENABLED: "true" RUSTC_WRAPPER: "sccache" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 @@ -120,7 +120,7 @@ jobs: SCCACHE_GHA_ENABLED: "true" RUSTC_WRAPPER: "sccache" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 From 8c1696084c08488146d6068a092ada14a6cf47b8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 15:47:49 +0000 Subject: [PATCH 129/370] chore(deps): update rust crate clap to 4.4 --- Cargo.lock | 18 ++++++++---------- Cargo.toml | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13008ab9a..c3e7ae92f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,16 +34,15 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] @@ -73,9 +72,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -263,23 +262,22 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.21" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" +checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.21" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" dependencies = [ "anstream", "anstyle", "clap_lex", - "once_cell", "strsim", "terminal_size", ] diff --git a/Cargo.toml b/Cargo.toml index 90ee3fb4a..97edb75dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -268,7 +268,7 @@ chrono = { version = "^0.4.28", default-features = false, features = [ "alloc", "clock", ] } -clap = { version = "4.3", features = ["wrap_help", "cargo"] } +clap = { version = "4.4", features = ["wrap_help", "cargo"] } clap_complete = "4.4" clap_mangen = "0.2" compare = "0.1.0" From 636c2bb7ae9444551d900d50829eb87414a23f8f Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Mon, 4 Sep 2023 12:05:26 -0400 Subject: [PATCH 130/370] uucore: parse_size_max and split --- src/uu/split/src/split.rs | 28 ++++++++-------------- src/uucore/src/lib/parser/parse_size.rs | 32 +++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index d76bfb2de..e39f6e93f 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -21,7 +21,7 @@ use std::io::{stdin, BufRead, BufReader, BufWriter, ErrorKind, Read, Write}; use std::path::Path; use uucore::display::Quotable; use uucore::error::{FromIo, UIoError, UResult, USimpleError, UUsageError}; -use uucore::parse_size::{parse_size, ParseSizeError}; +use uucore::parse_size::{parse_size_max, ParseSizeError}; use uucore::uio_error; use uucore::{format_usage, help_about, help_section, help_usage}; @@ -419,8 +419,7 @@ impl NumberType { let parts: Vec<&str> = s.split('/').collect(); match &parts[..] { [n_str] => { - let num_chunks = n_str - .parse() + let num_chunks = parse_size_max(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; if num_chunks > 0 { Ok(Self::Bytes(num_chunks)) @@ -429,32 +428,26 @@ impl NumberType { } } ["l", n_str] => { - let num_chunks = n_str - .parse() + let num_chunks = parse_size_max(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; Ok(Self::Lines(num_chunks)) } ["l", k_str, n_str] => { - let num_chunks = n_str - .parse() + let num_chunks = parse_size_max(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; - let chunk_number = k_str - .parse() + let chunk_number = parse_size_max(k_str) .map_err(|_| NumberTypeError::ChunkNumber(k_str.to_string()))?; Ok(Self::KthLines(chunk_number, num_chunks)) } ["r", n_str] => { - let num_chunks = n_str - .parse() + let num_chunks = parse_size_max(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; Ok(Self::RoundRobin(num_chunks)) } ["r", k_str, n_str] => { - let num_chunks = n_str - .parse() + let num_chunks = parse_size_max(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; - let chunk_number = k_str - .parse() + let chunk_number = parse_size_max(k_str) .map_err(|_| NumberTypeError::ChunkNumber(k_str.to_string()))?; Ok(Self::KthRoundRobin(chunk_number, num_chunks)) } @@ -523,7 +516,7 @@ impl Strategy { error: fn(ParseSizeError) -> StrategyError, ) -> Result { let s = matches.get_one::(option).unwrap(); - let n = parse_size(s).map_err(error)?; + let n = parse_size_max(s).map_err(error)?; if n > 0 { Ok(strategy(n)) } else { @@ -542,7 +535,7 @@ impl Strategy { matches.value_source(OPT_NUMBER) == Some(ValueSource::CommandLine), ) { (Some(v), false, false, false, false) => { - let v = parse_size(v).map_err(|_| { + let v = parse_size_max(v).map_err(|_| { StrategyError::Lines(ParseSizeError::ParseFailure(v.to_string())) })?; Ok(Self::Lines(v)) @@ -687,7 +680,6 @@ impl Settings { if additional_suffix.contains('/') { return Err(SettingsError::SuffixContainsSeparator(additional_suffix)); } - let strategy = Strategy::from(matches, obs_lines).map_err(SettingsError::Strategy)?; let (suffix_type, suffix_start) = suffix_type_from(matches)?; let suffix_length_str = matches.get_one::(OPT_SUFFIX_LENGTH).unwrap(); diff --git a/src/uucore/src/lib/parser/parse_size.rs b/src/uucore/src/lib/parser/parse_size.rs index 5f64afcd8..63039e609 100644 --- a/src/uucore/src/lib/parser/parse_size.rs +++ b/src/uucore/src/lib/parser/parse_size.rs @@ -7,6 +7,7 @@ use std::error::Error; use std::fmt; +use std::num::IntErrorKind; use crate::display::Quotable; @@ -201,8 +202,10 @@ impl<'parser> Parser<'parser> { radix: u32, original_size: &str, ) -> Result { - u64::from_str_radix(numeric_string, radix) - .map_err(|_| ParseSizeError::ParseFailure(original_size.to_string())) + u64::from_str_radix(numeric_string, radix).map_err(|e| match e.kind() { + IntErrorKind::PosOverflow => ParseSizeError::size_too_big(original_size), + _ => ParseSizeError::ParseFailure(original_size.to_string()), + }) } } @@ -232,6 +235,23 @@ pub fn parse_size(size: &str) -> Result { Parser::default().parse(size) } +/// Same as `parse_size()`, except returns `u64::MAX` on overflow +/// GNU lib/coreutils include similar functionality +/// and GNU test suite checks this behavior for some utils +pub fn parse_size_max(size: &str) -> Result { + let result = Parser::default().parse(size); + match result { + Ok(_) => result, + Err(error) => { + if let ParseSizeError::SizeTooBig(_) = error { + Ok(u64::MAX) + } else { + Err(error) + } + } + } +} + #[derive(Debug, PartialEq, Eq)] pub enum ParseSizeError { InvalidSuffix(String), // Suffix @@ -392,6 +412,14 @@ mod tests { ); } + #[test] + #[cfg(not(target_pointer_width = "128"))] + fn overflow_to_max_x64() { + assert_eq!(Ok(u64::MAX), parse_size_max("18446744073709551616")); + assert_eq!(Ok(u64::MAX), parse_size_max("10000000000000000000000")); + assert_eq!(Ok(u64::MAX), parse_size_max("1Y")); + } + #[test] fn invalid_suffix() { let test_strings = ["5mib", "1eb", "1H"]; From 862a2df924eabf9c2c99dae520b1d4d78e361b57 Mon Sep 17 00:00:00 2001 From: Yury Zhytkou <54360928+zhitkoff@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:23:49 -0400 Subject: [PATCH 131/370] build-gnu.sh: fix for /usr/bin/timeout on MacOS (#5194) * build-gnu.sh: `/usr/bin/timeout` should not be hardcoded to /usr/bin location Fixes #5193 --- util/build-gnu.sh | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index a3dd0b9ad..157265f61 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -18,10 +18,30 @@ path_GNU="$(readlink -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")" ### +# On MacOS there is no system /usr/bin/timeout +# and trying to add it to /usr/bin (with symlink of copy binary) will fail unless system integrity protection is disabled (not ideal) +# ref: https://support.apple.com/en-us/102149 +# On MacOS the Homebrew coreutils could be installed and then "sudo ln -s /opt/homebrew/bin/timeout /usr/local/bin/timeout" +# Set to /usr/local/bin/timeout instead if /usr/bin/timeout is not found +SYSTEM_TIMEOUT="timeout" +if [ -x /usr/bin/timeout ] ; then + SYSTEM_TIMEOUT="/usr/bin/timeout" +elif [ -x /usr/local/bin/timeout ] ; then + SYSTEM_TIMEOUT="/usr/local/bin/timeout" +fi + +### + +release_tag_GNU="v9.4" + if test ! -d "${path_GNU}"; then echo "Could not find GNU coreutils (expected at '${path_GNU}')" echo "Run the following to download into the expected path:" echo "git clone --recurse-submodules https://github.com/coreutils/coreutils.git \"${path_GNU}\"" + echo "After downloading GNU coreutils to \"${path_GNU}\" run the following commands to checkout latest release tag" + echo "cd \"${path_GNU}\"" + echo "git fetch --all --tags" + echo "git checkout tags/${release_tag_GNU}" exit 1 fi @@ -82,7 +102,7 @@ else ./bootstrap --skip-po ./configure --quiet --disable-gcc-warnings #Add timeout to to protect against hangs - sed -i 's|^"\$@|/usr/bin/timeout 600 "\$@|' build-aux/test-driver + sed -i 's|^"\$@|'"${SYSTEM_TIMEOUT}"' 600 "\$@|' build-aux/test-driver # Change the PATH in the Makefile to test the uutils coreutils instead of the GNU coreutils sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${UU_BUILD_DIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile sed -i 's| tr | /usr/bin/tr |' tests/init.sh @@ -153,13 +173,14 @@ sed -i 's|touch |/usr/bin/touch |' tests/cp/reflink-perm.sh tests/ls/block-size. sed -i 's|ln -|/usr/bin/ln -|' tests/cp/link-deref.sh sed -i 's|cp |/usr/bin/cp |' tests/mv/hard-2.sh sed -i 's|paste |/usr/bin/paste |' tests/od/od-endian.sh -sed -i 's|timeout |/usr/bin/timeout |' tests/tail/follow-stdin.sh +sed -i 's|timeout |'"${SYSTEM_TIMEOUT}"' |' tests/tail/follow-stdin.sh # Add specific timeout to tests that currently hang to limit time spent waiting -sed -i 's|\(^\s*\)seq \$|\1/usr/bin/timeout 0.1 seq \$|' tests/seq/seq-precision.sh tests/seq/seq-long-double.sh +sed -i 's|\(^\s*\)seq \$|\1'"${SYSTEM_TIMEOUT}"' 0.1 seq \$|' tests/seq/seq-precision.sh tests/seq/seq-long-double.sh -# Remove dup of /usr/bin/ when executed several times +# Remove dup of /usr/bin/ and /usr/local/bin/ when executed several times grep -rlE '/usr/bin/\s?/usr/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/bin/\s?/usr/bin/|/usr/bin/|g' +grep -rlE '/usr/local/bin/\s?/usr/local/bin' init.cfg tests/* | xargs --no-run-if-empty sed -Ei 's|/usr/local/bin/\s?/usr/local/bin/|/usr/local/bin/|g' #### Adjust tests to make them work with Rust/coreutils # in some cases, what we are doing in rust/coreutils is good (or better) From 7eec0ddaa364464f0567945934876cf8ac30fcbd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 05:06:00 +0000 Subject: [PATCH 132/370] chore(deps): update rust crate half to 2.3 --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c3e7ae92f..26a38fd36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1028,10 +1028,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "half" -version = "2.2.1" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" +checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872" dependencies = [ + "cfg-if", "crunchy", ] diff --git a/Cargo.toml b/Cargo.toml index 97edb75dd..9b92b342c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -284,7 +284,7 @@ fts-sys = "0.2" fundu = "2.0.0" gcd = "2.3" glob = "0.3.1" -half = "2.2" +half = "2.3" indicatif = "0.17" is-terminal = "0.4.9" itertools = "0.11.0" From f30b59efc0bf7d9fa49602058e7788b7edff47bf Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 5 Sep 2023 07:37:14 +0200 Subject: [PATCH 133/370] wc: use Rust's ilog10(), remove custom ilog10 fn --- src/uu/wc/src/wc.rs | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index 6d5894db0..663bbda15 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -702,7 +702,7 @@ fn compute_number_width(inputs: &Inputs, settings: &Settings) -> usize { if total == 0 { minimum_width } else { - let total_width = (1 + ilog10_u64(total)) + let total_width = (1 + total.ilog10()) .try_into() .expect("ilog of a u64 should fit into a usize"); max(total_width, minimum_width) @@ -857,29 +857,3 @@ fn print_stats( writeln!(stdout) } } - -// TODO: remove and just use usize::ilog10 once the MSRV is >= 1.67. -fn ilog10_u64(mut u: u64) -> u32 { - if u == 0 { - panic!("cannot compute log of 0") - } - let mut log = 0; - if u >= 10_000_000_000 { - log += 10; - u /= 10_000_000_000; - } - if u >= 100_000 { - log += 5; - u /= 100_000; - } - // Rust's standard library in versions >= 1.67 does something even more clever than this, but - // this should work just fine for the time being. - log + match u { - 1..=9 => 0, - 10..=99 => 1, - 100..=999 => 2, - 1000..=9999 => 3, - 10000..=99999 => 4, - _ => unreachable!(), - } -} From e493b9c5275e8764d33bb464bf0be6e977b531f5 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 5 Sep 2023 08:16:25 +0200 Subject: [PATCH 134/370] yes: use let/else to fix todo --- src/uu/yes/src/yes.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/uu/yes/src/yes.rs b/src/uu/yes/src/yes.rs index e6868d9d8..a58b73404 100644 --- a/src/uu/yes/src/yes.rs +++ b/src/uu/yes/src/yes.rs @@ -58,10 +58,7 @@ fn args_into_buffer<'a>( buf: &mut Vec, i: Option>, ) -> Result<(), Box> { - // TODO: this should be replaced with let/else once available in the MSRV. - let i = if let Some(i) = i { - i - } else { + let Some(i) = i else { buf.extend_from_slice(b"y\n"); return Ok(()); }; From 862a63835048d0e9d534a4ea1e33f08fb016a176 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 5 Sep 2023 09:44:30 +0200 Subject: [PATCH 135/370] Remove is-terminal from Cargo.lock --- Cargo.lock | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28ae46ccd..25377dc0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1136,17 +1136,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix 0.38.8", - "windows-sys 0.48.0", -] - [[package]] name = "itertools" version = "0.11.0" From 1a086ead7f69526d70447c9450ad709f2175fa89 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 5 Sep 2023 10:05:58 +0200 Subject: [PATCH 136/370] build-gnu.sh: fix formatting issues --- util/build-gnu.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 157265f61..2d949bbb3 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -18,16 +18,16 @@ path_GNU="$(readlink -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")" ### -# On MacOS there is no system /usr/bin/timeout +# On MacOS there is no system /usr/bin/timeout # and trying to add it to /usr/bin (with symlink of copy binary) will fail unless system integrity protection is disabled (not ideal) # ref: https://support.apple.com/en-us/102149 # On MacOS the Homebrew coreutils could be installed and then "sudo ln -s /opt/homebrew/bin/timeout /usr/local/bin/timeout" # Set to /usr/local/bin/timeout instead if /usr/bin/timeout is not found SYSTEM_TIMEOUT="timeout" -if [ -x /usr/bin/timeout ] ; then +if [ -x /usr/bin/timeout ]; then SYSTEM_TIMEOUT="/usr/bin/timeout" -elif [ -x /usr/local/bin/timeout ] ; then - SYSTEM_TIMEOUT="/usr/local/bin/timeout" +elif [ -x /usr/local/bin/timeout ]; then + SYSTEM_TIMEOUT="/usr/local/bin/timeout" fi ### From cefb4eb265b6ae13d57c003e9b9c636b76786b86 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 5 Sep 2023 10:43:26 +0200 Subject: [PATCH 137/370] Bump blake3 from 1.4.0 to 1.4.1 --- Cargo.lock | 14 ++++++++++---- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25377dc0c..86c374828 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,20 +161,20 @@ checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", "arrayvec", - "constant_time_eq", + "constant_time_eq 0.2.4", ] [[package]] name = "blake3" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729b71f35bd3fa1a4c86b85d32c8b9069ea7fe14f7a53cfabb65f62d4265b888" +checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" dependencies = [ "arrayref", "arrayvec", "cc", "cfg-if", - "constant_time_eq", + "constant_time_eq 0.3.0", "digest", ] @@ -360,6 +360,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3ad85c1f65dc7b37604eb0e89748faf0b9653065f2a8ef69f96a687ec1e9279" +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + [[package]] name = "conv" version = "0.3.3" diff --git a/Cargo.toml b/Cargo.toml index 5e2b4230a..51b64aff8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -339,7 +339,7 @@ sha1 = "0.10.5" sha2 = "0.10.7" sha3 = "0.10.8" blake2b_simd = "1.0.1" -blake3 = "1.4.0" +blake3 = "1.4.1" sm3 = "0.4.2" digest = "0.10.7" From 442e468efcda70a2bac6f18bc642a513bec2293e Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 5 Sep 2023 10:45:14 +0200 Subject: [PATCH 138/370] Bump constant_time_eq from 0.2.4 to 0.2.6 --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86c374828..7b476f447 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,7 +161,7 @@ checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", "arrayvec", - "constant_time_eq 0.2.4", + "constant_time_eq 0.2.6", ] [[package]] @@ -356,9 +356,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ad85c1f65dc7b37604eb0e89748faf0b9653065f2a8ef69f96a687ec1e9279" +checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" [[package]] name = "constant_time_eq" From dd584b6332967ba76acafec983dbba2189af32f3 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 5 Sep 2023 10:49:32 +0200 Subject: [PATCH 139/370] deny.toml: add constant_time_eq to skip list --- deny.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deny.toml b/deny.toml index c2e580a4d..678fc352d 100644 --- a/deny.toml +++ b/deny.toml @@ -87,6 +87,8 @@ skip = [ { name = "syn", version = "1.0.109" }, # various crates { name = "bitflags", version = "1.3.2" }, + # blake2b_simd + { name = "constant_time_eq", version = "0.2.6" }, ] # spell-checker: enable From 3cce11b46ff2229fffc39f84237007bc86300ede Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 14:17:59 +0000 Subject: [PATCH 140/370] chore(deps): update rust crate walkdir to 2.4 --- Cargo.lock | 5 ++--- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25377dc0c..eb1cdd4b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3311,12 +3311,11 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", - "winapi", "winapi-util", ] diff --git a/Cargo.toml b/Cargo.toml index 5e2b4230a..dbe5bd10e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -327,7 +327,7 @@ time = { version = "0.3" } unicode-segmentation = "1.10.1" unicode-width = "0.1.10" utf-8 = "0.7.6" -walkdir = "2.3" +walkdir = "2.4" winapi-util = "0.1.5" windows-sys = { version = "0.48.0", default-features = false } xattr = "1.0.1" From 2ae1d8d1ccd7c4fff24b51b8d914cda2be9de006 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Tue, 5 Sep 2023 17:13:30 -0400 Subject: [PATCH 141/370] split: missing functionality for --number option --- src/uu/split/src/split.rs | 218 ++++++++++++++++++++++-- src/uucore/src/lib/parser/parse_size.rs | 2 +- 2 files changed, 204 insertions(+), 16 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index e39f6e93f..23520f709 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -19,9 +19,10 @@ use std::fs::{metadata, File}; use std::io; use std::io::{stdin, BufRead, BufReader, BufWriter, ErrorKind, Read, Write}; use std::path::Path; +use std::u64; use uucore::display::Quotable; use uucore::error::{FromIo, UIoError, UResult, USimpleError, UUsageError}; -use uucore::parse_size::{parse_size_max, ParseSizeError}; +use uucore::parse_size::{parse_size, parse_size_max, ParseSizeError}; use uucore::uio_error; use uucore::{format_usage, help_about, help_section, help_usage}; @@ -337,6 +338,10 @@ enum NumberType { /// Split into a specific number of chunks by byte. Bytes(u64), + /// Split into a specific number of chunks by byte + /// but output only the *k*th chunk. + KthBytes(u64, u64), + /// Split into a specific number of chunks by line (approximately). Lines(u64), @@ -349,7 +354,7 @@ enum NumberType { /// Assign lines via round-robin to the specified number of output /// chunks, but output only the *k*th chunk. - KthRoundRobin(u64, u64), + KthRoundRobin(u64, u64), // not yet implemented? } impl NumberType { @@ -357,6 +362,7 @@ impl NumberType { fn num_chunks(&self) -> u64 { match self { Self::Bytes(n) => *n, + Self::KthBytes(_, n) => *n, Self::Lines(n) => *n, Self::KthLines(_, n) => *n, Self::RoundRobin(n) => *n, @@ -375,6 +381,7 @@ enum NumberTypeError { /// /// ```ignore /// -n N + /// -n K/N /// -n l/N /// -n l/K/N /// -n r/N @@ -385,9 +392,12 @@ enum NumberTypeError { /// The chunk number was invalid. /// /// This can happen if the value of `K` in any of the following - /// command-line options is not a positive integer: + /// command-line options is not a positive integer + /// or if `K` is 0 + /// or if `K` is greater than `N`: /// /// ```ignore + /// -n K/N /// -n l/K/N /// -n r/K/N /// ``` @@ -401,6 +411,7 @@ impl NumberType { /// /// ```ignore /// "N" + /// "K/N" /// "l/N" /// "l/K/N" /// "r/N" @@ -412,14 +423,17 @@ impl NumberType { /// /// # Errors /// - /// If the string is not one of the valid number types, if `K` is - /// not a nonnegative integer, or if `N` is not a positive - /// integer, then this function returns [`NumberTypeError`]. + /// If the string is not one of the valid number types, + /// if `K` is not a nonnegative integer, + /// or if `K` is 0, + /// or if `N` is not a positive integer, + /// or if `K` is greater than `N` + /// then this function returns [`NumberTypeError`]. fn from(s: &str) -> Result { let parts: Vec<&str> = s.split('/').collect(); match &parts[..] { [n_str] => { - let num_chunks = parse_size_max(n_str) + let num_chunks = parse_size(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; if num_chunks > 0 { Ok(Self::Bytes(num_chunks)) @@ -427,28 +441,44 @@ impl NumberType { Err(NumberTypeError::NumberOfChunks(s.to_string())) } } + [k_str, n_str] if !k_str.starts_with('l') && !k_str.starts_with('r') => { + let num_chunks = parse_size(n_str) + .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; + let chunk_number = parse_size(k_str) + .map_err(|_| NumberTypeError::ChunkNumber(k_str.to_string()))?; + if chunk_number > num_chunks || chunk_number == 0 { + return Err(NumberTypeError::ChunkNumber(k_str.to_string())); + } + Ok(Self::KthBytes(chunk_number, num_chunks)) + } ["l", n_str] => { - let num_chunks = parse_size_max(n_str) + let num_chunks = parse_size(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; Ok(Self::Lines(num_chunks)) } ["l", k_str, n_str] => { - let num_chunks = parse_size_max(n_str) + let num_chunks = parse_size(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; - let chunk_number = parse_size_max(k_str) + let chunk_number = parse_size(k_str) .map_err(|_| NumberTypeError::ChunkNumber(k_str.to_string()))?; + if chunk_number > num_chunks || chunk_number == 0 { + return Err(NumberTypeError::ChunkNumber(k_str.to_string())); + } Ok(Self::KthLines(chunk_number, num_chunks)) } ["r", n_str] => { - let num_chunks = parse_size_max(n_str) + let num_chunks = parse_size(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; Ok(Self::RoundRobin(num_chunks)) } ["r", k_str, n_str] => { - let num_chunks = parse_size_max(n_str) + let num_chunks = parse_size(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; - let chunk_number = parse_size_max(k_str) + let chunk_number = parse_size(k_str) .map_err(|_| NumberTypeError::ChunkNumber(k_str.to_string()))?; + if chunk_number > num_chunks || chunk_number == 0 { + return Err(NumberTypeError::ChunkNumber(k_str.to_string())); + } Ok(Self::KthRoundRobin(chunk_number, num_chunks)) } _ => Err(NumberTypeError::NumberOfChunks(s.to_string())), @@ -538,7 +568,13 @@ impl Strategy { let v = parse_size_max(v).map_err(|_| { StrategyError::Lines(ParseSizeError::ParseFailure(v.to_string())) })?; - Ok(Self::Lines(v)) + if v > 0 { + Ok(Self::Lines(v)) + } else { + Err(StrategyError::Lines(ParseSizeError::ParseFailure( + v.to_string(), + ))) + } } (None, false, false, false, false) => Ok(Self::Lines(1000)), (None, true, false, false, false) => { @@ -1263,6 +1299,93 @@ where } } +/// Print the k-th chunk of a file to stdout, splitting by byte. +/// +/// This function is like [`split_into_n_chunks_by_byte`], but instead +/// of writing each chunk to its own file, it only writes to stdout +/// the contents of the chunk identified by `chunk_number` +/// +/// # Errors +/// +/// This function returns an error if there is a problem reading from +/// `reader` or writing to stdout. +fn kth_chunks_by_byte( + settings: &Settings, + reader: &mut R, + chunk_number: u64, + num_chunks: u64, +) -> UResult<()> +where + R: BufRead, +{ + // Get the size of the input file in bytes and compute the number + // of bytes per chunk. + // + // If the requested number of chunks exceeds the number of bytes + // in the file - just write empty byte string to stdout + // NOTE: the `elide_empty_files` parameter is ignored here + // as we do not generate any files + // and instead writing to stdout + let metadata = metadata(&settings.input).map_err(|_| { + USimpleError::new(1, format!("{}: cannot determine file size", settings.input)) + })?; + + let num_bytes = metadata.len(); + // If input file is empty and we would have written zero chunks of output, + // then terminate immediately. + // This happens on `split -e -n 3 /dev/null`, for example. + if num_bytes == 0 { + return Ok(()); + } + + // Write to stdout instead of to a file. + let stdout = std::io::stdout(); + let mut writer = stdout.lock(); + + let chunk_size = (num_bytes / (num_chunks)).max(1); + let mut num_bytes: usize = num_bytes.try_into().unwrap(); + + let mut i = 1; + loop { + let buf: &mut Vec = &mut vec![]; + if num_bytes > 0 { + // Read `chunk_size` bytes from the reader into `buf` + // except the last. + // + // The last chunk gets all remaining bytes so that if the number + // of bytes in the input file was not evenly divisible by + // `num_chunks`, we don't leave any bytes behind. + let limit = { + if i == num_chunks { + num_bytes.try_into().unwrap() + } else { + chunk_size + } + }; + let n_bytes_read = reader.by_ref().take(limit).read_to_end(buf); + match n_bytes_read { + Ok(n_bytes) => { + num_bytes -= n_bytes; + } + Err(error) => { + return Err(USimpleError::new( + 1, + format!("{}: cannot read from input : {}", settings.input, error), + )); + } + } + if i == chunk_number { + writer.write_all(buf)?; + break; + } + i += 1; + } else { + break; + } + } + Ok(()) +} + /// Split a file into a specific number of chunks by line. /// /// This function always creates one output file for each chunk, even @@ -1438,6 +1561,50 @@ where Ok(()) } +/// Print the k-th chunk of a file, splitting by line, but +/// assign lines via round-robin to the specified number of output +/// chunks, but output only the *k*th chunk. +/// +/// This function is like [`kth_chunk_by_line`], as it only writes to stdout and +/// prints out only *k*th chunk +/// It is also like [`split_into_n_chunks_by_line_round_robin`], as it is assigning chunks +/// using round robin distribution +/// +/// # Errors +/// +/// This function returns an error if there is a problem reading from +/// `reader` or writing to one of the output files. +/// +/// # See also +/// +/// * [`split_into_n_chunks_by_line_round_robin`], which splits its input in the +/// same way, but writes each chunk to its own file. +fn kth_chunk_by_line_round_robin( + _settings: &Settings, + reader: &mut R, + chunk_number: u64, + num_chunks: u64, +) -> UResult<()> +where + R: BufRead, +{ + // Write to stdout instead of to a file. + let stdout = std::io::stdout(); + let mut writer = stdout.lock(); + + let num_chunks: usize = num_chunks.try_into().unwrap(); + let chunk_number: usize = chunk_number.try_into().unwrap(); + for (i, line_result) in reader.lines().enumerate() { + let line = line_result?; + let bytes = line.as_bytes(); + if (i % num_chunks) == chunk_number { + writer.write_all(bytes)?; + writer.write_all(b"\n")?; + } + } + Ok(()) +} + fn split(settings: &Settings) -> UResult<()> { let mut reader = BufReader::new(if settings.input == "-" { Box::new(stdin()) as Box @@ -1455,6 +1622,9 @@ fn split(settings: &Settings) -> UResult<()> { Strategy::Number(NumberType::Bytes(num_chunks)) => { split_into_n_chunks_by_byte(settings, &mut reader, num_chunks) } + Strategy::Number(NumberType::KthBytes(chunk_number, num_chunks)) => { + kth_chunks_by_byte(settings, &mut reader, chunk_number, num_chunks) + } Strategy::Number(NumberType::Lines(num_chunks)) => { split_into_n_chunks_by_line(settings, &mut reader, num_chunks) } @@ -1467,7 +1637,12 @@ fn split(settings: &Settings) -> UResult<()> { Strategy::Number(NumberType::RoundRobin(num_chunks)) => { split_into_n_chunks_by_line_round_robin(settings, &mut reader, num_chunks) } - Strategy::Number(_) => Err(USimpleError::new(1, "-n mode not yet fully implemented")), + Strategy::Number(NumberType::KthRoundRobin(chunk_number, num_chunks)) => { + // The chunk number is given as a 1-indexed number, but it + // is a little easier to deal with a 0-indexed number. + let chunk_number = chunk_number - 1; + kth_chunk_by_line_round_robin(settings, &mut reader, chunk_number, num_chunks) + } Strategy::Lines(chunk_size) => { let mut writer = LineChunkWriter::new(chunk_size, settings)?; match std::io::copy(&mut reader, &mut writer) { @@ -1570,6 +1745,18 @@ mod tests { NumberType::from("l/abc/456").unwrap_err(), NumberTypeError::ChunkNumber("abc".to_string()) ); + assert_eq!( + NumberType::from("l/456/123").unwrap_err(), + NumberTypeError::ChunkNumber("456".to_string()) + ); + assert_eq!( + NumberType::from("r/456/123").unwrap_err(), + NumberTypeError::ChunkNumber("456".to_string()) + ); + assert_eq!( + NumberType::from("456/123").unwrap_err(), + NumberTypeError::ChunkNumber("456".to_string()) + ); // In GNU split, the number of chunks get precedence: // // $ split -n l/abc/xyz @@ -1605,6 +1792,7 @@ mod tests { #[test] fn test_number_type_num_chunks() { assert_eq!(NumberType::from("123").unwrap().num_chunks(), 123); + assert_eq!(NumberType::from("123/456").unwrap().num_chunks(), 456); assert_eq!(NumberType::from("l/123").unwrap().num_chunks(), 123); assert_eq!(NumberType::from("l/123/456").unwrap().num_chunks(), 456); assert_eq!(NumberType::from("r/123").unwrap().num_chunks(), 123); diff --git a/src/uucore/src/lib/parser/parse_size.rs b/src/uucore/src/lib/parser/parse_size.rs index 63039e609..4d9968bb7 100644 --- a/src/uucore/src/lib/parser/parse_size.rs +++ b/src/uucore/src/lib/parser/parse_size.rs @@ -236,7 +236,7 @@ pub fn parse_size(size: &str) -> Result { } /// Same as `parse_size()`, except returns `u64::MAX` on overflow -/// GNU lib/coreutils include similar functionality +/// GNU lib/coreutils include similar functionality /// and GNU test suite checks this behavior for some utils pub fn parse_size_max(size: &str) -> Result { let result = Parser::default().parse(size); From 8be6338da9f87a49589752942186d328884c0d1a Mon Sep 17 00:00:00 2001 From: David Matos Date: Tue, 5 Sep 2023 23:35:14 +0200 Subject: [PATCH 142/370] cp: Error out if cp only contains source --- src/uu/cp/src/cp.rs | 3 +++ tests/by-util/test_cp.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 7dbf8aedb..516f20fda 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1073,6 +1073,9 @@ fn parse_path_args( if paths.is_empty() { // No files specified return Err("missing file operand".into()); + } else if paths.len() == 1 && options.target_dir.is_none() { + // Only one file specified + return Err(format!("missing destination file operand after {:?}", paths[0]).into()); } // Return an error if the user requested to copy more than one diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index f72316b5d..c77be3d4e 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -3231,3 +3231,15 @@ fn test_cp_debug_sparse_always_reflink_auto() { panic!("Failure: stdout was \n{stdout_str}"); } } + +#[test] +fn test_cp_only_source_no_target() { + let ts = TestScenario::new(util_name!()); + let at = &ts.fixtures; + at.touch("a"); + let result = ts.ucmd().arg("a").fails(); + let stderr_str = result.stderr_str(); + if !stderr_str.contains("missing destination file operand after \"a\"") { + panic!("Failure: stderr was \n{stderr_str}"); + } +} From 2a0b4f88370f1ad787937d174b0ca8e6c2e4bf10 Mon Sep 17 00:00:00 2001 From: Yury Zhytkou <54360928+zhitkoff@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:14:14 -0400 Subject: [PATCH 143/370] Update build-gnu.sh --- util/build-gnu.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index b57b4fe76..2d949bbb3 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -19,7 +19,6 @@ path_GNU="$(readlink -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")" ### # On MacOS there is no system /usr/bin/timeout - # and trying to add it to /usr/bin (with symlink of copy binary) will fail unless system integrity protection is disabled (not ideal) # ref: https://support.apple.com/en-us/102149 # On MacOS the Homebrew coreutils could be installed and then "sudo ln -s /opt/homebrew/bin/timeout /usr/local/bin/timeout" From a0a9ee6491ca3402e9fdc3af5b7b3f5def3b8268 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Tue, 5 Sep 2023 18:38:22 -0400 Subject: [PATCH 144/370] split: fixing tests for parse_size_max() --- tests/by-util/test_split.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 053b6f8bf..2d6474511 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -608,14 +608,6 @@ fn test_split_invalid_bytes_size() { .fails() .code_is(1) .stderr_only("split: invalid number of bytes: '1024R'\n"); - #[cfg(not(target_pointer_width = "128"))] - new_ucmd!() - .args(&["-b", "1Y"]) - .fails() - .code_is(1) - .stderr_only( - "split: invalid number of bytes: '1Y': Value too large for defined data type\n", - ); #[cfg(target_pointer_width = "32")] { let sizes = ["1000G", "10T"]; @@ -625,6 +617,18 @@ fn test_split_invalid_bytes_size() { } } +#[test] +fn test_split_overflow_bytes_size() { + #[cfg(not(target_pointer_width = "128"))] + let (at, mut ucmd) = at_and_ucmd!(); + let name = "test_split_overflow_bytes_size"; + RandomFile::new(&at, name).add_bytes(1000); + ucmd.args(&["-b", "1Y", name]).succeeds(); + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 1); + assert_eq!(glob.collate(), at.read_bytes(name)); +} + #[test] fn test_split_chunks_num_chunks_oversized_32() { #[cfg(target_pointer_width = "32")] From eaae32ec3bfbf842933b706001368314ee221851 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Tue, 5 Sep 2023 20:12:25 -0400 Subject: [PATCH 145/370] split: comments --- src/uu/split/src/split.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 23520f709..6fb05dabb 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -354,7 +354,7 @@ enum NumberType { /// Assign lines via round-robin to the specified number of output /// chunks, but output only the *k*th chunk. - KthRoundRobin(u64, u64), // not yet implemented? + KthRoundRobin(u64, u64), } impl NumberType { From 5c93c592db69312c0460c66c78fdddb624fc7462 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 6 Sep 2023 09:47:50 +0200 Subject: [PATCH 146/370] uucore: turn version_cmp into a feature --- src/uu/ls/Cargo.toml | 2 +- src/uu/sort/Cargo.toml | 2 +- src/uucore/Cargo.toml | 1 + src/uucore/src/lib/features.rs | 2 ++ src/uucore/src/lib/{mods => features}/version_cmp.rs | 0 src/uucore/src/lib/lib.rs | 3 ++- src/uucore/src/lib/mods.rs | 1 - 7 files changed, 7 insertions(+), 4 deletions(-) rename src/uucore/src/lib/{mods => features}/version_cmp.rs (100%) diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index f3fc2eb6b..24b6947fd 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -23,7 +23,7 @@ term_grid = { workspace = true } terminal_size = { workspace = true } glob = { workspace = true } lscolors = { workspace = true } -uucore = { workspace = true, features = ["entries", "fs"] } +uucore = { workspace = true, features = ["entries", "fs", "version-cmp"] } once_cell = { workspace = true } selinux = { workspace = true, optional = true } diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index 359a2b012..981e71641 100644 --- a/src/uu/sort/Cargo.toml +++ b/src/uu/sort/Cargo.toml @@ -27,7 +27,7 @@ rayon = { workspace = true } self_cell = { workspace = true } tempfile = { workspace = true } unicode-width = { workspace = true } -uucore = { workspace = true, features = ["fs"] } +uucore = { workspace = true, features = ["fs", "version-cmp"] } [[bin]] name = "sort" diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index fcbfdeac7..15a053ac4 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -100,4 +100,5 @@ sum = [ update-control = [] utf8 = [] utmpx = ["time", "time/macros", "libc", "dns-lookup"] +version-cmp = [] wide = [] diff --git a/src/uucore/src/lib/features.rs b/src/uucore/src/lib/features.rs index 786a64682..49eee3843 100644 --- a/src/uucore/src/lib/features.rs +++ b/src/uucore/src/lib/features.rs @@ -26,6 +26,8 @@ pub mod sum; mod tokenize; #[cfg(feature = "update-control")] pub mod update_control; +#[cfg(feature = "version-cmp")] +pub mod version_cmp; // * (platform-specific) feature-gated modules // ** non-windows (i.e. Unix + Fuchsia) diff --git a/src/uucore/src/lib/mods/version_cmp.rs b/src/uucore/src/lib/features/version_cmp.rs similarity index 100% rename from src/uucore/src/lib/mods/version_cmp.rs rename to src/uucore/src/lib/features/version_cmp.rs diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 5b9f4ae12..c0732f069 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -26,7 +26,6 @@ pub use crate::mods::line_ending; pub use crate::mods::os; pub use crate::mods::panic; pub use crate::mods::quoting_style; -pub use crate::mods::version_cmp; // * string parsing modules pub use crate::parser::parse_glob; @@ -55,6 +54,8 @@ pub use crate::features::ringbuffer; pub use crate::features::sum; #[cfg(feature = "update-control")] pub use crate::features::update_control; +#[cfg(feature = "version-cmp")] +pub use crate::features::version_cmp; // * (platform-specific) feature-gated modules // ** non-windows (i.e. Unix + Fuchsia) diff --git a/src/uucore/src/lib/mods.rs b/src/uucore/src/lib/mods.rs index caa8fcb92..d3a2dc19e 100644 --- a/src/uucore/src/lib/mods.rs +++ b/src/uucore/src/lib/mods.rs @@ -9,6 +9,5 @@ pub mod error; pub mod line_ending; pub mod os; pub mod panic; -pub mod version_cmp; // dir and vdir also need access to the quoting_style module pub mod quoting_style; From d8a16a235149ab60099c93c889437314095426fb Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 6 Sep 2023 12:42:49 -0400 Subject: [PATCH 147/370] split: tests --- tests/by-util/test_split.rs | 99 ++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 2d6474511..da4a4475b 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -377,6 +377,22 @@ fn test_split_obs_lines_standalone() { let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); assert_eq!(glob.count(), 2); assert_eq!(glob.collate(), at.read_bytes(name)); + ucmd.args(&["-99999999999999999991", name]).succeeds().no_stderr().no_stdout(); + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 2); + assert_eq!(glob.collate(), at.read_bytes(name)); +} + +/// Test for obsolete lines option standalone overflow +#[test] +fn test_split_obs_lines_standalone_overflow() { + let (at, mut ucmd) = at_and_ucmd!(); + let name = "obs-lines-standalone"; + RandomFile::new(&at, name).add_lines(4); + ucmd.args(&["-99999999999999999991", name]).succeeds().no_stderr().no_stdout(); + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 1); + assert_eq!(glob.collate(), at.read_bytes(name)); } /// Test for obsolete lines option as part of invalid combined short options @@ -756,7 +772,7 @@ creating file 'xaf' } #[test] -fn test_number() { +fn test_number_n() { let (at, mut ucmd) = at_and_ucmd!(); let file_read = |f| { let mut s = String::new(); @@ -771,6 +787,80 @@ fn test_number() { assert_eq!(file_read("xae"), "uvwxyz\n"); } +#[test] +fn test_number_kth_of_n() { + new_ucmd!() + .args(&["--number=3/5", "asciilowercase.txt"]) + .succeeds() + .stdout_only("klmno"); + new_ucmd!() + .args(&["-e", "--number=99/100", "asciilowercase.txt"]) + .succeeds() + .stdout_only(""); + new_ucmd!() + .args(&[ + "--number=r/9223372036854775807/18446744073709551615", + "asciilowercase.txt", + ]) + .succeeds() + .stdout_only(""); + new_ucmd!() + .args(&["--number=0/5", "asciilowercase.txt"]) + .fails() + .stderr_contains("split: invalid chunk number: 0"); + new_ucmd!() + .args(&["--number=10/5", "asciilowercase.txt"]) + .fails() + .stderr_contains("split: invalid chunk number: 10"); + new_ucmd!() + .args(&[ + "--number=9223372036854775807/18446744073709551616", + "asciilowercase.txt", + ]) + .fails() + .stderr_contains("split: invalid number of chunks: 18446744073709551616"); +} + +#[test] +fn test_number_kth_of_n_round_robin() { + new_ucmd!() + .args(&["--number", "r/2/3", "fivelines.txt"]) + .succeeds() + .stdout_only("2\n5\n"); + new_ucmd!() + .args(&["--number", "r/1/4", "fivelines.txt"]) + .succeeds() + .stdout_only("1\n5\n"); + new_ucmd!() + .args(&["-e", "--number", "r/7/7", "fivelines.txt"]) + .succeeds() + .stdout_only(""); + new_ucmd!() + .args(&[ + "--number", + "r/9223372036854775807/18446744073709551615", + "fivelines.txt", + ]) + .succeeds() + .stdout_only(""); + new_ucmd!() + .args(&[ + "--number", + "r/9223372036854775807/18446744073709551616", + "fivelines.txt", + ]) + .fails() + .stderr_contains("split: invalid number of chunks: 18446744073709551616"); + new_ucmd!() + .args(&["--number", "r/0/3", "fivelines.txt"]) + .fails() + .stderr_contains("split: invalid chunk number: 0"); + new_ucmd!() + .args(&["--number", "r/10/3", "fivelines.txt"]) + .fails() + .stderr_contains("split: invalid chunk number: 10"); +} + #[test] fn test_split_number_with_io_blksize() { let (at, mut ucmd) = at_and_ucmd!(); @@ -927,6 +1017,13 @@ fn test_line_bytes() { assert_eq!(at.read("xad"), "ee\n"); } +#[test] +fn test_line_bytes_overflow() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-C", "18446744073709551616", "letters.txt"]).succeeds(); + assert_eq!(at.read("xaa"), "aaaaaaaaa\nbbbb\ncccc\ndd\nee\n"); +} + #[test] fn test_line_bytes_concatenated_with_value() { let (at, mut ucmd) = at_and_ucmd!(); From e378454a265b103b98e940d5ed9b691985433f54 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 6 Sep 2023 13:15:35 -0400 Subject: [PATCH 148/370] split: formatting --- tests/by-util/test_split.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index da4a4475b..3ea74606c 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -377,7 +377,10 @@ fn test_split_obs_lines_standalone() { let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); assert_eq!(glob.count(), 2); assert_eq!(glob.collate(), at.read_bytes(name)); - ucmd.args(&["-99999999999999999991", name]).succeeds().no_stderr().no_stdout(); + ucmd.args(&["-99999999999999999991", name]) + .succeeds() + .no_stderr() + .no_stdout(); let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); assert_eq!(glob.count(), 2); assert_eq!(glob.collate(), at.read_bytes(name)); @@ -389,7 +392,10 @@ fn test_split_obs_lines_standalone_overflow() { let (at, mut ucmd) = at_and_ucmd!(); let name = "obs-lines-standalone"; RandomFile::new(&at, name).add_lines(4); - ucmd.args(&["-99999999999999999991", name]).succeeds().no_stderr().no_stdout(); + ucmd.args(&["-99999999999999999991", name]) + .succeeds() + .no_stderr() + .no_stdout(); let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); assert_eq!(glob.count(), 1); assert_eq!(glob.collate(), at.read_bytes(name)); @@ -1020,7 +1026,8 @@ fn test_line_bytes() { #[test] fn test_line_bytes_overflow() { let (at, mut ucmd) = at_and_ucmd!(); - ucmd.args(&["-C", "18446744073709551616", "letters.txt"]).succeeds(); + ucmd.args(&["-C", "18446744073709551616", "letters.txt"]) + .succeeds(); assert_eq!(at.read("xaa"), "aaaaaaaaa\nbbbb\ncccc\ndd\nee\n"); } From 4fd598e4d513d3fec00876e3c897c7bd6024508f Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 6 Sep 2023 13:20:58 -0400 Subject: [PATCH 149/370] split: tests --- tests/by-util/test_split.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 3ea74606c..c3e8445a6 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -377,13 +377,6 @@ fn test_split_obs_lines_standalone() { let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); assert_eq!(glob.count(), 2); assert_eq!(glob.collate(), at.read_bytes(name)); - ucmd.args(&["-99999999999999999991", name]) - .succeeds() - .no_stderr() - .no_stdout(); - let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); - assert_eq!(glob.count(), 2); - assert_eq!(glob.collate(), at.read_bytes(name)); } /// Test for obsolete lines option standalone overflow From 1669a92694985c8e2ad3df661fe457731698d172 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 6 Sep 2023 14:02:08 -0400 Subject: [PATCH 150/370] split: tests overflow --- tests/by-util/test_split.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index c3e8445a6..849fdc7cf 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes threebytes asciilowercase fghij klmno pqrst uvwxyz fivelines twohundredfortyonebytes onehundredlines nbbbb dxen +// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes threebytes asciilowercase fghij klmno pqrst uvwxyz fivelines twohundredfortyonebytes onehundredlines nbbbb dxen ncccc use crate::common::util::{AtPath, TestScenario}; use rand::{thread_rng, Rng, SeedableRng}; @@ -796,6 +796,7 @@ fn test_number_kth_of_n() { .args(&["-e", "--number=99/100", "asciilowercase.txt"]) .succeeds() .stdout_only(""); + #[cfg(target_pointer_width = "64")] new_ucmd!() .args(&[ "--number=r/9223372036854775807/18446744073709551615", @@ -811,6 +812,7 @@ fn test_number_kth_of_n() { .args(&["--number=10/5", "asciilowercase.txt"]) .fails() .stderr_contains("split: invalid chunk number: 10"); + #[cfg(target_pointer_width = "64")] new_ucmd!() .args(&[ "--number=9223372036854775807/18446744073709551616", @@ -834,6 +836,7 @@ fn test_number_kth_of_n_round_robin() { .args(&["-e", "--number", "r/7/7", "fivelines.txt"]) .succeeds() .stdout_only(""); + #[cfg(target_pointer_width = "64")] new_ucmd!() .args(&[ "--number", @@ -842,6 +845,7 @@ fn test_number_kth_of_n_round_robin() { ]) .succeeds() .stdout_only(""); + #[cfg(target_pointer_width = "64")] new_ucmd!() .args(&[ "--number", @@ -1018,6 +1022,7 @@ fn test_line_bytes() { #[test] fn test_line_bytes_overflow() { + #[cfg(target_pointer_width = "64")] let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["-C", "18446744073709551616", "letters.txt"]) .succeeds(); From fbf5ac4329b83c8c6e6ffb3f87ab7c2fea09e263 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 6 Sep 2023 14:16:21 -0400 Subject: [PATCH 151/370] split: tests 32bit --- tests/by-util/test_split.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 849fdc7cf..247b3cc57 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -1021,8 +1021,8 @@ fn test_line_bytes() { } #[test] +#[cfg(target_pointer_width = "64")] fn test_line_bytes_overflow() { - #[cfg(target_pointer_width = "64")] let (at, mut ucmd) = at_and_ucmd!(); ucmd.args(&["-C", "18446744073709551616", "letters.txt"]) .succeeds(); From e40e88702270930470d99301118e03eaba37ca6d Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 6 Sep 2023 18:43:20 -0400 Subject: [PATCH 152/370] split: some refactoring for handle_obsolete() --- src/uu/split/src/split.rs | 243 +++++++++++++++++++++++--------------- 1 file changed, 147 insertions(+), 96 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 6fb05dabb..65032dfd9 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -75,106 +75,154 @@ fn handle_obsolete(args: impl uucore::Args) -> (Vec, Option) { let mut obs_lines = None; let mut preceding_long_opt_req_value = false; let mut preceding_short_opt_req_value = false; + let filtered_args = args .filter_map(|os_slice| { - let filter: Option; - if let Some(slice) = os_slice.to_str() { - // check if the slice is a true short option (and not hyphen prefixed value of an option) - // and if so, a short option that can contain obsolete lines value - if slice.starts_with('-') - && !slice.starts_with("--") - && !preceding_long_opt_req_value - && !preceding_short_opt_req_value - && !slice.starts_with("-a") - && !slice.starts_with("-b") - && !slice.starts_with("-C") - && !slice.starts_with("-l") - && !slice.starts_with("-n") - { - // start of the short option string - // that can have obsolete lines option value in it - // extract numeric part and filter it out - let mut obs_lines_extracted: Vec = vec![]; - let mut obs_lines_end_reached = false; - let filtered_slice: Vec = slice - .chars() - .filter(|c| { - // To correctly process scenario like '-x200a4' - // we need to stop extracting digits once alphabetic character is encountered - // after we already have something in obs_lines_extracted - if c.is_ascii_digit() && !obs_lines_end_reached { - obs_lines_extracted.push(*c); - false - } else { - if !obs_lines_extracted.is_empty() { - obs_lines_end_reached = true; - } - true - } - }) - .collect(); - - if obs_lines_extracted.is_empty() { - // no obsolete lines value found/extracted - filter = Some(OsString::from(slice)); - } else { - // obsolete lines value was extracted - obs_lines = Some(obs_lines_extracted.iter().collect()); - if filtered_slice.get(1).is_some() { - // there were some short options in front of or after obsolete lines value - // i.e. '-xd100' or '-100de' or similar, which after extraction of obsolete lines value - // would look like '-xd' or '-de' or similar - let filtered_slice: String = filtered_slice.iter().collect(); - filter = Some(OsString::from(filtered_slice)); - } else { - filter = None; - } - } - } else { - // either not a short option - // or a short option that cannot have obsolete lines value in it - filter = Some(OsString::from(slice)); - } - // capture if current slice is a preceding long option that requires value and does not use '=' to assign that value - // following slice should be treaded as value for this option - // even if it starts with '-' (which would be treated as hyphen prefixed value) - if slice.starts_with("--") { - preceding_long_opt_req_value = &slice[2..] == OPT_BYTES - || &slice[2..] == OPT_LINE_BYTES - || &slice[2..] == OPT_LINES - || &slice[2..] == OPT_ADDITIONAL_SUFFIX - || &slice[2..] == OPT_FILTER - || &slice[2..] == OPT_NUMBER - || &slice[2..] == OPT_SUFFIX_LENGTH; - } - // capture if current slice is a preceding short option that requires value and does not have value in the same slice (value separated by whitespace) - // following slice should be treaded as value for this option - // even if it starts with '-' (which would be treated as hyphen prefixed value) - preceding_short_opt_req_value = slice == "-b" - || slice == "-C" - || slice == "-l" - || slice == "-n" - || slice == "-a"; - // slice is a value - // reset preceding option flags - if !slice.starts_with('-') { - preceding_short_opt_req_value = false; - preceding_long_opt_req_value = false; - } - } else { - // Cannot cleanly convert os_slice to UTF-8 - // Do not process and return as-is - // This will cause failure later on, but we should not handle it here - // and let clap panic on invalid UTF-8 argument - filter = Some(os_slice); - } - // return filter - filter + filter_args( + os_slice, + &mut obs_lines, + &mut preceding_long_opt_req_value, + &mut preceding_short_opt_req_value, + ) }) .collect(); + (filtered_args, obs_lines) } +/// Helper function to [`handle_obsolete`] +/// Filters out obsolete lines option from args +fn filter_args( + os_slice: OsString, + obs_lines: &mut Option, + preceding_long_opt_req_value: &mut bool, + preceding_short_opt_req_value: &mut bool, +) -> Option { + let filter: Option; + if let Some(slice) = os_slice.to_str() { + if should_extract_obs_lines( + slice, + preceding_long_opt_req_value, + preceding_short_opt_req_value, + ) { + // start of the short option string + // that can have obsolete lines option value in it + filter = handle_extract_obs_lines(slice, obs_lines); + } else { + // either not a short option + // or a short option that cannot have obsolete lines value in it + filter = Some(OsString::from(slice)); + } + handle_preceding_options( + slice, + preceding_long_opt_req_value, + preceding_short_opt_req_value, + ); + } else { + // Cannot cleanly convert os_slice to UTF-8 + // Do not process and return as-is + // This will cause failure later on, but we should not handle it here + // and let clap panic on invalid UTF-8 argument + filter = Some(os_slice); + } + filter +} + +/// Helper function to [`filter_args`] +/// Checks if the slice is a true short option (and not hyphen prefixed value of an option) +/// and if so, a short option that can contain obsolete lines value +fn should_extract_obs_lines( + slice: &str, + preceding_long_opt_req_value: &bool, + preceding_short_opt_req_value: &bool, +) -> bool { + slice.starts_with('-') + && !slice.starts_with("--") + && !preceding_long_opt_req_value + && !preceding_short_opt_req_value + && !slice.starts_with("-a") + && !slice.starts_with("-b") + && !slice.starts_with("-C") + && !slice.starts_with("-l") + && !slice.starts_with("-n") +} + +/// Helper function to [`filter_args`] +/// Extracts obsolete lines numeric part from argument slice +/// and filters it out +fn handle_extract_obs_lines(slice: &str, obs_lines: &mut Option) -> Option { + let mut obs_lines_extracted: Vec = vec![]; + let mut obs_lines_end_reached = false; + let filtered_slice: Vec = slice + .chars() + .filter(|c| { + // To correctly process scenario like '-x200a4' + // we need to stop extracting digits once alphabetic character is encountered + // after we already have something in obs_lines_extracted + if c.is_ascii_digit() && !obs_lines_end_reached { + obs_lines_extracted.push(*c); + false + } else { + if !obs_lines_extracted.is_empty() { + obs_lines_end_reached = true; + } + true + } + }) + .collect(); + + if obs_lines_extracted.is_empty() { + // no obsolete lines value found/extracted + Some(OsString::from(slice)) + } else { + // obsolete lines value was extracted + let extracted: String = obs_lines_extracted.iter().collect(); + *obs_lines = Some(extracted); + if filtered_slice.get(1).is_some() { + // there were some short options in front of or after obsolete lines value + // i.e. '-xd100' or '-100de' or similar, which after extraction of obsolete lines value + // would look like '-xd' or '-de' or similar + let filtered_slice: String = filtered_slice.iter().collect(); + Some(OsString::from(filtered_slice)) + } else { + None + } + } +} + +/// Helper function to [`handle_extract_obs_lines`] +/// Captures if current slice is a preceding option +/// that requires value +fn handle_preceding_options( + slice: &str, + preceding_long_opt_req_value: &mut bool, + preceding_short_opt_req_value: &mut bool, +) { + // capture if current slice is a preceding long option that requires value and does not use '=' to assign that value + // following slice should be treaded as value for this option + // even if it starts with '-' (which would be treated as hyphen prefixed value) + if slice.starts_with("--") { + *preceding_long_opt_req_value = &slice[2..] == OPT_BYTES + || &slice[2..] == OPT_LINE_BYTES + || &slice[2..] == OPT_LINES + || &slice[2..] == OPT_ADDITIONAL_SUFFIX + || &slice[2..] == OPT_FILTER + || &slice[2..] == OPT_NUMBER + || &slice[2..] == OPT_SUFFIX_LENGTH; + } + // capture if current slice is a preceding short option that requires value and does not have value in the same slice (value separated by whitespace) + // following slice should be treaded as value for this option + // even if it starts with '-' (which would be treated as hyphen prefixed value) + *preceding_short_opt_req_value = + slice == "-b" || slice == "-C" || slice == "-l" || slice == "-n" || slice == "-a"; + // slice is a value + // reset preceding option flags + if !slice.starts_with('-') { + *preceding_short_opt_req_value = false; + *preceding_long_opt_req_value = false; + } +} + pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(crate_version!()) @@ -430,6 +478,9 @@ impl NumberType { /// or if `K` is greater than `N` /// then this function returns [`NumberTypeError`]. fn from(s: &str) -> Result { + fn is_invalid_chunk(chunk_number: u64, num_chunks: u64) -> bool { + chunk_number > num_chunks || chunk_number == 0 + } let parts: Vec<&str> = s.split('/').collect(); match &parts[..] { [n_str] => { @@ -446,7 +497,7 @@ impl NumberType { .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; let chunk_number = parse_size(k_str) .map_err(|_| NumberTypeError::ChunkNumber(k_str.to_string()))?; - if chunk_number > num_chunks || chunk_number == 0 { + if is_invalid_chunk(chunk_number, num_chunks) { return Err(NumberTypeError::ChunkNumber(k_str.to_string())); } Ok(Self::KthBytes(chunk_number, num_chunks)) @@ -461,7 +512,7 @@ impl NumberType { .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; let chunk_number = parse_size(k_str) .map_err(|_| NumberTypeError::ChunkNumber(k_str.to_string()))?; - if chunk_number > num_chunks || chunk_number == 0 { + if is_invalid_chunk(chunk_number, num_chunks) { return Err(NumberTypeError::ChunkNumber(k_str.to_string())); } Ok(Self::KthLines(chunk_number, num_chunks)) @@ -476,7 +527,7 @@ impl NumberType { .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; let chunk_number = parse_size(k_str) .map_err(|_| NumberTypeError::ChunkNumber(k_str.to_string()))?; - if chunk_number > num_chunks || chunk_number == 0 { + if is_invalid_chunk(chunk_number, num_chunks) { return Err(NumberTypeError::ChunkNumber(k_str.to_string())); } Ok(Self::KthRoundRobin(chunk_number, num_chunks)) From 3be284e0d94eb0c8d61e7ab684a9ff1bec5a4196 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 6 Sep 2023 19:49:26 -0400 Subject: [PATCH 153/370] split: more test coverage --- src/uu/split/src/split.rs | 2 +- tests/by-util/test_split.rs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 65032dfd9..7762789ac 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -1295,7 +1295,7 @@ where // 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 { + if num_chunks == 0 || num_bytes == 0 { return Ok(()); } diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 247b3cc57..bbac3c739 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -340,6 +340,18 @@ fn test_split_lines_number() { .succeeds() .no_stderr() .no_stdout(); + scene + .ucmd() + .args(&["--lines", "0", "file"]) + .fails() + .code_is(1) + .stderr_only("split: invalid number of lines: 0\n"); + scene + .ucmd() + .args(&["-0", "file"]) + .fails() + .code_is(1) + .stderr_only("split: invalid number of lines: 0\n"); scene .ucmd() .args(&["--lines", "2fb", "file"]) @@ -669,6 +681,15 @@ fn test_split_stdin_num_chunks() { .stderr_only("split: -: cannot determine file size\n"); } +#[test] +fn test_split_stdin_num_kth_chunk() { + new_ucmd!() + .args(&["--number=1/2"]) + .fails() + .code_is(1) + .stderr_only("split: -: cannot determine file size\n"); +} + fn file_read(at: &AtPath, filename: &str) -> String { let mut s = String::new(); at.open(filename).read_to_string(&mut s).unwrap(); @@ -784,6 +805,10 @@ fn test_number_n() { assert_eq!(file_read("xac"), "klmno"); assert_eq!(file_read("xad"), "pqrst"); assert_eq!(file_read("xae"), "uvwxyz\n"); + new_ucmd!() + .args(&["--number=100", "/dev/null"]) + .succeeds() + .stdout_only(""); } #[test] @@ -792,10 +817,18 @@ fn test_number_kth_of_n() { .args(&["--number=3/5", "asciilowercase.txt"]) .succeeds() .stdout_only("klmno"); + new_ucmd!() + .args(&["--number=5/5", "asciilowercase.txt"]) + .succeeds() + .stdout_only("uvwxyz\n"); new_ucmd!() .args(&["-e", "--number=99/100", "asciilowercase.txt"]) .succeeds() .stdout_only(""); + new_ucmd!() + .args(&["--number=3/10", "/dev/null"]) + .succeeds() + .stdout_only(""); #[cfg(target_pointer_width = "64")] new_ucmd!() .args(&[ From 8883f016d4ffd9929949130ab724a20b1c3cb132 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 6 Sep 2023 20:09:26 -0400 Subject: [PATCH 154/370] split: fix windows tests --- tests/by-util/test_split.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index bbac3c739..c204a6238 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -805,6 +805,7 @@ fn test_number_n() { assert_eq!(file_read("xac"), "klmno"); assert_eq!(file_read("xad"), "pqrst"); assert_eq!(file_read("xae"), "uvwxyz\n"); + #[cfg(unix)] new_ucmd!() .args(&["--number=100", "/dev/null"]) .succeeds() @@ -825,6 +826,7 @@ fn test_number_kth_of_n() { .args(&["-e", "--number=99/100", "asciilowercase.txt"]) .succeeds() .stdout_only(""); + #[cfg(unix)] new_ucmd!() .args(&["--number=3/10", "/dev/null"]) .succeeds() From 3f065eed8a265e24ea8790a8680dd62410c5f024 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 6 Sep 2023 21:04:01 -0400 Subject: [PATCH 155/370] split: fixing test for 32bit --- tests/by-util/test_split.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index c204a6238..5eba5071f 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -657,19 +657,17 @@ fn test_split_overflow_bytes_size() { } #[test] +#[cfg(target_pointer_width = "32")] fn test_split_chunks_num_chunks_oversized_32() { - #[cfg(target_pointer_width = "32")] - { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - at.touch("file"); - scene - .ucmd() - .args(&["--number", "5000000000", "file"]) - .fails() - .code_is(1) - .stderr_only("split: Number of chunks too big\n"); - } + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.touch("file"); + scene + .ucmd() + .args(&["--number", "5000000000", "sixhundredfiftyonebytes.txt"]) + .fails() + .code_is(1) + .stderr_only("split: Number of chunks too big\n"); } #[test] From e3f6fd3c3f6f9d80078789e79e2a80b22708461b Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Thu, 7 Sep 2023 20:48:26 +0100 Subject: [PATCH 156/370] truncate clippy fix. --- src/uu/truncate/src/truncate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index 3b1e9bd09..6e1c19fde 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -102,7 +102,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .unwrap_or_default(); if files.is_empty() { - return Err(UUsageError::new(1, "missing file operand")); + Err(UUsageError::new(1, "missing file operand")) } else { let io_blocks = matches.get_flag(options::IO_BLOCKS); let no_create = matches.get_flag(options::NO_CREATE); From a63603eea81a8999c0e4bd2d5ccc48d2203a3a4b Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 7 Sep 2023 22:08:11 +0200 Subject: [PATCH 157/370] echo's doc doesn't show correctly --- src/uu/echo/echo.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/uu/echo/echo.md b/src/uu/echo/echo.md index 4330ecd88..f6f6f37ff 100644 --- a/src/uu/echo/echo.md +++ b/src/uu/echo/echo.md @@ -12,15 +12,15 @@ Echo the STRING(s) to standard output. If -e is in effect, the following sequences are recognized: -\\ backslash -\a alert (BEL) -\b backspace -\c produce no further output -\e escape -\f form feed -\n new line -\r carriage return -\t horizontal tab -\v vertical tab -\0NNN byte with octal value NNN (1 to 3 digits) -\xHH byte with hexadecimal value HH (1 to 2 digits) \ No newline at end of file +- `\` backslash +- `\a` alert (BEL) +- `\b` backspace +- `\c` produce no further output +- `\e` escape +- `\f` form feed +- `\n` new line +- `\r` carriage return +- `\t` horizontal tab +- `\v` vertical tab +- `\0NNN` byte with octal value NNN (1 to 3 digits) +- `\xHH` byte with hexadecimal value HH (1 to 2 digits) From 6a63acc983d2b4b3e9c6b8f7ec325501ba5523f6 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 8 Sep 2023 07:27:19 +0200 Subject: [PATCH 158/370] deny.toml: add redox_syscall to skip list --- deny.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deny.toml b/deny.toml index 678fc352d..154b2bfe8 100644 --- a/deny.toml +++ b/deny.toml @@ -89,6 +89,8 @@ skip = [ { name = "bitflags", version = "1.3.2" }, # blake2b_simd { name = "constant_time_eq", version = "0.2.6" }, + # various crates + { name = "redox_syscall", version = "0.3.5" }, ] # spell-checker: enable From 7d2996bb1a8511563ee074c94dd0e8c4a84ea60a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 06:51:03 +0000 Subject: [PATCH 159/370] chore(deps): update rust crate redox_syscall to 0.4 --- Cargo.lock | 17 +++++++++++++---- Cargo.toml | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f18b8b72..c6f76c75b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -843,7 +843,7 @@ checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.3.5", "windows-sys 0.48.0", ] @@ -1510,7 +1510,7 @@ checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.3.5", "smallvec", "windows-targets 0.48.0", ] @@ -1743,6 +1743,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded0bce2d41cc3c57aefa284708ced249a64acb01745dbbe72bd78610bfd644c" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "reference-counted-singleton" version = "0.1.2" @@ -2115,7 +2124,7 @@ checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "redox_syscall 0.3.5", "rustix 0.38.8", "windows-sys 0.48.0", ] @@ -3085,7 +3094,7 @@ version = "0.0.21" dependencies = [ "clap", "libc", - "redox_syscall", + "redox_syscall 0.4.0", "uucore", ] diff --git a/Cargo.toml b/Cargo.toml index 88047df00..8ba138596 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -309,7 +309,7 @@ quick-error = "2.0.1" rand = { version = "0.8", features = ["small_rng"] } rand_core = "0.6" rayon = "1.7" -redox_syscall = "0.3" +redox_syscall = "0.4" regex = "1.9.5" rstest = "0.18.2" rust-ini = "0.19.0" From 2c96a0d741e182f0fc7c28258ee248c5f192ff85 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 4 Sep 2023 14:46:01 +0200 Subject: [PATCH 160/370] Bump nix and ctrlc nix from 0.26.2 -> 0.27.1 ctrlc from 3.4.0 -> 3.4.1 --- Cargo.lock | 17 +++++------------ Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c6f76c75b..ff9d65e46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -684,9 +684,9 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.0" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a011bbe2c35ce9c1f143b7af6f94f29a167beb4cd1d29e6740ce836f723120e" +checksum = "82e95fbd621905b854affdc67943b043a0fbb6ed7385fd5a25650d19a8a6cfdf" dependencies = [ "nix", "windows-sys 0.48.0", @@ -1343,14 +1343,13 @@ dependencies = [ [[package]] name = "nix" -version = "0.26.2" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.3.3", "cfg-if", "libc", - "static_assertions", ] [[package]] @@ -2076,12 +2075,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" diff --git a/Cargo.toml b/Cargo.toml index 8ba138596..fa45b2bb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -293,7 +293,7 @@ lscolors = { version = "0.15.0", default-features = false, features = [ ] } memchr = "2" memmap2 = "0.7" -nix = { version = "0.26", default-features = false } +nix = { version = "0.27", default-features = false } nom = "7.1.3" notify = { version = "=6.0.1", features = ["macos_kqueue"] } num-bigint = "0.4.4" From 36d5013fac3d4fd4158d721e2fa24b685c775a07 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 7 Sep 2023 15:07:20 +0200 Subject: [PATCH 161/370] stty: adapt to API change in nix 0.27.x tcgetattr(fd: RawFd) changed to tcgetattr(fd: Fd), with RawFd not implementing AsFd. A similar change was applied to tcsetattr. --- src/uu/stty/src/stty.rs | 56 +++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/src/uu/stty/src/stty.rs b/src/uu/stty/src/stty.rs index d55870730..669285750 100644 --- a/src/uu/stty/src/stty.rs +++ b/src/uu/stty/src/stty.rs @@ -14,10 +14,12 @@ use nix::sys::termios::{ OutputFlags, SpecialCharacterIndices, Termios, }; use nix::{ioctl_read_bad, ioctl_write_ptr_bad}; -use std::io::{self, stdout}; +use std::fs::File; +use std::io::{self, stdout, Stdout}; use std::ops::ControlFlow; +use std::os::fd::{AsFd, BorrowedFd}; use std::os::unix::fs::OpenOptionsExt; -use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; +use std::os::unix::io::{AsRawFd, RawFd}; use uucore::error::{UResult, USimpleError}; use uucore::{format_usage, help_about, help_usage}; @@ -91,10 +93,33 @@ mod options { struct Options<'a> { all: bool, save: bool, - file: RawFd, + file: Device, settings: Option>, } +enum Device { + File(File), + Stdout(Stdout), +} + +impl AsFd for Device { + fn as_fd(&self) -> BorrowedFd<'_> { + match self { + Self::File(f) => f.as_fd(), + Self::Stdout(stdout) => stdout.as_fd(), + } + } +} + +impl AsRawFd for Device { + fn as_raw_fd(&self) -> RawFd { + match self { + Self::File(f) => f.as_raw_fd(), + Self::Stdout(stdout) => stdout.as_raw_fd(), + } + } +} + impl<'a> Options<'a> { fn from(matches: &'a ArgMatches) -> io::Result { Ok(Self { @@ -110,12 +135,13 @@ impl<'a> Options<'a> { // will clean up the FD for us on exit, so it doesn't // matter. The alternative would be to have an enum of // BorrowedFd/OwnedFd to handle both cases. - Some(f) => std::fs::OpenOptions::new() - .read(true) - .custom_flags(O_NONBLOCK) - .open(f)? - .into_raw_fd(), - None => stdout().as_raw_fd(), + Some(f) => Device::File( + std::fs::OpenOptions::new() + .read(true) + .custom_flags(O_NONBLOCK) + .open(f)?, + ), + None => Device::Stdout(stdout()), }, settings: matches .get_many::(options::SETTINGS) @@ -175,7 +201,7 @@ fn stty(opts: &Options) -> UResult<()> { } // TODO: Figure out the right error message for when tcgetattr fails - let mut termios = tcgetattr(opts.file).expect("Could not get terminal attributes"); + let mut termios = tcgetattr(opts.file.as_fd()).expect("Could not get terminal attributes"); if let Some(settings) = &opts.settings { for setting in settings { @@ -187,8 +213,12 @@ fn stty(opts: &Options) -> UResult<()> { } } - tcsetattr(opts.file, nix::sys::termios::SetArg::TCSANOW, &termios) - .expect("Could not write terminal attributes"); + tcsetattr( + opts.file.as_fd(), + nix::sys::termios::SetArg::TCSANOW, + &termios, + ) + .expect("Could not write terminal attributes"); } else { print_settings(&termios, opts).expect("TODO: make proper error here from nix error"); } @@ -228,7 +258,7 @@ fn print_terminal_size(termios: &Termios, opts: &Options) -> nix::Result<()> { if opts.all { let mut size = TermSize::default(); - unsafe { tiocgwinsz(opts.file, &mut size as *mut _)? }; + unsafe { tiocgwinsz(opts.file.as_raw_fd(), &mut size as *mut _)? }; print!("rows {}; columns {}; ", size.rows, size.columns); } From 7679e908184e73035079fdf74382d155ce8c8574 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Sat, 9 Sep 2023 08:47:08 +0100 Subject: [PATCH 162/370] clippy: remove some unnecessary mut removing useless mutability mostly. --- src/uu/cat/src/splice.rs | 2 +- src/uu/cksum/src/cksum.rs | 3 +-- src/uu/env/src/env.rs | 5 ++++- src/uu/hashsum/src/hashsum.rs | 3 +-- src/uu/sort/src/ext_sort.rs | 6 +++--- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/uu/cat/src/splice.rs b/src/uu/cat/src/splice.rs index 5a9e8738e..6c2b6d3da 100644 --- a/src/uu/cat/src/splice.rs +++ b/src/uu/cat/src/splice.rs @@ -21,7 +21,7 @@ const BUF_SIZE: usize = 1024 * 16; /// copying or not. False means we don't have to. #[inline] pub(super) fn write_fast_using_splice( - handle: &mut InputHandle, + handle: &InputHandle, write_fd: &impl AsRawFd, ) -> CatResult { let (pipe_rd, pipe_wr) = pipe()?; diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index 6c9c79582..629bb457f 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -207,8 +207,7 @@ fn digest_read( Ok((digest.result_str(), output_size)) } else { // Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016) - let mut bytes = Vec::new(); - bytes.resize((output_bits + 7) / 8, 0); + let mut bytes = vec![0; (output_bits + 7) / 8]; digest.hash_finalize(&mut bytes); Ok((encode(bytes), output_size)) } diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index e031e39e3..d7c9687de 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -101,7 +101,7 @@ fn load_config_file(opts: &mut Options) -> UResult<()> { #[cfg(not(windows))] #[allow(clippy::ptr_arg)] -fn build_command<'a, 'b>(args: &'a mut Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b str]) { +fn build_command<'a, 'b>(args: &'a Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b str]) { let progname = Cow::from(args[0]); (progname, &args[1..]) } @@ -303,7 +303,10 @@ fn run_env(args: impl uucore::Args) -> UResult<()> { print_env(opts.line_ending); } else { // we need to execute a command + #[cfg(windows)] let (prog, args) = build_command(&mut opts.program); + #[cfg(not(windows))] + let (prog, args) = build_command(&opts.program); /* * On Unix-like systems Command::status either ends up calling either fork or posix_spawnp diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index f8f00f011..d27b09b98 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -803,8 +803,7 @@ fn digest_reader( Ok(digest.result_str()) } else { // Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016) - let mut bytes = Vec::new(); - bytes.resize((output_bits + 7) / 8, 0); + let mut bytes = vec![0; (output_bits + 7) / 8]; digest.hash_finalize(&mut bytes); Ok(encode(bytes)) } diff --git a/src/uu/sort/src/ext_sort.rs b/src/uu/sort/src/ext_sort.rs index 08de4e33e..183098812 100644 --- a/src/uu/sort/src/ext_sort.rs +++ b/src/uu/sort/src/ext_sort.rs @@ -224,7 +224,7 @@ fn read_write_loop( let mut sender_option = Some(sender); let mut tmp_files = vec![]; loop { - let mut chunk = match receiver.recv() { + let chunk = match receiver.recv() { Ok(it) => it, _ => { return Ok(ReadResult::WroteChunksToFile { tmp_files }); @@ -232,7 +232,7 @@ fn read_write_loop( }; let tmp_file = write::( - &mut chunk, + &chunk, tmp_dir.next_file()?, settings.compress_prog.as_deref(), separator, @@ -262,7 +262,7 @@ fn read_write_loop( /// Write the lines in `chunk` to `file`, separated by `separator`. /// `compress_prog` is used to optionally compress file contents. fn write( - chunk: &mut Chunk, + chunk: &Chunk, file: (File, PathBuf), compress_prog: Option<&str>, separator: u8, From d19b8b78d863de0ccab5b6074c28b46ad0eec90b Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 10 Sep 2023 15:07:37 +0200 Subject: [PATCH 163/370] uucore: turn quoting_style into a feature --- src/uu/dir/Cargo.toml | 2 +- src/uu/ls/Cargo.toml | 7 ++++++- src/uu/vdir/Cargo.toml | 2 +- src/uu/wc/Cargo.toml | 2 +- src/uucore/Cargo.toml | 1 + src/uucore/src/lib/features.rs | 2 ++ src/uucore/src/lib/{mods => features}/quoting_style.rs | 0 src/uucore/src/lib/lib.rs | 3 ++- src/uucore/src/lib/mods.rs | 2 -- 9 files changed, 14 insertions(+), 7 deletions(-) rename src/uucore/src/lib/{mods => features}/quoting_style.rs (100%) diff --git a/src/uu/dir/Cargo.toml b/src/uu/dir/Cargo.toml index 9cc5fbde4..2a709a804 100644 --- a/src/uu/dir/Cargo.toml +++ b/src/uu/dir/Cargo.toml @@ -16,7 +16,7 @@ path = "src/dir.rs" [dependencies] clap = { workspace = true, features = ["env"] } -uucore = { workspace = true, features = ["entries", "fs"] } +uucore = { workspace = true, features = ["entries", "fs", "quoting-style"] } uu_ls = { workspace = true } [[bin]] diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index 24b6947fd..e4100d07f 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -23,7 +23,12 @@ term_grid = { workspace = true } terminal_size = { workspace = true } glob = { workspace = true } lscolors = { workspace = true } -uucore = { workspace = true, features = ["entries", "fs", "version-cmp"] } +uucore = { workspace = true, features = [ + "entries", + "fs", + "quoting-style", + "version-cmp", +] } once_cell = { workspace = true } selinux = { workspace = true, optional = true } diff --git a/src/uu/vdir/Cargo.toml b/src/uu/vdir/Cargo.toml index dc57512b1..99bcf383b 100644 --- a/src/uu/vdir/Cargo.toml +++ b/src/uu/vdir/Cargo.toml @@ -16,7 +16,7 @@ path = "src/vdir.rs" [dependencies] clap = { workspace = true, features = ["env"] } -uucore = { workspace = true, features = ["entries", "fs"] } +uucore = { workspace = true, features = ["entries", "fs", "quoting-style"] } uu_ls = { workspace = true } [[bin]] diff --git a/src/uu/wc/Cargo.toml b/src/uu/wc/Cargo.toml index 199cc4e0a..5712fbd83 100644 --- a/src/uu/wc/Cargo.toml +++ b/src/uu/wc/Cargo.toml @@ -16,7 +16,7 @@ path = "src/wc.rs" [dependencies] clap = { workspace = true } -uucore = { workspace = true, features = ["pipes"] } +uucore = { workspace = true, features = ["pipes", "quoting-style"] } bytecount = { workspace = true } thiserror = { workspace = true } unicode-width = { workspace = true } diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 15a053ac4..90ae74aab 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -82,6 +82,7 @@ mode = ["libc"] perms = ["libc", "walkdir"] pipes = [] process = ["libc"] +quoting-style = [] ranges = [] ringbuffer = [] signals = [] diff --git a/src/uucore/src/lib/features.rs b/src/uucore/src/lib/features.rs index 49eee3843..3a99eb84f 100644 --- a/src/uucore/src/lib/features.rs +++ b/src/uucore/src/lib/features.rs @@ -16,6 +16,8 @@ pub mod fsext; pub mod lines; #[cfg(feature = "memo")] pub mod memo; +#[cfg(feature = "quoting-style")] +pub mod quoting_style; #[cfg(feature = "ranges")] pub mod ranges; #[cfg(feature = "ringbuffer")] diff --git a/src/uucore/src/lib/mods/quoting_style.rs b/src/uucore/src/lib/features/quoting_style.rs similarity index 100% rename from src/uucore/src/lib/mods/quoting_style.rs rename to src/uucore/src/lib/features/quoting_style.rs diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index c0732f069..2f28195da 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -25,7 +25,6 @@ pub use crate::mods::error; pub use crate::mods::line_ending; pub use crate::mods::os; pub use crate::mods::panic; -pub use crate::mods::quoting_style; // * string parsing modules pub use crate::parser::parse_glob; @@ -46,6 +45,8 @@ pub use crate::features::fsext; pub use crate::features::lines; #[cfg(feature = "memo")] pub use crate::features::memo; +#[cfg(feature = "quoting-style")] +pub use crate::features::quoting_style; #[cfg(feature = "ranges")] pub use crate::features::ranges; #[cfg(feature = "ringbuffer")] diff --git a/src/uucore/src/lib/mods.rs b/src/uucore/src/lib/mods.rs index d3a2dc19e..986536d6d 100644 --- a/src/uucore/src/lib/mods.rs +++ b/src/uucore/src/lib/mods.rs @@ -9,5 +9,3 @@ pub mod error; pub mod line_ending; pub mod os; pub mod panic; -// dir and vdir also need access to the quoting_style module -pub mod quoting_style; From 55a62f56b954d9991d41206cfcff47ffcbf98ebe Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 10 Sep 2023 22:42:02 +0000 Subject: [PATCH 164/370] chore(deps): update rust crate blake2b_simd to 1.0.2 --- Cargo.lock | 14 ++++---------- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff9d65e46..2601e0995 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -155,13 +155,13 @@ checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" [[package]] name = "blake2b_simd" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" dependencies = [ "arrayref", "arrayvec", - "constant_time_eq 0.2.6", + "constant_time_eq", ] [[package]] @@ -174,7 +174,7 @@ dependencies = [ "arrayvec", "cc", "cfg-if", - "constant_time_eq 0.3.0", + "constant_time_eq", "digest", ] @@ -354,12 +354,6 @@ dependencies = [ "tiny-keccak", ] -[[package]] -name = "constant_time_eq" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" - [[package]] name = "constant_time_eq" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index fa45b2bb1..f457af28e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -338,7 +338,7 @@ md-5 = "0.10.5" sha1 = "0.10.5" sha2 = "0.10.7" sha3 = "0.10.8" -blake2b_simd = "1.0.1" +blake2b_simd = "1.0.2" blake3 = "1.4.1" sm3 = "0.4.2" digest = "0.10.7" From 8916dc4087345d18af2e71a26a9e8a098566da4b Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 11 Sep 2023 07:06:23 +0200 Subject: [PATCH 165/370] deny.toml: remove constant_time_eq from skip list --- deny.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/deny.toml b/deny.toml index 154b2bfe8..c80588f51 100644 --- a/deny.toml +++ b/deny.toml @@ -87,8 +87,6 @@ skip = [ { name = "syn", version = "1.0.109" }, # various crates { name = "bitflags", version = "1.3.2" }, - # blake2b_simd - { name = "constant_time_eq", version = "0.2.6" }, # various crates { name = "redox_syscall", version = "0.3.5" }, ] From 6d0bac2842d5f58bc0988fc8b07debfa1dffbe99 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 11 Sep 2023 16:05:19 +0200 Subject: [PATCH 166/370] ls: use OnceCell from std instead of once_cell --- src/uu/ls/src/ls.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 652b978a5..18a1a221d 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -12,8 +12,7 @@ use clap::{ use glob::{MatchOptions, Pattern}; use lscolors::LsColors; use number_prefix::NumberPrefix; -use once_cell::unsync::OnceCell; -use std::num::IntErrorKind; +use std::{cell::OnceCell, num::IntErrorKind}; use std::{collections::HashSet, io::IsTerminal}; #[cfg(windows)] From e131ecdc850c5e9125093316bb3e9a0bfa323c3f Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 8 Sep 2023 15:07:47 +0200 Subject: [PATCH 167/370] Bump chrono from 0.4.28 to 0.4.30 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2601e0995..f0863ef86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -239,9 +239,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.28" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" +checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index f457af28e..03f43c26a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -263,7 +263,7 @@ binary-heap-plus = "0.5.0" bstr = "1.6" bytecount = "0.6.3" byteorder = "1.4.3" -chrono = { version = "^0.4.28", default-features = false, features = [ +chrono = { version = "^0.4.30", default-features = false, features = [ "std", "alloc", "clock", From 6ce80758d5708d0b04852af2db8b66c7074f9452 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 12 Sep 2023 15:08:21 +0200 Subject: [PATCH 168/370] touch: fix deprecation warnings from chrono datetime_from_str() has been deprecated --- src/uu/touch/src/touch.rs | 27 +++++++++++++++++++-------- tests/by-util/test_touch.rs | 3 +-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index e9970cb24..85eb97bc4 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -3,10 +3,13 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) filetime datetime lpszfilepath mktime DATETIME subsecond datelike timelike +// spell-checker:ignore (ToDO) filetime datetime lpszfilepath mktime DATETIME datelike timelike // spell-checker:ignore (FORMATS) MMDDhhmm YYYYMMDDHHMM YYMMDDHHMM YYYYMMDDHHMMS -use chrono::{DateTime, Datelike, Duration, Local, NaiveDate, NaiveTime, TimeZone, Timelike, Utc}; +use chrono::{ + DateTime, Datelike, Duration, Local, LocalResult, NaiveDate, NaiveDateTime, NaiveTime, + TimeZone, Timelike, +}; use clap::builder::ValueParser; use clap::{crate_version, Arg, ArgAction, ArgGroup, Command}; use filetime::{set_file_times, set_symlink_file_times, FileTime}; @@ -348,8 +351,8 @@ fn parse_date(s: &str) -> UResult { // Tue Dec 3 ... // ("%c", POSIX_LOCALE_FORMAT), // - if let Ok(parsed) = Local.datetime_from_str(s, format::POSIX_LOCALE) { - return Ok(datetime_to_filetime(&parsed)); + if let Ok(parsed) = NaiveDateTime::parse_from_str(s, format::POSIX_LOCALE) { + return Ok(datetime_to_filetime(&parsed.and_utc())); } // Also support other formats found in the GNU tests like @@ -361,8 +364,8 @@ fn parse_date(s: &str) -> UResult { format::YYYY_MM_DD_HH_MM, format::YYYYMMDDHHMM_OFFSET, ] { - if let Ok(parsed) = Utc.datetime_from_str(s, fmt) { - return Ok(datetime_to_filetime(&parsed)); + if let Ok(parsed) = NaiveDateTime::parse_from_str(s, fmt) { + return Ok(datetime_to_filetime(&parsed.and_utc())); } } @@ -411,9 +414,17 @@ fn parse_timestamp(s: &str) -> UResult { } }; - let mut local = chrono::Local - .datetime_from_str(&ts, format) + let local = NaiveDateTime::parse_from_str(&ts, format) .map_err(|_| USimpleError::new(1, format!("invalid date ts format {}", ts.quote())))?; + let mut local = match chrono::Local.from_local_datetime(&local) { + LocalResult::Single(dt) => dt, + _ => { + return Err(USimpleError::new( + 1, + format!("invalid date ts format {}", ts.quote()), + )) + } + }; // Chrono caps seconds at 59, but 60 is valid. It might be a leap second // or wrap to the next minute. But that doesn't really matter, because we diff --git a/tests/by-util/test_touch.rs b/tests/by-util/test_touch.rs index 942446a33..c9c0d700e 100644 --- a/tests/by-util/test_touch.rs +++ b/tests/by-util/test_touch.rs @@ -5,7 +5,6 @@ // spell-checker:ignore (formats) cymdhm cymdhms mdhm mdhms ymdhm ymdhms datetime mktime use crate::common::util::{AtPath, TestScenario}; -use chrono::TimeZone; use filetime::{self, FileTime}; use std::fs::remove_file; use std::path::PathBuf; @@ -32,7 +31,7 @@ fn set_file_times(at: &AtPath, path: &str, atime: FileTime, mtime: FileTime) { } fn str_to_filetime(format: &str, s: &str) -> FileTime { - let tm = chrono::Utc.datetime_from_str(s, format).unwrap(); + let tm = chrono::NaiveDateTime::parse_from_str(s, format).unwrap(); FileTime::from_unix_time(tm.timestamp(), tm.timestamp_subsec_nanos()) } From 335e8d5464bb18ed2047550aaca570d690501173 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 12 Sep 2023 16:08:19 +0200 Subject: [PATCH 169/370] ci: replace deprecated "command" with "fix" markdownlint-cli2-action deprecated "command" input in favor of "fix" --- .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 27378cd96..01dfdd274 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -328,7 +328,7 @@ jobs: RUSTDOCFLAGS="-Dwarnings" cargo doc ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --no-deps --workspace --document-private-items - uses: DavidAnson/markdownlint-cli2-action@v12 with: - command: fix + fix: "true" globs: | *.md docs/src/*.md From d4217c5a129464cec638c56f06a679830d64ff71 Mon Sep 17 00:00:00 2001 From: Guillaume Ranquet Date: Wed, 6 Sep 2023 16:07:59 +0200 Subject: [PATCH 170/370] split: catch broken pipe error for round robin strategy The broken pipe error is not handled in the case of the round robin strategy (typically used with --filter). Align to the other strategies to silence that error in that use case too. fixes #5191 Signed-off-by: Guillaume Ranquet --- src/uu/split/src/split.rs | 14 ++++++++++---- tests/by-util/test_split.rs | 12 ++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 517031791..4a1624d07 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -1282,7 +1282,7 @@ fn split_into_n_chunks_by_line_round_robin( settings: &Settings, reader: &mut R, num_chunks: u64, -) -> UResult<()> +) -> std::io::Result<()> where R: BufRead, { @@ -1293,7 +1293,7 @@ where settings.suffix_length, settings.suffix_type, settings.suffix_start, - )?; + ).map_err(|e| io::Error::new(ErrorKind::Other, format!("{e}")))?; // Create one writer for each chunk. This will create each // of the underlying files (if not in `--filter` mode). @@ -1301,7 +1301,7 @@ where for _ in 0..num_chunks { let filename = filename_iterator .next() - .ok_or_else(|| USimpleError::new(1, "output file suffixes exhausted"))?; + .ok_or_else(|| io::Error::new(ErrorKind::Other, "output file suffixes exhausted"))?; let writer = settings.instantiate_current_writer(filename.as_str())?; writers.push(writer); } @@ -1346,7 +1346,13 @@ fn split(settings: &Settings) -> UResult<()> { kth_chunk_by_line(settings, &mut reader, chunk_number, num_chunks) } Strategy::Number(NumberType::RoundRobin(num_chunks)) => { - split_into_n_chunks_by_line_round_robin(settings, &mut reader, num_chunks) + match split_into_n_chunks_by_line_round_robin(settings, &mut reader, num_chunks) { + Ok(_) => Ok(()), + Err(e) => match e.kind() { + ErrorKind::BrokenPipe => Ok(()), + _ => Err(USimpleError::new(1, format!("{e}"))), + }, + } } Strategy::Number(_) => Err(USimpleError::new(1, "-n mode not yet fully implemented")), Strategy::Lines(chunk_size) => { diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 0b7bbfec6..cb7775781 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -299,6 +299,18 @@ fn test_filter_command_fails() { .fails(); } +#[test] +#[cfg(unix)] +fn test_filter_broken_pipe() { + let (at, mut ucmd) = at_and_ucmd!(); + let name = "filter-big-input"; + + RandomFile::new(&at, name).add_lines(1024 * 10); + ucmd + .args(&["--filter=head -c1 > /dev/null", "-n", "r/1", name]) + .succeeds(); +} + #[test] fn test_split_lines_number() { // Test if stdout/stderr for '--lines' option is correct From aa7b39ae493f6fd888c7a0231eeecc36a64556eb Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 13 Sep 2023 10:45:38 +0200 Subject: [PATCH 171/370] split: fix formatting --- src/uu/split/src/split.rs | 3 ++- tests/by-util/test_split.rs | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 4a1624d07..5ba9d9db2 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -1293,7 +1293,8 @@ where settings.suffix_length, settings.suffix_type, settings.suffix_start, - ).map_err(|e| io::Error::new(ErrorKind::Other, format!("{e}")))?; + ) + .map_err(|e| io::Error::new(ErrorKind::Other, format!("{e}")))?; // Create one writer for each chunk. This will create each // of the underlying files (if not in `--filter` mode). diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index cb7775781..aba06162b 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -306,8 +306,7 @@ fn test_filter_broken_pipe() { let name = "filter-big-input"; RandomFile::new(&at, name).add_lines(1024 * 10); - ucmd - .args(&["--filter=head -c1 > /dev/null", "-n", "r/1", name]) + ucmd.args(&["--filter=head -c1 > /dev/null", "-n", "r/1", name]) .succeeds(); } From 2523d3813960666ddf87ea1aa77b78c0b4faa289 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 11:51:31 +0000 Subject: [PATCH 172/370] chore(deps): update rust crate libc to 0.2.148 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f0863ef86..3362401cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1203,9 +1203,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libloading" diff --git a/Cargo.toml b/Cargo.toml index 03f43c26a..21b0fa30a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -287,7 +287,7 @@ glob = "0.3.1" half = "2.3" indicatif = "0.17" itertools = "0.11.0" -libc = "0.2.147" +libc = "0.2.148" lscolors = { version = "0.15.0", default-features = false, features = [ "nu-ansi-term", ] } From 0d07cefee8d287d082610a61ac023d3abb4b8b95 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 17:49:59 +0000 Subject: [PATCH 173/370] chore(deps): update codecov/codecov-action action to v4 --- .github/workflows/CICD.yml | 2 +- .github/workflows/GnuTests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 01dfdd274..36df67de6 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -1199,7 +1199,7 @@ jobs: ~/.cargo/bin/grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT - name: Upload coverage results (to Codecov.io) - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 # if: steps.vars.outputs.HAS_CODECOV_TOKEN with: # token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/GnuTests.yml b/.github/workflows/GnuTests.yml index 61f30eba4..b524f8fde 100644 --- a/.github/workflows/GnuTests.yml +++ b/.github/workflows/GnuTests.yml @@ -368,7 +368,7 @@ jobs: grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT - name: Upload coverage results (to Codecov.io) - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: file: ${{ steps.coverage.outputs.report }} flags: gnutests From dec788dec30339a6e0337664949b8c7c4dfc5109 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 15 Sep 2023 09:25:04 +0200 Subject: [PATCH 174/370] Revert "chore(deps): update codecov/codecov-action action to v4" --- .github/workflows/CICD.yml | 2 +- .github/workflows/GnuTests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 36df67de6..01dfdd274 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -1199,7 +1199,7 @@ jobs: ~/.cargo/bin/grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT - name: Upload coverage results (to Codecov.io) - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v3 # if: steps.vars.outputs.HAS_CODECOV_TOKEN with: # token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/GnuTests.yml b/.github/workflows/GnuTests.yml index b524f8fde..61f30eba4 100644 --- a/.github/workflows/GnuTests.yml +++ b/.github/workflows/GnuTests.yml @@ -368,7 +368,7 @@ jobs: grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT - name: Upload coverage results (to Codecov.io) - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v3 with: file: ${{ steps.coverage.outputs.report }} flags: gnutests From e59285e2766abfa3a04c71945cbc1eb9f5d0b327 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 15 Sep 2023 08:11:28 +0200 Subject: [PATCH 175/370] deny.toml: add terminal_size to skip list --- deny.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deny.toml b/deny.toml index c80588f51..b1707d035 100644 --- a/deny.toml +++ b/deny.toml @@ -89,6 +89,8 @@ skip = [ { name = "bitflags", version = "1.3.2" }, # various crates { name = "redox_syscall", version = "0.3.5" }, + # clap_builder, textwrap + { name = "terminal_size", version = "0.2.6" }, ] # spell-checker: enable From b8ff52f28b729efa44127adab2070792f37ae746 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 15 Sep 2023 15:59:41 +0000 Subject: [PATCH 176/370] chore(deps): update rust crate chrono to ^0.4.31 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3362401cc..3a0e17642 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -239,9 +239,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.30" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index 21b0fa30a..b15bf4e08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -263,7 +263,7 @@ binary-heap-plus = "0.5.0" bstr = "1.6" bytecount = "0.6.3" byteorder = "1.4.3" -chrono = { version = "^0.4.30", default-features = false, features = [ +chrono = { version = "^0.4.31", default-features = false, features = [ "std", "alloc", "clock", From 37ee889003509f701e83d33fcb07b9dc30b88aff Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 15 Sep 2023 22:34:17 +0200 Subject: [PATCH 177/370] ls -l: show an error when symlink not readable switching to match and handle the error Will help with tests/ls/stat-failed.sh --- src/uu/ls/src/ls.rs | 95 ++++++++++++++++++++++------------------ tests/by-util/test_ls.rs | 19 ++++++++ 2 files changed, 71 insertions(+), 43 deletions(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 18a1a221d..8d559ed15 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -2908,55 +2908,64 @@ fn display_file_name( && path.file_type(out).unwrap().is_symlink() && !path.must_dereference { - if let Ok(target) = path.p_buf.read_link() { - name.push_str(" -> "); + match path.p_buf.read_link() { + Ok(target) => { + name.push_str(" -> "); - // We might as well color the symlink output after the arrow. - // This makes extra system calls, but provides important information that - // people run `ls -l --color` are very interested in. - if let Some(ls_colors) = &config.color { - // We get the absolute path to be able to construct PathData with valid Metadata. - // This is because relative symlinks will fail to get_metadata. - let mut absolute_target = target.clone(); - if target.is_relative() { - if let Some(parent) = path.p_buf.parent() { - absolute_target = parent.join(absolute_target); + // We might as well color the symlink output after the arrow. + // This makes extra system calls, but provides important information that + // people run `ls -l --color` are very interested in. + if let Some(ls_colors) = &config.color { + // We get the absolute path to be able to construct PathData with valid Metadata. + // This is because relative symlinks will fail to get_metadata. + let mut absolute_target = target.clone(); + if target.is_relative() { + if let Some(parent) = path.p_buf.parent() { + absolute_target = parent.join(absolute_target); + } } - } - let target_data = PathData::new(absolute_target, None, None, config, false); + let target_data = PathData::new(absolute_target, None, None, config, false); - // If we have a symlink to a valid file, we use the metadata of said file. - // Because we use an absolute path, we can assume this is guaranteed to exist. - // Otherwise, we use path.md(), which will guarantee we color to the same - // color of non-existent symlinks according to style_for_path_with_metadata. - if path.md(out).is_none() - && get_metadata(target_data.p_buf.as_path(), target_data.must_dereference) - .is_err() - { - name.push_str(&path.p_buf.read_link().unwrap().to_string_lossy()); + // If we have a symlink to a valid file, we use the metadata of said file. + // Because we use an absolute path, we can assume this is guaranteed to exist. + // Otherwise, we use path.md(), which will guarantee we color to the same + // color of non-existent symlinks according to style_for_path_with_metadata. + if path.md(out).is_none() + && get_metadata(target_data.p_buf.as_path(), target_data.must_dereference) + .is_err() + { + name.push_str(&path.p_buf.read_link().unwrap().to_string_lossy()); + } else { + // Use fn get_metadata instead of md() here and above because ls + // should not exit with an err, if we are unable to obtain the target_metadata + let target_metadata = match get_metadata( + target_data.p_buf.as_path(), + target_data.must_dereference, + ) { + Ok(md) => md, + Err(_) => path.md(out).unwrap().to_owned(), + }; + + name.push_str(&color_name( + escape_name(target.as_os_str(), &config.quoting_style), + &target_data.p_buf, + Some(&target_metadata), + ls_colors, + )); + } } else { - // Use fn get_metadata instead of md() here and above because ls - // should not exit with an err, if we are unable to obtain the target_metadata - let target_metadata = match get_metadata( - target_data.p_buf.as_path(), - target_data.must_dereference, - ) { - Ok(md) => md, - Err(_) => path.md(out).unwrap().to_owned(), - }; - - name.push_str(&color_name( - escape_name(target.as_os_str(), &config.quoting_style), - &target_data.p_buf, - Some(&target_metadata), - ls_colors, - )); + // If no coloring is required, we just use target as is. + // Apply the right quoting + name.push_str(&escape_name(target.as_os_str(), &config.quoting_style)); } - } else { - // If no coloring is required, we just use target as is. - // Apply the right quoting - name.push_str(&escape_name(target.as_os_str(), &config.quoting_style)); + } + Err(err) => { + show!(LsError::IOErrorContext( + err, + path.p_buf.to_path_buf(), + false + )); } } } diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index f18150358..5f2b7e443 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -3503,3 +3503,22 @@ fn test_invalid_utf8() { at.touch(filename); ucmd.succeeds(); } + +#[cfg(all(unix, feature = "chmod"))] +#[test] +fn test_ls_perm_io_errors() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.mkdir("d"); + at.symlink_file("/", "d/s"); + + scene.ccmd("chmod").arg("600").arg("d").succeeds(); + + scene + .ucmd() + .arg("-l") + .arg("d") + .fails() + .code_is(1) + .stderr_contains("Permission denied"); +} From f9c91fda2f6bc8391f0bc33e102378d3740ec16b Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 16 Sep 2023 15:37:23 +0200 Subject: [PATCH 178/370] Document how to run the pure Rust tests --- CONTRIBUTING.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bd87e2d05..6f67eb828 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -137,6 +137,12 @@ If you also want to test the core utilities: cargo test -p uucore -p coreutils ``` +Or to test the pure Rust tests in the utility itself: + +```shell +cargo test -p uu_ls --lib +``` + Running the complete test suite might take a while. We use [nextest](https://nexte.st/index.html) in the CI and you might want to try it out locally. It can speed up the execution time of the whole test run significantly if the cpu has multiple cores. From 975b3286308adbaea9c1ea1e1df16f33498f14fc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 17 Sep 2023 08:36:43 +0000 Subject: [PATCH 179/370] chore(deps): update rust crate terminal_size to 0.3.0 --- Cargo.lock | 16 +++++++++++++--- Cargo.toml | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a0e17642..9b079d090 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ dependencies = [ "anstyle", "clap_lex", "strsim", - "terminal_size", + "terminal_size 0.2.6", ] [[package]] @@ -2135,6 +2135,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix 0.38.8", + "windows-sys 0.48.0", +] + [[package]] name = "textwrap" version = "0.16.0" @@ -2142,7 +2152,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" dependencies = [ "smawk", - "terminal_size", + "terminal_size 0.2.6", "unicode-linebreak", "unicode-width", ] @@ -2671,7 +2681,7 @@ dependencies = [ "once_cell", "selinux", "term_grid", - "terminal_size", + "terminal_size 0.3.0", "unicode-width", "uucore", ] diff --git a/Cargo.toml b/Cargo.toml index b15bf4e08..f7a3a3725 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -320,7 +320,7 @@ signal-hook = "0.3.17" smallvec = { version = "1.11", features = ["union"] } tempfile = "3.8.0" term_grid = "0.1.5" -terminal_size = "0.2.6" +terminal_size = "0.3.0" textwrap = { version = "0.16.0", features = ["terminal_size"] } thiserror = "1.0" time = { version = "0.3" } From 416a4832b80596eb017869e5cfb8ca4851ae6c0d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 17 Sep 2023 17:46:16 +0000 Subject: [PATCH 180/370] fix(deps): update rust crate dns-lookup to 2.0.3 --- Cargo.lock | 4 ++-- src/uucore/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b079d090..4efd163a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -746,9 +746,9 @@ dependencies = [ [[package]] name = "dns-lookup" -version = "2.0.2" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f332aa79f9e9de741ac013237294ef42ce2e9c6394dc7d766725812f1238812" +checksum = "8d0fa3cd8dc96ada974e126a940d37d4079bbbe6a24aca15b1113c2f362441c5" dependencies = [ "cfg-if", "libc", diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 90ae74aab..93bc618ce 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -20,7 +20,7 @@ path = "src/lib/lib.rs" [dependencies] clap = { workspace = true } uucore_procs = { workspace = true } -dns-lookup = { version = "2.0.2", optional = true } +dns-lookup = { version = "2.0.3", optional = true } dunce = { version = "1.0.4", optional = true } wild = "2.1" glob = { workspace = true } From d01fe6a10f4e325de8b3c5bf4fdd5c221b47ca03 Mon Sep 17 00:00:00 2001 From: Rojin Raju <46747837+rojin254@users.noreply.github.com> Date: Tue, 19 Sep 2023 01:17:02 +0530 Subject: [PATCH 181/370] ls.rs: rename variable name dfn to displayed_file Closes: #5282 --- src/uu/ls/src/ls.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 8d559ed15..cc741fcf2 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -2482,13 +2482,13 @@ fn display_item_long( } }; - let dfn = display_file_name(item, config, None, String::new(), out).contents; + let displayed_file = display_file_name(item, config, None, String::new(), out).contents; write!( out, " {} {}{}", display_date(md, config), - dfn, + displayed_file, config.line_ending )?; } else { @@ -2561,7 +2561,7 @@ fn display_item_long( write!(out, " {}", pad_right("?", padding.uname))?; } - let dfn = display_file_name(item, config, None, String::new(), out).contents; + let displayed_file = display_file_name(item, config, None, String::new(), out).contents; let date_len = 12; writeln!( @@ -2569,7 +2569,7 @@ fn display_item_long( " {} {} {}", pad_left("?", padding.size), pad_left("?", date_len), - dfn, + displayed_file, )?; } From 514315462c7e429599b89a7a6da38e5efadacda4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 19:47:21 +0000 Subject: [PATCH 182/370] chore(deps): update mfinelli/setup-shfmt action to v3 --- .github/workflows/CheckScripts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CheckScripts.yml b/.github/workflows/CheckScripts.yml index 98ae6cb75..995b5456f 100644 --- a/.github/workflows/CheckScripts.yml +++ b/.github/workflows/CheckScripts.yml @@ -52,7 +52,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup shfmt - uses: mfinelli/setup-shfmt@v2 + uses: mfinelli/setup-shfmt@v3 - name: Run shfmt shell: bash run: | From 1107fadca9e263b8aa976d82ac61be7952d068ae Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 19 Sep 2023 10:47:00 +0200 Subject: [PATCH 183/370] nl: increase line number over multiple files --- src/uu/nl/src/nl.rs | 33 ++++++++++++++++++++++++--------- tests/by-util/test_nl.rs | 13 +++++++++++++ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 61a0a9f35..356882237 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -55,6 +55,20 @@ impl Default for Settings { } } +struct Stats { + line_number: i64, + consecutive_empty_lines: u64, +} + +impl Stats { + fn new(starting_line_number: i64) -> Self { + Self { + line_number: starting_line_number, + consecutive_empty_lines: 0, + } + } +} + // NumberingStyle stores which lines are to be numbered. // The possible options are: // 1. Number all lines @@ -160,6 +174,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { None => vec!["-".to_owned()], }; + let mut stats = Stats::new(settings.starting_line_number); + for file in &files { if file == "-" { // If both file names and '-' are specified, we choose to treat first all @@ -170,12 +186,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let path = Path::new(file); let reader = File::open(path).map_err_context(|| file.to_string())?; let mut buffer = BufReader::new(reader); - nl(&mut buffer, &settings)?; + nl(&mut buffer, &mut stats, &settings)?; } if read_stdin { let mut buffer = BufReader::new(stdin()); - nl(&mut buffer, &settings)?; + nl(&mut buffer, &mut stats, &settings)?; } Ok(()) } @@ -285,10 +301,9 @@ pub fn uu_app() -> Command { } // nl implements the main functionality for an individual buffer. -fn nl(reader: &mut BufReader, settings: &Settings) -> UResult<()> { +fn nl(reader: &mut BufReader, stats: &mut Stats, settings: &Settings) -> UResult<()> { let mut current_numbering_style = &settings.body_numbering; - let mut line_no = settings.starting_line_number; - let mut consecutive_empty_lines = 0; + let mut consecutive_empty_lines = stats.consecutive_empty_lines; for line in reader.lines() { let line = line.map_err_context(|| "could not read line".to_string())?; @@ -312,7 +327,7 @@ fn nl(reader: &mut BufReader, settings: &Settings) -> UResult<()> { if let Some(new_style) = new_numbering_style { current_numbering_style = new_style; if settings.renumber { - line_no = settings.starting_line_number; + stats.line_number = settings.starting_line_number; } println!(); } else { @@ -336,13 +351,13 @@ fn nl(reader: &mut BufReader, settings: &Settings) -> UResult<()> { "{}{}{}", settings .number_format - .format(line_no, settings.number_width), + .format(stats.line_number, settings.number_width), settings.number_separator, line ); // update line number for the potential next line - match line_no.checked_add(settings.line_increment) { - Some(new_line_no) => line_no = new_line_no, + match stats.line_number.checked_add(settings.line_increment) { + Some(new_line_number) => stats.line_number = new_line_number, None => return Err(USimpleError::new(1, "line number overflow")), } } else { diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index b58c0c206..336ab4c29 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -311,6 +311,19 @@ fn test_default_body_numbering() { .stdout_is(" 1\ta\n \n 2\tb\n"); } +#[test] +fn test_default_body_numbering_multiple_files() { + let (at, mut ucmd) = at_and_ucmd!(); + + at.write("a.txt", "a"); + at.write("b.txt", "b"); + at.write("c.txt", "c"); + + ucmd.args(&["a.txt", "b.txt", "c.txt"]) + .succeeds() + .stdout_is(" 1\ta\n 2\tb\n 3\tc\n"); +} + #[test] fn test_body_numbering_all_lines_without_delimiter() { for arg in ["-ba", "--body-numbering=a"] { From 1a30a1b8b656afe0deb674a4b848f7b311a18c81 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 19 Sep 2023 10:47:20 +0200 Subject: [PATCH 184/370] nl: support --join-blank-lines over multiple files --- src/uu/nl/src/nl.rs | 7 +++---- tests/by-util/test_nl.rs | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 356882237..fef9c030a 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -303,15 +303,14 @@ pub fn uu_app() -> Command { // nl implements the main functionality for an individual buffer. fn nl(reader: &mut BufReader, stats: &mut Stats, settings: &Settings) -> UResult<()> { let mut current_numbering_style = &settings.body_numbering; - let mut consecutive_empty_lines = stats.consecutive_empty_lines; for line in reader.lines() { let line = line.map_err_context(|| "could not read line".to_string())?; if line.is_empty() { - consecutive_empty_lines += 1; + stats.consecutive_empty_lines += 1; } else { - consecutive_empty_lines = 0; + stats.consecutive_empty_lines = 0; }; // FIXME section delimiters are hardcoded and settings.section_delimiter is ignored @@ -336,7 +335,7 @@ fn nl(reader: &mut BufReader, stats: &mut Stats, settings: &Settings // for numbering, and only number the last one NumberingStyle::All if line.is_empty() - && consecutive_empty_lines % settings.join_blank_lines != 0 => + && stats.consecutive_empty_lines % settings.join_blank_lines != 0 => { false } diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index 336ab4c29..b008c61de 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -284,6 +284,31 @@ fn test_join_blank_lines() { } } +#[test] +fn test_join_blank_lines_multiple_files() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + at.write("a.txt", "\n\n"); + at.write("b.txt", "\n\n"); + at.write("c.txt", "\n\n"); + + for arg in ["-l3", "--join-blank-lines=3"] { + scene + .ucmd() + .args(&[arg, "--body-numbering=a", "a.txt", "b.txt", "c.txt"]) + .succeeds() + .stdout_is(concat!( + " \n", + " \n", + " 1\t\n", + " \n", + " \n", + " 2\t\n", + )); + } +} + #[test] fn test_join_blank_lines_zero() { for arg in ["-l0", "--join-blank-lines=0"] { From 9443985b49cbf630165d003ec6b1984db94d2b8c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:13:47 +0000 Subject: [PATCH 185/370] chore(deps): update rust crate unicode-width to 0.1.11 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4efd163a3..ece92cdfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2241,9 +2241,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" diff --git a/Cargo.toml b/Cargo.toml index f7a3a3725..866b1f585 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -325,7 +325,7 @@ textwrap = { version = "0.16.0", features = ["terminal_size"] } thiserror = "1.0" time = { version = "0.3" } unicode-segmentation = "1.10.1" -unicode-width = "0.1.10" +unicode-width = "0.1.11" utf-8 = "0.7.6" walkdir = "2.4" winapi-util = "0.1.5" From 5586e7bf2bae7d165861e884004aa3c751171d82 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 20 Sep 2023 04:47:16 +0000 Subject: [PATCH 186/370] chore(deps): update davidanson/markdownlint-cli2-action action to v13 --- .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 01dfdd274..577e235f9 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -326,7 +326,7 @@ jobs: shell: bash run: | RUSTDOCFLAGS="-Dwarnings" cargo doc ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --no-deps --workspace --document-private-items - - uses: DavidAnson/markdownlint-cli2-action@v12 + - uses: DavidAnson/markdownlint-cli2-action@v13 with: fix: "true" globs: | From 9b4d2c6bc46cbedfa377e592d6188a643a88e3ed Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 20 Sep 2023 08:17:46 +0200 Subject: [PATCH 187/370] ls: implement --dired * Support ls --dired * stat-failed.sh: update of the test - we have a small difference * ls --dired: address some of the comments * fix warnings * use unwrap() * Improve test Co-authored-by: Daniel Hofstetter * Simplify test Co-authored-by: Daniel Hofstetter * Remove a word from the spell ignore Co-authored-by: Daniel Hofstetter * remove duplication of the spell ignore Co-authored-by: Daniel Hofstetter * rustfmt --------- Co-authored-by: Daniel Hofstetter --- src/uu/ls/src/dired.rs | 178 +++++++++++++++++++ src/uu/ls/src/ls.rs | 172 +++++++++++++----- src/uucore/src/lib/features/quoting_style.rs | 81 ++++++++- tests/by-util/test_ls.rs | 125 ++++++++++++- util/build-gnu.sh | 6 +- 5 files changed, 510 insertions(+), 52 deletions(-) create mode 100644 src/uu/ls/src/dired.rs diff --git a/src/uu/ls/src/dired.rs b/src/uu/ls/src/dired.rs new file mode 100644 index 000000000..f66d22b38 --- /dev/null +++ b/src/uu/ls/src/dired.rs @@ -0,0 +1,178 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. +// spell-checker:ignore dired subdired + +use crate::Config; +use std::fmt; +use std::io::{BufWriter, Stdout, Write}; +use uucore::error::UResult; + +#[derive(Debug, Clone)] +pub struct BytePosition { + pub start: usize, + pub end: usize, +} + +/// Represents the output structure for DIRED, containing positions for both DIRED and SUBDIRED. +#[derive(Debug, Clone, Default)] +pub struct DiredOutput { + pub dired_positions: Vec, + pub subdired_positions: Vec, + pub just_printed_total: bool, +} + +impl fmt::Display for BytePosition { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{} {}", self.start, self.end) + } +} + +// When --dired is used, all lines starts with 2 spaces +static DIRED_TRAILING_OFFSET: usize = 2; + +/// Calculates the byte positions for DIRED +pub fn calculate_dired_byte_positions( + output_display_len: usize, + dfn_len: usize, + dired_positions: &[BytePosition], +) -> (usize, usize) { + let offset_from_previous_line = if let Some(last_position) = dired_positions.last() { + last_position.end + 1 + } else { + 0 + }; + + let start = output_display_len + offset_from_previous_line; + let end = start + dfn_len; + (start, end) +} + +pub fn indent(out: &mut BufWriter) -> UResult<()> { + write!(out, " ")?; + Ok(()) +} + +pub fn calculate_offset_and_push(dired: &mut DiredOutput, path_len: usize) { + let offset = if dired.subdired_positions.is_empty() { + DIRED_TRAILING_OFFSET + } else { + dired.subdired_positions[dired.subdired_positions.len() - 1].start + DIRED_TRAILING_OFFSET + }; + dired.subdired_positions.push(BytePosition { + start: offset, + end: path_len + offset, + }); +} + +/// Prints the dired output based on the given configuration and dired structure. +pub fn print_dired_output( + config: &Config, + dired: &DiredOutput, + out: &mut BufWriter, +) -> UResult<()> { + out.flush()?; + if config.recursive { + print_positions("//SUBDIRED//", &dired.subdired_positions); + } else if !dired.just_printed_total { + print_positions("//DIRED//", &dired.dired_positions); + } + println!("//DIRED-OPTIONS// --quoting-style={}", config.quoting_style); + Ok(()) +} + +/// Helper function to print positions with a given prefix. +fn print_positions(prefix: &str, positions: &Vec) { + print!("{}", prefix); + for c in positions { + print!(" {}", c); + } + println!(); +} + +pub fn add_total(total_len: usize, dired: &mut DiredOutput) { + dired.just_printed_total = true; + dired.dired_positions.push(BytePosition { + start: 0, + // the 2 is from the trailing spaces + // the 1 is from the line ending (\n) + end: total_len + DIRED_TRAILING_OFFSET - 1, + }); +} + +/// Calculates byte positions and updates the dired structure. +pub fn calculate_and_update_positions( + output_display_len: usize, + dfn_len: usize, + dired: &mut DiredOutput, +) { + let offset = dired + .dired_positions + .last() + .map_or(DIRED_TRAILING_OFFSET, |last_position| { + last_position.start + DIRED_TRAILING_OFFSET + }); + let start = output_display_len + offset + DIRED_TRAILING_OFFSET; + let end = start + dfn_len; + update_positions(start, end, dired, true); +} + +/// Updates the dired positions based on the given start and end positions. +/// update when it is the first element in the list (to manage "total X" +/// insert when it isn't the about total +pub fn update_positions(start: usize, end: usize, dired: &mut DiredOutput, adjust: bool) { + if dired.just_printed_total { + if let Some(last_position) = dired.dired_positions.last_mut() { + *last_position = BytePosition { + start: if adjust { + start + last_position.end + } else { + start + }, + end: if adjust { end + last_position.end } else { end }, + }; + dired.just_printed_total = false; + } + } else { + dired.dired_positions.push(BytePosition { start, end }); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_calculate_dired_byte_positions() { + let output_display = "sample_output".to_string(); + let dfn = "sample_file".to_string(); + let dired_positions = vec![BytePosition { start: 5, end: 10 }]; + let (start, end) = + calculate_dired_byte_positions(output_display.len(), dfn.len(), &dired_positions); + + assert_eq!(start, 24); + assert_eq!(end, 35); + } + + #[test] + fn test_dired_update_positions() { + let mut dired = DiredOutput { + dired_positions: vec![BytePosition { start: 5, end: 10 }], + subdired_positions: vec![], + just_printed_total: true, + }; + + // Test with adjust = true + update_positions(15, 20, &mut dired, true); + let last_position = dired.dired_positions.last().unwrap(); + assert_eq!(last_position.start, 25); // 15 + 10 (end of the previous position) + assert_eq!(last_position.end, 30); // 20 + 10 (end of the previous position) + + // Test with adjust = false + update_positions(30, 35, &mut dired, false); + let last_position = dired.dired_positions.last().unwrap(); + assert_eq!(last_position.start, 30); + assert_eq!(last_position.end, 35); + } +} diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index cc741fcf2..3d67cccaa 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) cpio svgz webm somegroup nlink rmvb xspf tabsize dired +// spell-checker:ignore (ToDO) cpio svgz webm somegroup nlink rmvb xspf tabsize dired subdired use clap::{ builder::{NonEmptyStringValueParser, ValueParser}, @@ -61,7 +61,8 @@ use uucore::{ version_cmp::version_cmp, }; use uucore::{help_about, help_section, help_usage, parse_glob, show, show_error, show_warning}; - +mod dired; +use dired::DiredOutput; #[cfg(not(feature = "selinux"))] static CONTEXT_HELP_TEXT: &str = "print any security context of each file (not enabled)"; #[cfg(feature = "selinux")] @@ -167,6 +168,7 @@ enum LsError { IOError(std::io::Error), IOErrorContext(std::io::Error, PathBuf, bool), BlockSizeParseError(String), + ConflictingArgumentDired(), AlreadyListedError(PathBuf), TimeStyleParseError(String, Vec), } @@ -179,6 +181,7 @@ impl UError for LsError { Self::IOErrorContext(_, _, false) => 1, Self::IOErrorContext(_, _, true) => 2, Self::BlockSizeParseError(_) => 1, + Self::ConflictingArgumentDired() => 1, Self::AlreadyListedError(_) => 2, Self::TimeStyleParseError(_, _) => 1, } @@ -193,6 +196,10 @@ impl Display for LsError { Self::BlockSizeParseError(s) => { write!(f, "invalid --block-size argument {}", s.quote()) } + Self::ConflictingArgumentDired() => { + write!(f, "--dired requires --format=long") + } + Self::TimeStyleParseError(s, possible_time_styles) => { write!( f, @@ -406,6 +413,7 @@ pub struct Config { selinux_supported: bool, group_directories_first: bool, line_ending: LineEnding, + dired: bool, } // Fields that can be removed or added to the long format @@ -610,6 +618,8 @@ fn extract_quoting_style(options: &clap::ArgMatches, show_control: bool) -> Quot QuotingStyle::C { quotes: quoting_style::Quotes::Double, } + } else if options.get_flag(options::DIRED) { + QuotingStyle::Literal { show_control } } else { // TODO: use environment variable if available QuotingStyle::Shell { @@ -954,6 +964,11 @@ impl Config { None }; + let dired = options.get_flag(options::DIRED); + if dired && format != Format::Long { + return Err(Box::new(LsError::ConflictingArgumentDired())); + } + let dereference = if options.get_flag(options::dereference::ALL) { Dereference::All } else if options.get_flag(options::dereference::ARGS) { @@ -1003,6 +1018,7 @@ impl Config { }, group_directories_first: options.get_flag(options::GROUP_DIRECTORIES_FIRST), line_ending: LineEnding::from_zero_flag(options.get_flag(options::ZERO)), + dired, }) } } @@ -1135,7 +1151,7 @@ pub fn uu_app() -> Command { Arg::new(options::DIRED) .long(options::DIRED) .short('D') - .hide(true) + .help("generate output designed for Emacs' dired (Directory Editor) mode") .action(ArgAction::SetTrue), ) // The next four arguments do not override with the other format @@ -1844,6 +1860,7 @@ pub fn list(locs: Vec<&Path>, config: &Config) -> UResult<()> { let mut files = Vec::::new(); let mut dirs = Vec::::new(); let mut out = BufWriter::new(stdout()); + let mut dired = DiredOutput::default(); let initial_locs_len = locs.len(); for loc in locs { @@ -1877,7 +1894,7 @@ pub fn list(locs: Vec<&Path>, config: &Config) -> UResult<()> { sort_entries(&mut files, config, &mut out); sort_entries(&mut dirs, config, &mut out); - display_items(&files, config, &mut out)?; + display_items(&files, config, &mut out, &mut dired)?; for (pos, path_data) in dirs.iter().enumerate() { // Do read_dir call here to match GNU semantics by printing @@ -1899,7 +1916,13 @@ pub fn list(locs: Vec<&Path>, config: &Config) -> UResult<()> { // Print dir heading - name... 'total' comes after error display if initial_locs_len > 1 || config.recursive { if pos.eq(&0usize) && files.is_empty() { + if config.dired { + dired::indent(&mut out)?; + } writeln!(out, "{}:", path_data.p_buf.display())?; + if config.dired { + dired::calculate_offset_and_push(&mut dired, path_data.display_name.len()); + } } else { writeln!(out, "\n{}:", path_data.p_buf.display())?; } @@ -1909,9 +1932,18 @@ pub fn list(locs: Vec<&Path>, config: &Config) -> UResult<()> { &path_data.p_buf, path_data.must_dereference, )?); - enter_directory(path_data, read_dir, config, &mut out, &mut listed_ancestors)?; + enter_directory( + path_data, + read_dir, + config, + &mut out, + &mut listed_ancestors, + &mut dired, + )?; + } + if config.dired { + dired::print_dired_output(config, &dired, &mut out)?; } - Ok(()) } @@ -2022,6 +2054,7 @@ fn enter_directory( config: &Config, out: &mut BufWriter, listed_ancestors: &mut HashSet, + dired: &mut DiredOutput, ) -> UResult<()> { // Create vec of entries with initial dot files let mut entries: Vec = if config.files == Files::All { @@ -2067,10 +2100,14 @@ fn enter_directory( // Print total after any error display if config.format == Format::Long || config.alloc_size { - display_total(&entries, config, out)?; + let total = return_total(&entries, config, out)?; + write!(out, "{}", total.as_str())?; + if config.dired { + dired::add_total(total.len(), dired); + } } - display_items(&entries, config, out)?; + display_items(&entries, config, out, dired)?; if config.recursive { for e in entries @@ -2095,7 +2132,7 @@ fn enter_directory( .insert(FileInformation::from_path(&e.p_buf, e.must_dereference)?) { writeln!(out, "\n{}:", e.p_buf.display())?; - enter_directory(e, rd, config, out, listed_ancestors)?; + enter_directory(e, rd, config, out, listed_ancestors, dired)?; listed_ancestors .remove(&FileInformation::from_path(&e.p_buf, e.must_dereference)?); } else { @@ -2154,7 +2191,11 @@ fn pad_right(string: &str, count: usize) -> String { format!("{string:) -> UResult<()> { +fn return_total( + items: &[PathData], + config: &Config, + out: &mut BufWriter, +) -> UResult { let mut total_size = 0; for item in items { total_size += item @@ -2162,13 +2203,14 @@ fn display_total(items: &[PathData], config: &Config, out: &mut BufWriter) -> UResult<()> { +fn display_items( + items: &[PathData], + config: &Config, + out: &mut BufWriter, + dired: &mut DiredOutput, +) -> UResult<()> { // `-Z`, `--context`: // Display the SELinux security context or '?' if none is found. When used with the `-l` // option, print the security context to the left of the size column. @@ -2220,6 +2267,7 @@ fn display_items(items: &[PathData], config: &Config, out: &mut BufWriter, + dired: &mut DiredOutput, ) -> UResult<()> { + let mut output_display: String = String::new(); + if config.dired { + output_display += " "; + } if let Some(md) = item.md(out) { write!( - out, + output_display, "{}{} {}", display_permissions(md, true), if item.security_context.len() > 1 { @@ -2416,49 +2469,54 @@ fn display_item_long( "" }, pad_left(&display_symlink_count(md), padding.link_count) - )?; + ) + .unwrap(); if config.long.owner { write!( - out, + output_display, " {}", pad_right(&display_uname(md, config), padding.uname) - )?; + ) + .unwrap(); } if config.long.group { write!( - out, + output_display, " {}", pad_right(&display_group(md, config), padding.group) - )?; + ) + .unwrap(); } if config.context { write!( - out, + output_display, " {}", pad_right(&item.security_context, padding.context) - )?; + ) + .unwrap(); } // Author is only different from owner on GNU/Hurd, so we reuse // the owner, since GNU/Hurd is not currently supported by Rust. if config.long.author { write!( - out, + output_display, " {}", pad_right(&display_uname(md, config), padding.uname) - )?; + ) + .unwrap(); } match display_len_or_rdev(md, config) { SizeOrDeviceId::Size(size) => { - write!(out, " {}", pad_left(&size, padding.size))?; + write!(output_display, " {}", pad_left(&size, padding.size)).unwrap(); } SizeOrDeviceId::Device(major, minor) => { write!( - out, + output_display, " {}, {}", pad_left( &major, @@ -2478,19 +2536,23 @@ fn display_item_long( #[cfg(unix)] padding.minor, ), - )?; + ) + .unwrap(); } }; - let displayed_file = display_file_name(item, config, None, String::new(), out).contents; + write!(output_display, " {} ", display_date(md, config)).unwrap(); - write!( - out, - " {} {}{}", - display_date(md, config), - displayed_file, - config.line_ending - )?; + let displayed_file = display_file_name(item, config, None, String::new(), out).contents; + if config.dired { + let (start, end) = dired::calculate_dired_byte_positions( + output_display.len(), + displayed_file.len(), + &dired.dired_positions, + ); + dired::update_positions(start, end, dired, false); + } + write!(output_display, "{}{}", displayed_file, config.line_ending).unwrap(); } else { #[cfg(unix)] let leading_char = { @@ -2526,7 +2588,7 @@ fn display_item_long( }; write!( - out, + output_display, "{}{} {}", format_args!("{leading_char}?????????"), if item.security_context.len() > 1 { @@ -2537,41 +2599,53 @@ fn display_item_long( "" }, pad_left("?", padding.link_count) - )?; + ) + .unwrap(); if config.long.owner { - write!(out, " {}", pad_right("?", padding.uname))?; + write!(output_display, " {}", pad_right("?", padding.uname)).unwrap(); } if config.long.group { - write!(out, " {}", pad_right("?", padding.group))?; + write!(output_display, " {}", pad_right("?", padding.group)).unwrap(); } if config.context { write!( - out, + output_display, " {}", pad_right(&item.security_context, padding.context) - )?; + ) + .unwrap(); } // Author is only different from owner on GNU/Hurd, so we reuse // the owner, since GNU/Hurd is not currently supported by Rust. if config.long.author { - write!(out, " {}", pad_right("?", padding.uname))?; + write!(output_display, " {}", pad_right("?", padding.uname)).unwrap(); } let displayed_file = display_file_name(item, config, None, String::new(), out).contents; let date_len = 12; - writeln!( - out, - " {} {} {}", + write!( + output_display, + " {} {} ", pad_left("?", padding.size), pad_left("?", date_len), - displayed_file, - )?; + ) + .unwrap(); + + if config.dired { + dired::calculate_and_update_positions( + output_display.len(), + displayed_file.trim().len(), + dired, + ); + } + write!(output_display, "{}{}", displayed_file, config.line_ending).unwrap(); } + write!(out, "{}", output_display)?; Ok(()) } diff --git a/src/uucore/src/lib/features/quoting_style.rs b/src/uucore/src/lib/features/quoting_style.rs index 1b9a76aae..b517dbd8d 100644 --- a/src/uucore/src/lib/features/quoting_style.rs +++ b/src/uucore/src/lib/features/quoting_style.rs @@ -4,12 +4,14 @@ // file that was distributed with this source code. use std::char::from_digit; use std::ffi::OsStr; +use std::fmt; // These are characters with special meaning in the shell (e.g. bash). // The first const contains characters that only have a special meaning when they appear at the beginning of a name. const SPECIAL_SHELL_CHARS_START: &[char] = &['~', '#']; const SPECIAL_SHELL_CHARS: &str = "`$&*()|[]{};\\'\"<>?! "; +#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum QuotingStyle { Shell { escape: bool, @@ -24,7 +26,7 @@ pub enum QuotingStyle { }, } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum Quotes { None, Single, @@ -316,6 +318,42 @@ pub fn escape_name(name: &OsStr, style: &QuotingStyle) -> String { } } +impl fmt::Display for QuotingStyle { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Self::Shell { + escape, + always_quote, + show_control, + } => { + let mut style = "shell".to_string(); + if escape { + style.push_str("-escape"); + } + if always_quote { + style.push_str("-always-quote"); + } + if show_control { + style.push_str("-show-control"); + } + f.write_str(&style) + } + Self::C { .. } => f.write_str("C"), + Self::Literal { .. } => f.write_str("literal"), + } + } +} + +impl fmt::Display for Quotes { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Self::None => f.write_str("None"), + Self::Single => f.write_str("Single"), + Self::Double => f.write_str("Double"), + } + } +} + #[cfg(test)] mod tests { use crate::quoting_style::{escape_name, Quotes, QuotingStyle}; @@ -732,4 +770,45 @@ mod tests { ], ); } + + #[test] + fn test_quoting_style_display() { + let style = QuotingStyle::Shell { + escape: true, + always_quote: false, + show_control: false, + }; + assert_eq!(format!("{}", style), "shell-escape"); + + let style = QuotingStyle::Shell { + escape: false, + always_quote: true, + show_control: false, + }; + assert_eq!(format!("{}", style), "shell-always-quote"); + + let style = QuotingStyle::Shell { + escape: false, + always_quote: false, + show_control: true, + }; + assert_eq!(format!("{}", style), "shell-show-control"); + + let style = QuotingStyle::C { + quotes: Quotes::Double, + }; + assert_eq!(format!("{}", style), "C"); + + let style = QuotingStyle::Literal { + show_control: false, + }; + assert_eq!(format!("{}", style), "literal"); + } + + #[test] + fn test_quotes_display() { + assert_eq!(format!("{}", Quotes::None), "None"); + assert_eq!(format!("{}", Quotes::Single), "Single"); + assert_eq!(format!("{}", Quotes::Double), "Double"); + } } diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 5f2b7e443..87b306656 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc neee naaaaa nbcdef nfffff +// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc neee naaaaa nbcdef nfffff dired subdired #[cfg(any(unix, feature = "feat_selinux"))] use crate::common::util::expected_result; @@ -3522,3 +3522,126 @@ fn test_ls_perm_io_errors() { .code_is(1) .stderr_contains("Permission denied"); } + +#[test] +fn test_ls_dired_incompatible() { + let scene = TestScenario::new(util_name!()); + + scene + .ucmd() + .arg("--dired") + .fails() + .code_is(1) + .stderr_contains("--dired requires --format=long"); +} + +#[test] +fn test_ls_dired_recursive() { + let scene = TestScenario::new(util_name!()); + + scene + .ucmd() + .arg("--dired") + .arg("-l") + .arg("-R") + .succeeds() + .stdout_does_not_contain("//DIRED//") + .stdout_contains(" total 0") + .stdout_contains("//SUBDIRED// 2 3") + .stdout_contains("//DIRED-OPTIONS// --quoting-style"); +} + +#[test] +fn test_ls_dired_simple() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + scene + .ucmd() + .arg("--dired") + .arg("-l") + .succeeds() + .stdout_contains(" total 0"); + + at.mkdir("d"); + at.touch("d/a1"); + let mut cmd = scene.ucmd(); + cmd.arg("--dired").arg("-l").arg("d"); + let result = cmd.succeeds(); + result.stdout_contains(" total 0"); + println!(" result.stdout = {:#?}", result.stdout_str()); + + let dired_line = result + .stdout_str() + .lines() + .find(|&line| line.starts_with("//DIRED//")) + .unwrap(); + let positions: Vec = dired_line + .split_whitespace() + .skip(1) + .map(|s| s.parse().unwrap()) + .collect(); + + assert_eq!(positions.len(), 2); + + let start_pos = positions[0]; + let end_pos = positions[1]; + + // Extract the filename using the positions + let filename = + String::from_utf8(result.stdout_str().as_bytes()[start_pos..end_pos].to_vec()).unwrap(); + + assert_eq!(filename, "a1"); +} + +#[test] +fn test_ls_dired_complex() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + at.mkdir("d"); + at.mkdir("d/d"); + at.touch("d/a1"); + at.touch("d/a22"); + at.touch("d/a333"); + at.touch("d/a4444"); + + let mut cmd = scene.ucmd(); + cmd.arg("--dired").arg("-l").arg("d"); + let result = cmd.succeeds(); + // Number of blocks + #[cfg(target_os = "linux")] + result.stdout_contains(" total 4"); + + let output = result.stdout_str().to_string(); + println!("Output:\n{}", output); + + let dired_line = output + .lines() + .find(|&line| line.starts_with("//DIRED//")) + .unwrap(); + let positions: Vec = dired_line + .split_whitespace() + .skip(1) + .map(|s| s.parse().unwrap()) + .collect(); + println!("{:?}", positions); + println!("Parsed byte positions: {:?}", positions); + assert_eq!(positions.len() % 2, 0); // Ensure there's an even number of positions + + let filenames: Vec = positions + .chunks(2) + .map(|chunk| { + let start_pos = chunk[0]; + let end_pos = chunk[1]; + let filename = String::from_utf8(output.as_bytes()[start_pos..=end_pos].to_vec()) + .unwrap() + .trim() + .to_string(); + println!("Extracted filename: {}", filename); + filename + }) + .collect(); + + println!("Extracted filenames: {:?}", filenames); + assert_eq!(filenames, vec!["a1", "a22", "a333", "a4444", "d"]); +} diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 2d949bbb3..75be52587 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -3,7 +3,7 @@ # # UU_MAKE_PROFILE == 'debug' | 'release' ## build profile for *uutils* build; may be supplied by caller, defaults to 'release' -# spell-checker:ignore (paths) abmon deref discrim eacces getlimits getopt ginstall inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW baddecode submodules ; (vars/env) SRCDIR vdir rcexp xpart +# spell-checker:ignore (paths) abmon deref discrim eacces getlimits getopt ginstall inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW baddecode submodules ; (vars/env) SRCDIR vdir rcexp xpart dired set -e @@ -261,6 +261,10 @@ sed -i -e "s/Try 'mv --help' for more information/For more information, try '--h # disable these test cases sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/printf/printf-cov.pl + +# with ls --dired, in case of error, we have a slightly different error position +sed -i -e "s|44 45|47 48|" tests/ls/stat-failed.sh + sed -i -e "s/du: invalid -t argument/du: invalid --threshold argument/" -e "s/du: option requires an argument/error: a value is required for '--threshold ' but none was supplied/" -e "/Try 'du --help' for more information./d" tests/du/threshold.sh # disable two kind of tests: From 89aef112088f14372ba8e6e9226c25bb3034adff Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 20 Sep 2023 10:02:20 +0200 Subject: [PATCH 188/370] build-gnu.sh: fix formatting --- util/build-gnu.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 75be52587..521f2208e 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -261,9 +261,8 @@ sed -i -e "s/Try 'mv --help' for more information/For more information, try '--h # disable these test cases sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/printf/printf-cov.pl - # with ls --dired, in case of error, we have a slightly different error position -sed -i -e "s|44 45|47 48|" tests/ls/stat-failed.sh +sed -i -e "s|44 45|47 48|" tests/ls/stat-failed.sh sed -i -e "s/du: invalid -t argument/du: invalid --threshold argument/" -e "s/du: option requires an argument/error: a value is required for '--threshold ' but none was supplied/" -e "/Try 'du --help' for more information./d" tests/du/threshold.sh From 5eb1fd0b024e23598925ef954f169f401473d5f4 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 20 Sep 2023 10:36:32 +0200 Subject: [PATCH 189/370] ci: remove committing from CheckScripts.yml --- .github/workflows/CheckScripts.yml | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/.github/workflows/CheckScripts.yml b/.github/workflows/CheckScripts.yml index 995b5456f..c18c4733c 100644 --- a/.github/workflows/CheckScripts.yml +++ b/.github/workflows/CheckScripts.yml @@ -41,14 +41,9 @@ jobs: shell_fmt: name: ShellScript/Format - # no need to run in pr events - # shfmt will be performed on main branch when the PR is merged - if: github.event_name != 'pull_request' runs-on: ubuntu-latest - needs: [ shell_check ] permissions: - contents: write - pull-requests: write + contents: read steps: - uses: actions/checkout@v4 - name: Setup shfmt @@ -56,19 +51,6 @@ jobs: - name: Run shfmt shell: bash run: | - # show differs first for every files that need to be formatted # fmt options: bash syntax, 4 spaces indent, indent for switch-case echo "## show the differences between formatted and original scripts..." find ${{ env.SCRIPT_DIR }} -name "*.sh" -print0 | xargs -0 shfmt -ln=bash -i 4 -ci -d || true - # perform a shell format - echo "## perform a shell format..." - # ignore the error code because `-d` will always return false when the file has difference - find ${{ env.SCRIPT_DIR }} -name "*.sh" -print0 | xargs -0 shfmt -ln=bash -i 4 -ci -w - - name: Commit any changes - uses: EndBug/add-and-commit@v9 - with: - default_author: github_actions - message: "style: auto format by CI (shfmt)" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - From 3bb180f4711dbbe56dfd3438e3165742a524630d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 20 Sep 2023 16:33:12 +0000 Subject: [PATCH 190/370] chore(deps): update rust crate winapi-util to 0.1.6 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ece92cdfe..d4340ff96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3429,9 +3429,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] diff --git a/Cargo.toml b/Cargo.toml index 866b1f585..42949b7c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -328,7 +328,7 @@ unicode-segmentation = "1.10.1" unicode-width = "0.1.11" utf-8 = "0.7.6" walkdir = "2.4" -winapi-util = "0.1.5" +winapi-util = "0.1.6" windows-sys = { version = "0.48.0", default-features = false } xattr = "1.0.1" zip = { version = "0.6.6", default_features = false, features = ["deflate"] } From 2ee4006bfdfbdab521cd56f24112a9157295bae5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 20 Sep 2023 23:08:42 +0000 Subject: [PATCH 191/370] chore(deps): update rust crate rayon to 1.8 --- Cargo.lock | 20 ++++---------------- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ece92cdfe..635b6ce11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1413,16 +1413,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "num_threads" version = "0.1.6" @@ -1707,9 +1697,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -1717,14 +1707,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 866b1f585..d8eca9f3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -308,7 +308,7 @@ platform-info = "2.0.2" quick-error = "2.0.1" rand = { version = "0.8", features = ["small_rng"] } rand_core = "0.6" -rayon = "1.7" +rayon = "1.8" redox_syscall = "0.4" regex = "1.9.5" rstest = "0.18.2" From 78e774a937fd83faeef676e1fbfea934c877339c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 21 Sep 2023 04:49:34 +0000 Subject: [PATCH 192/370] chore(deps): update rust crate blake3 to 1.5.0 --- Cargo.lock | 16 ++++------------ Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ece92cdfe..44a85a208 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,9 +88,9 @@ checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "autocfg" @@ -166,16 +166,15 @@ dependencies = [ [[package]] name = "blake3" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" +checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" dependencies = [ "arrayref", "arrayvec", "cc", "cfg-if", "constant_time_eq", - "digest", ] [[package]] @@ -732,7 +731,6 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", - "subtle", ] [[package]] @@ -2075,12 +2073,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - [[package]] name = "syn" version = "1.0.109" diff --git a/Cargo.toml b/Cargo.toml index 866b1f585..b7ca08b94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -339,7 +339,7 @@ sha1 = "0.10.5" sha2 = "0.10.7" sha3 = "0.10.8" blake2b_simd = "1.0.2" -blake3 = "1.4.1" +blake3 = "1.5.0" sm3 = "0.4.2" digest = "0.10.7" From 23ee9b622d19535da485346eaf9ff2d51740ff5f Mon Sep 17 00:00:00 2001 From: pin <90570748+0323pin@users.noreply.github.com> Date: Thu, 21 Sep 2023 12:24:08 +0200 Subject: [PATCH 193/370] Add NetBSD support to uucore. (#5289) * Add NetBSD support to uucore. Fixes https://github.com/uutils/coreutils/issues/5288 --- src/uucore/src/lib/features/fs.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index 3def63ad6..719efc7a6 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -114,6 +114,7 @@ impl FileInformation { not(target_vendor = "apple"), not(target_os = "android"), not(target_os = "freebsd"), + not(target_os = "netbsd"), not(target_arch = "aarch64"), not(target_arch = "riscv64"), target_pointer_width = "64" @@ -125,6 +126,7 @@ impl FileInformation { target_vendor = "apple", target_os = "android", target_os = "freebsd", + target_os = "netbsd", target_arch = "aarch64", target_arch = "riscv64", not(target_pointer_width = "64") @@ -137,9 +139,16 @@ impl FileInformation { #[cfg(unix)] pub fn inode(&self) -> u64 { - #[cfg(all(not(target_os = "freebsd"), target_pointer_width = "64"))] + #[cfg(all( + not(any(target_os = "freebsd", target_os = "netbsd")), + target_pointer_width = "64" + ))] return self.0.st_ino; - #[cfg(any(target_os = "freebsd", not(target_pointer_width = "64")))] + #[cfg(any( + target_os = "freebsd", + target_os = "netbsd", + not(target_pointer_width = "64") + ))] return self.0.st_ino.into(); } } From df211cd45f6a052054f761d56f0efe9bddd5068e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 21 Sep 2023 16:11:20 +0000 Subject: [PATCH 194/370] chore(deps): update rust crate sha1 to 0.10.6 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 665df5120..58a4324a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1943,9 +1943,9 @@ checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", diff --git a/Cargo.toml b/Cargo.toml index fd5d40999..d0c012f47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -335,7 +335,7 @@ zip = { version = "0.6.6", default_features = false, features = ["deflate"] } hex = "0.4.3" md-5 = "0.10.5" -sha1 = "0.10.5" +sha1 = "0.10.6" sha2 = "0.10.7" sha3 = "0.10.8" blake2b_simd = "1.0.2" From 1d10e0c6748a5b98a1efed6d0a39c49aafbc52fb Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 20 Sep 2023 22:00:30 +0200 Subject: [PATCH 195/370] ls: rename the function for something more explicit --- src/uu/ls/src/dired.rs | 2 +- src/uu/ls/src/ls.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/ls/src/dired.rs b/src/uu/ls/src/dired.rs index f66d22b38..ba8f09335 100644 --- a/src/uu/ls/src/dired.rs +++ b/src/uu/ls/src/dired.rs @@ -54,7 +54,7 @@ pub fn indent(out: &mut BufWriter) -> UResult<()> { Ok(()) } -pub fn calculate_offset_and_push(dired: &mut DiredOutput, path_len: usize) { +pub fn calculate_subdired(dired: &mut DiredOutput, path_len: usize) { let offset = if dired.subdired_positions.is_empty() { DIRED_TRAILING_OFFSET } else { diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 3d67cccaa..7f977da2a 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1921,7 +1921,7 @@ pub fn list(locs: Vec<&Path>, config: &Config) -> UResult<()> { } writeln!(out, "{}:", path_data.p_buf.display())?; if config.dired { - dired::calculate_offset_and_push(&mut dired, path_data.display_name.len()); + dired::calculate_subdired(&mut dired, path_data.display_name.len()); } } else { writeln!(out, "\n{}:", path_data.p_buf.display())?; From 8db6146dd3c6b131723bfd0cd3bf3b443a3efdc4 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 20 Sep 2023 22:00:38 +0200 Subject: [PATCH 196/370] ls remove old comment --- src/uu/ls/src/dired.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/uu/ls/src/dired.rs b/src/uu/ls/src/dired.rs index ba8f09335..8e85a2e0f 100644 --- a/src/uu/ls/src/dired.rs +++ b/src/uu/ls/src/dired.rs @@ -95,7 +95,6 @@ pub fn add_total(total_len: usize, dired: &mut DiredOutput) { dired.just_printed_total = true; dired.dired_positions.push(BytePosition { start: 0, - // the 2 is from the trailing spaces // the 1 is from the line ending (\n) end: total_len + DIRED_TRAILING_OFFSET - 1, }); From a12dd2ee1eddb42d23646ef7964b919a4b752d3c Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 20 Sep 2023 22:09:34 +0200 Subject: [PATCH 197/370] ls rename the function for consistency --- src/uu/ls/src/dired.rs | 7 +++---- src/uu/ls/src/ls.rs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/uu/ls/src/dired.rs b/src/uu/ls/src/dired.rs index 8e85a2e0f..288d7fc76 100644 --- a/src/uu/ls/src/dired.rs +++ b/src/uu/ls/src/dired.rs @@ -33,7 +33,7 @@ impl fmt::Display for BytePosition { static DIRED_TRAILING_OFFSET: usize = 2; /// Calculates the byte positions for DIRED -pub fn calculate_dired_byte_positions( +pub fn calculate_dired( output_display_len: usize, dfn_len: usize, dired_positions: &[BytePosition], @@ -143,12 +143,11 @@ mod tests { use super::*; #[test] - fn test_calculate_dired_byte_positions() { + fn test_calculate_dired() { let output_display = "sample_output".to_string(); let dfn = "sample_file".to_string(); let dired_positions = vec![BytePosition { start: 5, end: 10 }]; - let (start, end) = - calculate_dired_byte_positions(output_display.len(), dfn.len(), &dired_positions); + let (start, end) = calculate_dired(output_display.len(), dfn.len(), &dired_positions); assert_eq!(start, 24); assert_eq!(end, 35); diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 7f977da2a..f7a3b79ae 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -2545,7 +2545,7 @@ fn display_item_long( let displayed_file = display_file_name(item, config, None, String::new(), out).contents; if config.dired { - let (start, end) = dired::calculate_dired_byte_positions( + let (start, end) = dired::calculate_dired( output_display.len(), displayed_file.len(), &dired.dired_positions, From 0794d1338df62f303e7077e3397acd1873dc2766 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 22 Sep 2023 10:23:01 +0200 Subject: [PATCH 198/370] ls: fix test which fails if /tmp uses tmpfs --- tests/by-util/test_ls.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 87b306656..23dfafa32 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc neee naaaaa nbcdef nfffff dired subdired +// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc neee naaaaa nbcdef nfffff dired subdired tmpfs #[cfg(any(unix, feature = "feat_selinux"))] use crate::common::util::expected_result; @@ -3608,9 +3608,13 @@ fn test_ls_dired_complex() { let mut cmd = scene.ucmd(); cmd.arg("--dired").arg("-l").arg("d"); let result = cmd.succeeds(); - // Number of blocks + + // Number of blocks. We run this test only if the default size of a newly created directory is + // 4096 bytes to prevent it from failing where this is not the case (e.g. using tmpfs for /tmp). #[cfg(target_os = "linux")] - result.stdout_contains(" total 4"); + if at.metadata("d/d").len() == 4096 { + result.stdout_contains(" total 4"); + } let output = result.stdout_str().to_string(); println!("Output:\n{}", output); From 38831c46d1b896bac7bd45af31644d2733be2c28 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 22 Sep 2023 10:58:12 +0200 Subject: [PATCH 199/370] relpath: show error if no argument provided Fixes #5300 --- src/uu/relpath/src/relpath.rs | 6 +++++- tests/by-util/test_relpath.rs | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/uu/relpath/src/relpath.rs b/src/uu/relpath/src/relpath.rs index 46dd0d663..aa8b5caab 100644 --- a/src/uu/relpath/src/relpath.rs +++ b/src/uu/relpath/src/relpath.rs @@ -82,6 +82,10 @@ pub fn uu_app() -> Command { .arg(Arg::new(options::DIR).short('d').help( "If any of FROM and TO is not subpath of DIR, output absolute path instead of relative", )) - .arg(Arg::new(options::TO).value_hint(clap::ValueHint::AnyPath)) + .arg( + Arg::new(options::TO) + .value_hint(clap::ValueHint::AnyPath) + .required(true), + ) .arg(Arg::new(options::FROM).value_hint(clap::ValueHint::AnyPath)) } diff --git a/tests/by-util/test_relpath.rs b/tests/by-util/test_relpath.rs index 8a3c91802..f506e01c5 100644 --- a/tests/by-util/test_relpath.rs +++ b/tests/by-util/test_relpath.rs @@ -180,3 +180,10 @@ fn test_relpath_no_from_with_d() { assert!(Path::new(&result_stdout).is_absolute()); } } + +#[test] +fn test_relpath_no_to() { + new_ucmd!() + .fails() + .stderr_contains("required arguments were not provided"); +} From cc6a1ae4f415e572733dbfbd9c56dc0d75f05061 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 15:40:11 +0000 Subject: [PATCH 200/370] chore(deps): update rust crate md-5 to 0.10.6 --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 58a4324a6..3723c52da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1275,10 +1275,11 @@ checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" [[package]] name = "md-5" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ + "cfg-if", "digest", ] diff --git a/Cargo.toml b/Cargo.toml index d0c012f47..65b23faa2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -334,7 +334,7 @@ xattr = "1.0.1" zip = { version = "0.6.6", default_features = false, features = ["deflate"] } hex = "0.4.3" -md-5 = "0.10.5" +md-5 = "0.10.6" sha1 = "0.10.6" sha2 = "0.10.7" sha3 = "0.10.8" From 75044c1bc47321d8b360045693dd386515e27fa9 Mon Sep 17 00:00:00 2001 From: KAA the Wise Date: Fri, 22 Sep 2023 18:41:31 +0300 Subject: [PATCH 201/370] rm: make option types public Made `Options` and `InteractiveMode` public and added documentation for them. --- src/uu/rm/src/rm.rs | 50 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index d9421d0ae..96e0fa7aa 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -18,22 +18,52 @@ use uucore::{format_usage, help_about, help_section, help_usage, prompt_yes, sho use walkdir::{DirEntry, WalkDir}; #[derive(Eq, PartialEq, Clone, Copy)] -enum InteractiveMode { +/// Enum, determining when the `rm` will prompt the user about the file deletion +pub enum InteractiveMode { + /// Never prompt Never, + /// Prompt once before removing more than three files, or when removing + /// recursively. Once, + /// Prompt before every removal Always, + /// TODO clarify what this option does PromptProtected, } -struct Options { - force: bool, - interactive: InteractiveMode, +/// Options for the `rm` command +/// +/// All options are public so that the options can be programmatically +/// constructed by other crates, such as Nushell. That means that this struct +/// is part of our public API. It should therefore not be changed without good +/// reason. +/// +/// The fields are documented with the arguments that determine their value. +pub struct Options { + /// `-f`, `--force` + pub force: bool, + /// Iterative mode, determines when the command will prompt. + /// + /// Set by the following arguments: + /// - `-i`: [`InteractiveMode::Always`] + /// - `-I`: [`InteractiveMode::Once`] + /// - `--interactive`: sets one of the above or [`InteractiveMode::Never`] + /// - `-f`: implicitly sets [`InteractiveMode::Never`] + /// + /// If no other option sets this mode, [`InteractiveMode::PromptProtected`] + /// is used + pub interactive: InteractiveMode, #[allow(dead_code)] - one_fs: bool, - preserve_root: bool, - recursive: bool, - dir: bool, - verbose: bool, + /// `--one-file-system` + pub one_fs: bool, + /// `--preserve-root`/`--no-preserve-root` + pub preserve_root: bool, + /// `-r`, `--recursive` + pub recursive: bool, + /// `-d`, `--dir` + pub dir: bool, + /// `-v`, `--verbose` + pub verbose: bool, } const ABOUT: &str = help_about!("rm.md"); @@ -268,7 +298,7 @@ fn remove(files: &[&OsStr], options: &Options) -> bool { // TODO: actually print out the specific error // TODO: When the error is not about missing files // (e.g., permission), even rm -f should fail with - // outputting the error, but there's no easy eay. + // outputting the error, but there's no easy way. if options.force { false } else { From 20fb473da852d9b09a592b258c4c183c3d97dc64 Mon Sep 17 00:00:00 2001 From: KAA the Wise Date: Fri, 22 Sep 2023 19:17:51 +0300 Subject: [PATCH 202/370] rm: make the `remove` function public --- src/uu/rm/src/rm.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 96e0fa7aa..19c749cf0 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -279,7 +279,13 @@ pub fn uu_app() -> Command { } // TODO: implement one-file-system (this may get partially implemented in walkdir) -fn remove(files: &[&OsStr], options: &Options) -> bool { +/// Remove (or unlink) the given files +/// +/// Returns true if it has encountered an error. +/// +/// Behavior is determined by the `options` parameter, see [`Options`] for +/// details. +pub fn remove(files: &[&OsStr], options: &Options) -> bool { let mut had_err = false; for filename in files { From 30f1fceddcd77c79ec505b4dfad9b28e4d786d18 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 23 Sep 2023 09:29:00 +0200 Subject: [PATCH 203/370] add nushell to the list of ignored names --- .vscode/cspell.dictionaries/acronyms+names.wordlist.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt b/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt index 8711913d9..c004ea2f8 100644 --- a/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt +++ b/.vscode/cspell.dictionaries/acronyms+names.wordlist.txt @@ -58,6 +58,7 @@ MinGW Minix NetBSD Novell +Nushell OpenBSD POSIX PowerPC From 48613b47176c30c414f979edd5350d7c1aa56ba6 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 22 Sep 2023 22:12:44 +0200 Subject: [PATCH 204/370] ls --dired: replace the previous "total: xx" padding method by something easier --- src/uu/ls/src/dired.rs | 47 ++++++++++++++++-------------------------- src/uu/ls/src/ls.rs | 2 +- util/build-gnu.sh | 6 +++--- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/uu/ls/src/dired.rs b/src/uu/ls/src/dired.rs index 288d7fc76..8574e750e 100644 --- a/src/uu/ls/src/dired.rs +++ b/src/uu/ls/src/dired.rs @@ -20,7 +20,7 @@ pub struct BytePosition { pub struct DiredOutput { pub dired_positions: Vec, pub subdired_positions: Vec, - pub just_printed_total: bool, + pub padding: usize, } impl fmt::Display for BytePosition { @@ -75,7 +75,7 @@ pub fn print_dired_output( out.flush()?; if config.recursive { print_positions("//SUBDIRED//", &dired.subdired_positions); - } else if !dired.just_printed_total { + } else if dired.padding == 0 { print_positions("//DIRED//", &dired.dired_positions); } println!("//DIRED-OPTIONS// --quoting-style={}", config.quoting_style); @@ -92,12 +92,9 @@ fn print_positions(prefix: &str, positions: &Vec) { } pub fn add_total(total_len: usize, dired: &mut DiredOutput) { - dired.just_printed_total = true; - dired.dired_positions.push(BytePosition { - start: 0, - // the 1 is from the line ending (\n) - end: total_len + DIRED_TRAILING_OFFSET - 1, - }); + // when dealing with " total: xx", it isn't part of the //DIRED// + // so, we just keep the size line to add it to the position of the next file + dired.padding = total_len + DIRED_TRAILING_OFFSET; } /// Calculates byte positions and updates the dired structure. @@ -114,28 +111,20 @@ pub fn calculate_and_update_positions( }); let start = output_display_len + offset + DIRED_TRAILING_OFFSET; let end = start + dfn_len; - update_positions(start, end, dired, true); + update_positions(start, end, dired); } /// Updates the dired positions based on the given start and end positions. -/// update when it is the first element in the list (to manage "total X" +/// update when it is the first element in the list (to manage "total X") /// insert when it isn't the about total -pub fn update_positions(start: usize, end: usize, dired: &mut DiredOutput, adjust: bool) { - if dired.just_printed_total { - if let Some(last_position) = dired.dired_positions.last_mut() { - *last_position = BytePosition { - start: if adjust { - start + last_position.end - } else { - start - }, - end: if adjust { end + last_position.end } else { end }, - }; - dired.just_printed_total = false; - } - } else { - dired.dired_positions.push(BytePosition { start, end }); - } +pub fn update_positions(start: usize, end: usize, dired: &mut DiredOutput) { + // padding can be 0 but as it doesn't matter< + dired.dired_positions.push(BytePosition { + start: start + dired.padding, + end: end + dired.padding, + }); + // Remove the previous padding + dired.padding = 0; } #[cfg(test)] @@ -158,17 +147,17 @@ mod tests { let mut dired = DiredOutput { dired_positions: vec![BytePosition { start: 5, end: 10 }], subdired_positions: vec![], - just_printed_total: true, + padding: 10, }; // Test with adjust = true - update_positions(15, 20, &mut dired, true); + update_positions(15, 20, &mut dired); let last_position = dired.dired_positions.last().unwrap(); assert_eq!(last_position.start, 25); // 15 + 10 (end of the previous position) assert_eq!(last_position.end, 30); // 20 + 10 (end of the previous position) // Test with adjust = false - update_positions(30, 35, &mut dired, false); + update_positions(30, 35, &mut dired); let last_position = dired.dired_positions.last().unwrap(); assert_eq!(last_position.start, 30); assert_eq!(last_position.end, 35); diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index f7a3b79ae..301aefaf3 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -2550,7 +2550,7 @@ fn display_item_long( displayed_file.len(), &dired.dired_positions, ); - dired::update_positions(start, end, dired, false); + dired::update_positions(start, end, dired); } write!(output_display, "{}{}", displayed_file, config.line_ending).unwrap(); } else { diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 521f2208e..e2c675394 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -261,11 +261,11 @@ sed -i -e "s/Try 'mv --help' for more information/For more information, try '--h # disable these test cases sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/printf/printf-cov.pl -# with ls --dired, in case of error, we have a slightly different error position -sed -i -e "s|44 45|47 48|" tests/ls/stat-failed.sh - sed -i -e "s/du: invalid -t argument/du: invalid --threshold argument/" -e "s/du: option requires an argument/error: a value is required for '--threshold ' but none was supplied/" -e "/Try 'du --help' for more information./d" tests/du/threshold.sh +# with ls --dired, in case of error, we have a slightly different error position +sed -i -e "s|44 45|48 49|" tests/ls/stat-failed.sh + # disable two kind of tests: # "hostid BEFORE --help" doesn't fail for GNU. we fail. we are probably doing better # "hostid BEFORE --help AFTER " same for this From 06219350fa4d9277b8a1adea1050c180db39ff32 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 23 Sep 2023 14:44:30 +0200 Subject: [PATCH 205/370] nl: fix output order if stdin and files are mixed --- src/uu/nl/src/nl.rs | 20 +++++++------------- tests/by-util/test_nl.rs | 13 +++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index fef9c030a..6e1cb6835 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -168,7 +168,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { )); } - let mut read_stdin = false; let files: Vec = match matches.get_many::(options::FILE) { Some(v) => v.clone().map(|v| v.to_owned()).collect(), None => vec!["-".to_owned()], @@ -178,21 +177,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { for file in &files { if file == "-" { - // If both file names and '-' are specified, we choose to treat first all - // regular files, and then read from stdin last. - read_stdin = true; - continue; + let mut buffer = BufReader::new(stdin()); + nl(&mut buffer, &mut stats, &settings)?; + } else { + let path = Path::new(file); + let reader = File::open(path).map_err_context(|| file.to_string())?; + let mut buffer = BufReader::new(reader); + nl(&mut buffer, &mut stats, &settings)?; } - let path = Path::new(file); - let reader = File::open(path).map_err_context(|| file.to_string())?; - let mut buffer = BufReader::new(reader); - nl(&mut buffer, &mut stats, &settings)?; } - if read_stdin { - let mut buffer = BufReader::new(stdin()); - nl(&mut buffer, &mut stats, &settings)?; - } Ok(()) } diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index b008c61de..118c4cf04 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -349,6 +349,19 @@ fn test_default_body_numbering_multiple_files() { .stdout_is(" 1\ta\n 2\tb\n 3\tc\n"); } +#[test] +fn test_default_body_numbering_multiple_files_and_stdin() { + let (at, mut ucmd) = at_and_ucmd!(); + + at.write("a.txt", "a"); + at.write("c.txt", "c"); + + ucmd.args(&["a.txt", "-", "c.txt"]) + .pipe_in("b") + .succeeds() + .stdout_is(" 1\ta\n 2\tb\n 3\tc\n"); +} + #[test] fn test_body_numbering_all_lines_without_delimiter() { for arg in ["-ba", "--body-numbering=a"] { From 4b76b2f33220b268f3ac148fa3ac0a110947b5a1 Mon Sep 17 00:00:00 2001 From: KAA the Wise Date: Sat, 23 Sep 2023 15:55:57 +0300 Subject: [PATCH 206/370] rm: document PromptProtected interactive mode option --- src/uu/rm/src/rm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 19c749cf0..87767b904 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -27,7 +27,7 @@ pub enum InteractiveMode { Once, /// Prompt before every removal Always, - /// TODO clarify what this option does + /// Prompt only on write-protected files PromptProtected, } From 306a58a73147cd35491a3bd9facb6e0ee057752e Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 29 Nov 2022 10:20:04 +0100 Subject: [PATCH 207/370] tail: remove unused var "_event_counter" --- src/uu/tail/src/follow/watch.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/uu/tail/src/follow/watch.rs b/src/uu/tail/src/follow/watch.rs index 3ecb47f67..cd1dd49c3 100644 --- a/src/uu/tail/src/follow/watch.rs +++ b/src/uu/tail/src/follow/watch.rs @@ -479,7 +479,6 @@ pub fn follow(mut observer: Observer, settings: &Settings) -> UResult<()> { let mut process = platform::ProcessChecker::new(observer.pid); - let mut _event_counter = 0; let mut _timeout_counter = 0; // main follow loop @@ -529,7 +528,6 @@ pub fn follow(mut observer: Observer, settings: &Settings) -> UResult<()> { .receiver .recv_timeout(settings.sleep_sec); if rx_result.is_ok() { - _event_counter += 1; _timeout_counter = 0; } From a4a69c8ee7e1b93d87500504800d91186d3972d6 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 29 Nov 2022 10:25:48 +0100 Subject: [PATCH 208/370] tail: "_timeout_counter" -> "timeout_counter" --- src/uu/tail/src/follow/watch.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/uu/tail/src/follow/watch.rs b/src/uu/tail/src/follow/watch.rs index cd1dd49c3..fbda27aa0 100644 --- a/src/uu/tail/src/follow/watch.rs +++ b/src/uu/tail/src/follow/watch.rs @@ -479,7 +479,7 @@ pub fn follow(mut observer: Observer, settings: &Settings) -> UResult<()> { let mut process = platform::ProcessChecker::new(observer.pid); - let mut _timeout_counter = 0; + let mut timeout_counter = 0; // main follow loop loop { @@ -528,7 +528,7 @@ pub fn follow(mut observer: Observer, settings: &Settings) -> UResult<()> { .receiver .recv_timeout(settings.sleep_sec); if rx_result.is_ok() { - _timeout_counter = 0; + timeout_counter = 0; } let mut paths = vec![]; // Paths worth checking for new content to print @@ -567,7 +567,7 @@ pub fn follow(mut observer: Observer, settings: &Settings) -> UResult<()> { } Ok(Err(e)) => return Err(USimpleError::new(1, format!("NotifyError: {e}"))), Err(mpsc::RecvTimeoutError::Timeout) => { - _timeout_counter += 1; + timeout_counter += 1; } Err(e) => return Err(USimpleError::new(1, format!("RecvTimeoutError: {e}"))), } @@ -584,7 +584,7 @@ pub fn follow(mut observer: Observer, settings: &Settings) -> UResult<()> { _read_some = observer.files.tail_file(path, settings.verbose)?; } - if _timeout_counter == settings.max_unchanged_stats { + if timeout_counter == settings.max_unchanged_stats { /* TODO: [2021-10; jhscheer] implement timeout_counter for each file. ‘--max-unchanged-stats=n’ From 616c3f4a7fb199a525bcf148ed799516e13cf739 Mon Sep 17 00:00:00 2001 From: Benjamin Bara Date: Sat, 22 Jul 2023 11:25:39 +0200 Subject: [PATCH 209/370] util: extend run_ucmd_as_root for stdin/stdout This enables to give path to files (as str) which are then used as either stdin or stdout. --- tests/common/util.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/common/util.rs b/tests/common/util.rs index 0fbc58cd5..6f4e76d42 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -2532,6 +2532,16 @@ pub fn expected_result(ts: &TestScenario, args: &[&str]) -> std::result::Result< pub fn run_ucmd_as_root( ts: &TestScenario, args: &[&str], +) -> std::result::Result { + run_ucmd_as_root_with_stdin_stdout(ts, args, None, None) +} + +#[cfg(unix)] +pub fn run_ucmd_as_root_with_stdin_stdout( + ts: &TestScenario, + args: &[&str], + stdin: Option<&str>, + stdout: Option<&str>, ) -> std::result::Result { if is_ci() { Err(format!("{UUTILS_INFO}: {}", "cannot run inside CI")) @@ -2546,16 +2556,21 @@ pub fn run_ucmd_as_root( Ok(output) if String::from_utf8_lossy(&output.stdout).eq("root\n") => { // we can run sudo and we're root // run ucmd as root: - Ok(ts - .cmd("sudo") - .env("PATH", PATH) + let mut cmd = ts.cmd("sudo"); + cmd.env("PATH", PATH) .envs(DEFAULT_ENV) .arg("-E") .arg("--non-interactive") .arg(&ts.bin_path) .arg(&ts.util_name) - .args(args) - .run()) + .args(args); + if let Some(stdin) = stdin { + cmd.set_stdin(File::open(stdin).unwrap()); + } + if let Some(stdout) = stdout { + cmd.set_stdout(File::open(stdout).unwrap()); + } + Ok(cmd.run()) } Ok(output) if String::from_utf8_lossy(&output.stderr).eq("sudo: a password is required\n") => From 8a9b29ddfb5b0486c6461b6d85cebb64c63586a5 Mon Sep 17 00:00:00 2001 From: Benjamin Bara Date: Sat, 18 Mar 2023 08:54:47 +0100 Subject: [PATCH 210/370] dd: fix GNU test 'dd/skip-seek-past-dev' --- src/uu/dd/src/dd.rs | 57 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/src/uu/dd/src/dd.rs b/src/uu/dd/src/dd.rs index 4ac2aa780..b79ae22da 100644 --- a/src/uu/dd/src/dd.rs +++ b/src/uu/dd/src/dd.rs @@ -3,7 +3,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, iseek, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, oseek, outfile, parseargs, rlen, rmax, rremain, rsofar, rstat, sigusr, wlen, wstat seekable oconv canonicalized fadvise Fadvise FADV DONTNEED ESPIPE +// spell-checker:ignore fname, ftype, 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 oconv canonicalized fadvise Fadvise FADV DONTNEED ESPIPE mod datastructures; use datastructures::*; @@ -49,6 +49,8 @@ use nix::{ fcntl::{posix_fadvise, PosixFadviseAdvice}, }; use uucore::display::Quotable; +#[cfg(unix)] +use uucore::error::set_exit_code; use uucore::error::{FromIo, UResult}; use uucore::{format_usage, help_about, help_section, help_usage, show_error}; #[cfg(target_os = "linux")] @@ -200,14 +202,25 @@ impl Source { Err(e) => Err(e), }, #[cfg(unix)] - Self::StdinFile(f) => match io::copy(&mut f.take(n), &mut io::sink()) { - Ok(m) if m < n => { - show_error!("'standard input': cannot skip to specified offset"); - Ok(m) + Self::StdinFile(f) => { + if let Ok(Some(len)) = try_get_len_of_block_device(f) { + if len < n { + // GNU compatibility: + // this case prints the stats but sets the exit code to 1 + show_error!("'standard input': cannot skip: Invalid argument"); + set_exit_code(1); + return Ok(len); + } } - Ok(m) => Ok(m), - Err(e) => Err(e), - }, + match io::copy(&mut f.take(n), &mut io::sink()) { + Ok(m) if m < n => { + show_error!("'standard input': cannot skip to specified offset"); + Ok(m) + } + Ok(m) => Ok(m), + Err(e) => Err(e), + } + } Self::File(f) => f.seek(io::SeekFrom::Start(n)), #[cfg(unix)] Self::Fifo(f) => io::copy(&mut f.take(n), &mut io::sink()), @@ -527,7 +540,19 @@ impl Dest { fn seek(&mut self, n: u64) -> io::Result { match self { Self::Stdout(stdout) => io::copy(&mut io::repeat(0).take(n), stdout), - Self::File(f, _) => f.seek(io::SeekFrom::Start(n)), + Self::File(f, _) => { + #[cfg(unix)] + if let Ok(Some(len)) = try_get_len_of_block_device(f) { + if len < n { + // GNU compatibility: + // this case prints the stats but sets the exit code to 1 + show_error!("'standard output': cannot seek: Invalid argument"); + set_exit_code(1); + return Ok(len); + } + } + f.seek(io::SeekFrom::Start(n)) + } #[cfg(unix)] Self::Fifo(f) => { // Seeking in a named pipe means *reading* from the pipe. @@ -1133,6 +1158,20 @@ fn is_stdout_redirected_to_seekable_file() -> bool { } } +/// Try to get the len if it is a block device +#[cfg(unix)] +fn try_get_len_of_block_device(file: &mut File) -> io::Result> { + let ftype = file.metadata()?.file_type(); + if !ftype.is_block_device() { + return Ok(None); + } + + // FIXME: this can be replaced by file.stream_len() when stable. + let len = file.seek(SeekFrom::End(0))?; + file.rewind()?; + Ok(Some(len)) +} + /// Decide whether the named file is a named pipe, also known as a FIFO. #[cfg(unix)] fn is_fifo(filename: &str) -> bool { From 17f4d17021148b038e2f2c7942eea6004e06a06c Mon Sep 17 00:00:00 2001 From: Benjamin Bara Date: Sat, 22 Jul 2023 11:26:56 +0200 Subject: [PATCH 211/370] tests: dd: add skip-seek-past-dev tests These tests try to read or write past a block device, where the block device is either given as stdin or stdout. It requires access to the block device, and therefore is executed as root. For now, it is assumed that a block device "/dev/sda1" with a size smaller than 10000000000000000 exists. --- tests/by-util/test_dd.rs | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/by-util/test_dd.rs b/tests/by-util/test_dd.rs index fe38acca4..8ebf57c1c 100644 --- a/tests/by-util/test_dd.rs +++ b/tests/by-util/test_dd.rs @@ -4,6 +4,8 @@ // 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, 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 +#[cfg(unix)] +use crate::common::util::run_ucmd_as_root_with_stdin_stdout; use crate::common::util::TestScenario; #[cfg(all(not(windows), feature = "printf"))] use crate::common::util::{UCommand, TESTS_BINARY}; @@ -1566,3 +1568,45 @@ fn test_nocache_file() { .succeeds() .stderr_only("2048+0 records in\n2048+0 records out\n"); } + +#[test] +#[cfg(unix)] +fn test_skip_past_dev() { + // NOTE: This test intends to trigger code which can only be reached with root permissions. + let ts = TestScenario::new(util_name!()); + + if let Ok(result) = run_ucmd_as_root_with_stdin_stdout( + &ts, + &["bs=1", "skip=10000000000000000", "count=0", "status=noxfer"], + Some("/dev/sda1"), + None, + ) { + result.stderr_contains("dd: 'standard input': cannot skip: Invalid argument"); + result.stderr_contains("0+0 records in"); + result.stderr_contains("0+0 records out"); + result.code_is(1); + } else { + print!("TEST SKIPPED"); + } +} + +#[test] +#[cfg(unix)] +fn test_seek_past_dev() { + // NOTE: This test intends to trigger code which can only be reached with root permissions. + let ts = TestScenario::new(util_name!()); + + if let Ok(result) = run_ucmd_as_root_with_stdin_stdout( + &ts, + &["bs=1", "seek=10000000000000000", "count=0", "status=noxfer"], + None, + Some("/dev/sda1"), + ) { + result.stderr_contains("dd: 'standard output': cannot seek: Invalid argument"); + result.stderr_contains("0+0 records in"); + result.stderr_contains("0+0 records out"); + result.code_is(1); + } else { + print!("TEST SKIPPED"); + } +} From bd0fb817a7ae32f0dc6fafe6aa2ade7e81d3d05b Mon Sep 17 00:00:00 2001 From: tommady Date: Sun, 24 Sep 2023 16:53:27 +0800 Subject: [PATCH 212/370] cp: fix the result of inodes are not the same when preserve links is flagged (#5064) Should fix: ``` rm -rf a b c touch a ln -s a b mkdir c ./target/debug/coreutils cp --preserve=links -R -H a b c a_inode=$(ls -i c/a|sed 's,c/.*,,') b_inode=$(ls -i c/b|sed 's,c/.*,,') echo "$a_inode" = "$b_inode" ``` --- src/uu/cp/src/copydir.rs | 57 ++++++----- src/uu/cp/src/cp.rs | 158 ++++++++++++++----------------- tests/by-util/test_cp.rs | 199 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 296 insertions(+), 118 deletions(-) diff --git a/src/uu/cp/src/copydir.rs b/src/uu/cp/src/copydir.rs index 430548d0c..ac44ce687 100644 --- a/src/uu/cp/src/copydir.rs +++ b/src/uu/cp/src/copydir.rs @@ -8,7 +8,7 @@ //! See the [`copy_directory`] function for more information. #[cfg(windows)] use std::borrow::Cow; -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; use std::env; use std::fs; use std::io; @@ -24,8 +24,8 @@ use uucore::uio_error; use walkdir::{DirEntry, WalkDir}; use crate::{ - aligned_ancestors, context_for, copy_attributes, copy_file, copy_link, preserve_hardlinks, - CopyResult, Error, Options, + aligned_ancestors, context_for, copy_attributes, copy_file, copy_link, CopyResult, Error, + Options, }; /// Ensure a Windows path starts with a `\\?`. @@ -200,7 +200,7 @@ fn copy_direntry( options: &Options, symlinked_files: &mut HashSet, preserve_hard_links: bool, - hard_links: &mut Vec<(String, u64)>, + copied_files: &mut HashMap, ) -> CopyResult<()> { let Entry { source_absolute, @@ -240,30 +240,27 @@ fn copy_direntry( // If the source is not a directory, then we need to copy the file. if !source_absolute.is_dir() { if preserve_hard_links { - let dest = local_to_target.as_path().to_path_buf(); - let found_hard_link = preserve_hardlinks(hard_links, &source_absolute, &dest)?; - if !found_hard_link { - match copy_file( - progress_bar, - &source_absolute, - local_to_target.as_path(), - options, - symlinked_files, - false, - ) { - Ok(_) => Ok(()), - Err(err) => { - if source_absolute.is_symlink() { - // silent the error with a symlink - // In case we do --archive, we might copy the symlink - // before the file itself - Ok(()) - } else { - Err(err) - } + match copy_file( + progress_bar, + &source_absolute, + local_to_target.as_path(), + options, + symlinked_files, + copied_files, + false, + ) { + Ok(_) => Ok(()), + Err(err) => { + if source_absolute.is_symlink() { + // silent the error with a symlink + // In case we do --archive, we might copy the symlink + // before the file itself + Ok(()) + } else { + Err(err) } - }?; - } + } + }?; } else { // At this point, `path` is just a plain old file. // Terminate this function immediately if there is any @@ -277,6 +274,7 @@ fn copy_direntry( local_to_target.as_path(), options, symlinked_files, + copied_files, false, ) { Ok(_) => {} @@ -310,6 +308,7 @@ pub(crate) fn copy_directory( target: &Path, options: &Options, symlinked_files: &mut HashSet, + copied_files: &mut HashMap, source_in_command_line: bool, ) -> CopyResult<()> { if !options.recursive { @@ -324,6 +323,7 @@ pub(crate) fn copy_directory( target, options, symlinked_files, + copied_files, source_in_command_line, ); } @@ -372,7 +372,6 @@ pub(crate) fn copy_directory( }; let target = tmp.as_path(); - let mut hard_links: Vec<(String, u64)> = vec![]; let preserve_hard_links = options.preserve_hard_links(); // Collect some paths here that are invariant during the traversal @@ -397,7 +396,7 @@ pub(crate) fn copy_directory( options, symlinked_files, preserve_hard_links, - &mut hard_links, + copied_files, )?; } // Print an error message, but continue traversing the directory. diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 516f20fda..05261c22f 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -9,7 +9,7 @@ use quick_error::quick_error; use std::borrow::Cow; use std::cmp::Ordering; -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; use std::env; #[cfg(not(windows))] use std::ffi::CString; @@ -1106,67 +1106,6 @@ fn parse_path_args( Ok((paths, target)) } -/// Get the inode information for a file. -fn get_inode(file_info: &FileInformation) -> u64 { - #[cfg(unix)] - let result = file_info.inode(); - #[cfg(windows)] - let result = file_info.file_index(); - result -} - -#[cfg(target_os = "redox")] -fn preserve_hardlinks( - hard_links: &mut Vec<(String, u64)>, - source: &std::path::Path, - dest: &std::path::Path, - found_hard_link: &mut bool, -) -> CopyResult<()> { - // Redox does not currently support hard links - Ok(()) -} - -/// Hard link a pair of files if needed _and_ record if this pair is a new hard link. -#[cfg(not(target_os = "redox"))] -fn preserve_hardlinks( - hard_links: &mut Vec<(String, u64)>, - source: &std::path::Path, - dest: &std::path::Path, -) -> CopyResult { - let info = FileInformation::from_path(source, false) - .context(format!("cannot stat {}", source.quote()))?; - let inode = get_inode(&info); - let nlinks = info.number_of_links(); - let mut found_hard_link = false; - #[allow(clippy::explicit_iter_loop)] - for (link, link_inode) in hard_links.iter() { - if *link_inode == inode { - // Consider the following files: - // - // * `src/f` - a regular file - // * `src/link` - a hard link to `src/f` - // * `dest/src/f` - a different regular file - // - // In this scenario, if we do `cp -a src/ dest/`, it is - // possible that the order of traversal causes `src/link` - // to get copied first (to `dest/src/link`). In that case, - // in order to make sure `dest/src/link` is a hard link to - // `dest/src/f` and `dest/src/f` has the contents of - // `src/f`, we delete the existing file to allow the hard - // linking. - if file_or_link_exists(dest) && file_or_link_exists(Path::new(link)) { - std::fs::remove_file(dest)?; - } - std::fs::hard_link(link, dest).unwrap(); - found_hard_link = true; - } - } - if !found_hard_link && nlinks > 1 { - hard_links.push((dest.to_str().unwrap().to_string(), inode)); - } - Ok(found_hard_link) -} - /// When handling errors, we don't always want to show them to the user. This function handles that. fn show_error_if_needed(error: &Error) { match error { @@ -1195,14 +1134,19 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult let target_type = TargetType::determine(sources, target); verify_target_type(target, &target_type)?; - let preserve_hard_links = options.preserve_hard_links(); - - let mut hard_links: Vec<(String, u64)> = vec![]; - let mut non_fatal_errors = false; let mut seen_sources = HashSet::with_capacity(sources.len()); let mut symlinked_files = HashSet::new(); + // to remember the copied files for further usage. + // the FileInformation implemented the Hash trait by using + // 1. inode number + // 2. device number + // the combination of a file's inode number and device number is unique throughout all the file systems. + // + // key is the source file's information and the value is the destination filepath. + let mut copied_files: HashMap = HashMap::with_capacity(sources.len()); + let progress_bar = if options.progress_bar { let pb = ProgressBar::new(disk_usage(sources, options.recursive)?) .with_style( @@ -1222,28 +1166,19 @@ pub fn copy(sources: &[PathBuf], target: &Path, options: &Options) -> CopyResult if seen_sources.contains(source) { // FIXME: compare sources by the actual file they point to, not their path. (e.g. dir/file == dir/../dir/file in most cases) show_warning!("source {} specified more than once", source.quote()); - } else { - let found_hard_link = if preserve_hard_links && !source.is_dir() { - let dest = construct_dest_path(source, target, &target_type, options)?; - preserve_hardlinks(&mut hard_links, source, &dest)? - } else { - false - }; - if !found_hard_link { - if let Err(error) = copy_source( - &progress_bar, - source, - target, - &target_type, - options, - &mut symlinked_files, - ) { - show_error_if_needed(&error); - non_fatal_errors = true; - } - } - seen_sources.insert(source); + } else if let Err(error) = copy_source( + &progress_bar, + source, + target, + &target_type, + options, + &mut symlinked_files, + &mut copied_files, + ) { + show_error_if_needed(&error); + non_fatal_errors = true; } + seen_sources.insert(source); } if let Some(pb) = progress_bar { @@ -1295,11 +1230,20 @@ fn copy_source( target_type: &TargetType, options: &Options, symlinked_files: &mut HashSet, + copied_files: &mut HashMap, ) -> CopyResult<()> { let source_path = Path::new(&source); if source_path.is_dir() { // Copy as directory - copy_directory(progress_bar, source, target, options, symlinked_files, true) + copy_directory( + progress_bar, + source, + target, + options, + symlinked_files, + copied_files, + true, + ) } else { // Copy as file let dest = construct_dest_path(source_path, target, target_type, options)?; @@ -1309,6 +1253,7 @@ fn copy_source( dest.as_path(), options, symlinked_files, + copied_files, true, ); if options.parents { @@ -1570,6 +1515,24 @@ fn handle_existing_dest( OverwriteMode::Clobber(ClobberMode::RemoveDestination) => { fs::remove_file(dest)?; } + OverwriteMode::Clobber(ClobberMode::Standard) => { + // Consider the following files: + // + // * `src/f` - a regular file + // * `src/link` - a hard link to `src/f` + // * `dest/src/f` - a different regular file + // + // In this scenario, if we do `cp -a src/ dest/`, it is + // possible that the order of traversal causes `src/link` + // to get copied first (to `dest/src/link`). In that case, + // in order to make sure `dest/src/link` is a hard link to + // `dest/src/f` and `dest/src/f` has the contents of + // `src/f`, we delete the existing file to allow the hard + // linking. + if options.preserve_hard_links() { + fs::remove_file(dest)?; + } + } _ => (), }; @@ -1643,6 +1606,7 @@ fn copy_file( dest: &Path, options: &Options, symlinked_files: &mut HashSet, + copied_files: &mut HashMap, source_in_command_line: bool, ) -> CopyResult<()> { if (options.update == UpdateMode::ReplaceIfOlder || options.update == UpdateMode::ReplaceNone) @@ -1686,6 +1650,19 @@ fn copy_file( handle_existing_dest(source, dest, options, source_in_command_line)?; } + if options.preserve_hard_links() { + // if we encounter a matching device/inode pair in the source tree + // we can arrange to create a hard link between the corresponding names + // in the destination tree. + if let Some(new_source) = copied_files.get( + &FileInformation::from_path(source, options.dereference(source_in_command_line)) + .context(format!("cannot stat {}", source.quote()))?, + ) { + std::fs::hard_link(new_source, dest)?; + return Ok(()); + }; + } + if options.verbose { if let Some(pb) = progress_bar { // Suspend (hide) the progress bar so the println won't overlap with the progress bar. @@ -1873,6 +1850,11 @@ fn copy_file( copy_attributes(source, dest, &options.attributes)?; + copied_files.insert( + FileInformation::from_path(source, options.dereference(source_in_command_line))?, + dest.to_path_buf(), + ); + if let Some(progress_bar) = progress_bar { progress_bar.inc(fs::metadata(source)?.len()); } diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index c77be3d4e..afac4cd3a 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -11,7 +11,7 @@ use std::fs::set_permissions; #[cfg(not(windows))] use std::os::unix::fs; -#[cfg(all(unix, not(target_os = "freebsd")))] +#[cfg(unix)] use std::os::unix::fs::MetadataExt; #[cfg(all(unix, not(target_os = "freebsd")))] use std::os::unix::fs::PermissionsExt; @@ -1353,6 +1353,203 @@ fn test_cp_preserve_xattr_fails_on_android() { .fails(); } +#[test] +// android platform will causing stderr = cp: Permission denied (os error 13) +#[cfg(not(target_os = "android"))] +fn test_cp_preserve_links_case_1() { + let (at, mut ucmd) = at_and_ucmd!(); + + at.touch("a"); + at.hard_link("a", "b"); + at.mkdir("c"); + + ucmd.arg("-d").arg("a").arg("b").arg("c").succeeds(); + + assert!(at.dir_exists("c")); + assert!(at.plus("c").join("a").exists()); + assert!(at.plus("c").join("b").exists()); + + #[cfg(unix)] + { + let metadata_a = std::fs::metadata(at.subdir.join("c").join("a")).unwrap(); + let metadata_b = std::fs::metadata(at.subdir.join("c").join("b")).unwrap(); + + assert_eq!(metadata_a.ino(), metadata_b.ino()); + } +} + +#[test] +// android platform will causing stderr = cp: Permission denied (os error 13) +#[cfg(not(target_os = "android"))] +fn test_cp_preserve_links_case_2() { + let (at, mut ucmd) = at_and_ucmd!(); + + at.touch("a"); + at.symlink_file("a", "b"); + at.mkdir("c"); + + ucmd.arg("--preserve=links") + .arg("-R") + .arg("-H") + .arg("a") + .arg("b") + .arg("c") + .succeeds(); + + assert!(at.dir_exists("c")); + assert!(at.plus("c").join("a").exists()); + assert!(at.plus("c").join("b").exists()); + + #[cfg(unix)] + { + let metadata_a = std::fs::metadata(at.subdir.join("c").join("a")).unwrap(); + let metadata_b = std::fs::metadata(at.subdir.join("c").join("b")).unwrap(); + + assert_eq!(metadata_a.ino(), metadata_b.ino()); + } +} + +#[test] +// android platform will causing stderr = cp: Permission denied (os error 13) +#[cfg(not(target_os = "android"))] +fn test_cp_preserve_links_case_3() { + let (at, mut ucmd) = at_and_ucmd!(); + + at.mkdir("d"); + at.touch("d/a"); + at.symlink_file("d/a", "d/b"); + + ucmd.arg("--preserve=links") + .arg("-R") + .arg("-L") + .arg("d") + .arg("c") + .succeeds(); + + assert!(at.dir_exists("c")); + assert!(at.plus("c").join("a").exists()); + assert!(at.plus("c").join("b").exists()); + + #[cfg(unix)] + { + let metadata_a = std::fs::metadata(at.subdir.join("c").join("a")).unwrap(); + let metadata_b = std::fs::metadata(at.subdir.join("c").join("b")).unwrap(); + + assert_eq!(metadata_a.ino(), metadata_b.ino()); + } +} + +#[test] +// android platform will causing stderr = cp: Permission denied (os error 13) +#[cfg(not(target_os = "android"))] +fn test_cp_preserve_links_case_4() { + let (at, mut ucmd) = at_and_ucmd!(); + + at.mkdir("d"); + at.touch("d/a"); + at.hard_link("d/a", "d/b"); + + ucmd.arg("--preserve=links") + .arg("-R") + .arg("-L") + .arg("d") + .arg("c") + .succeeds(); + + assert!(at.dir_exists("c")); + assert!(at.plus("c").join("a").exists()); + assert!(at.plus("c").join("b").exists()); + + #[cfg(unix)] + { + let metadata_a = std::fs::metadata(at.subdir.join("c").join("a")).unwrap(); + let metadata_b = std::fs::metadata(at.subdir.join("c").join("b")).unwrap(); + + assert_eq!(metadata_a.ino(), metadata_b.ino()); + } +} + +#[test] +// android platform will causing stderr = cp: Permission denied (os error 13) +#[cfg(not(target_os = "android"))] +fn test_cp_preserve_links_case_5() { + let (at, mut ucmd) = at_and_ucmd!(); + + at.mkdir("d"); + at.touch("d/a"); + at.hard_link("d/a", "d/b"); + + ucmd.arg("-dR") + .arg("--no-preserve=links") + .arg("d") + .arg("c") + .succeeds(); + + assert!(at.dir_exists("c")); + assert!(at.plus("c").join("a").exists()); + assert!(at.plus("c").join("b").exists()); + + #[cfg(unix)] + { + let metadata_a = std::fs::metadata(at.subdir.join("c").join("a")).unwrap(); + let metadata_b = std::fs::metadata(at.subdir.join("c").join("b")).unwrap(); + + assert_eq!(metadata_a.ino(), metadata_b.ino()); + } +} + +#[test] +// android platform will causing stderr = cp: Permission denied (os error 13) +#[cfg(not(target_os = "android"))] +fn test_cp_preserve_links_case_6() { + let (at, mut ucmd) = at_and_ucmd!(); + + at.touch("a"); + at.hard_link("a", "b"); + at.mkdir("c"); + + ucmd.arg("-d").arg("a").arg("b").arg("c").succeeds(); + + assert!(at.dir_exists("c")); + assert!(at.plus("c").join("a").exists()); + assert!(at.plus("c").join("b").exists()); + + #[cfg(unix)] + { + let metadata_a = std::fs::metadata(at.subdir.join("c").join("a")).unwrap(); + let metadata_b = std::fs::metadata(at.subdir.join("c").join("b")).unwrap(); + + assert_eq!(metadata_a.ino(), metadata_b.ino()); + } +} + +#[test] +// android platform will causing stderr = cp: Permission denied (os error 13) +#[cfg(not(target_os = "android"))] +fn test_cp_preserve_links_case_7() { + let (at, mut ucmd) = at_and_ucmd!(); + + at.mkdir("src"); + at.touch("src/f"); + at.hard_link("src/f", "src/g"); + + at.mkdir("dest"); + at.touch("dest/g"); + + ucmd.arg("-n") + .arg("--preserve=links") + .arg("src/f") + .arg("src/g") + .arg("dest") + .fails() + .stderr_contains("not replacing"); + (); + + assert!(at.dir_exists("dest")); + assert!(at.plus("dest").join("f").exists()); + assert!(at.plus("dest").join("g").exists()); +} + #[test] // For now, disable the test on Windows. Symlinks aren't well support on Windows. // It works on Unix for now and it works locally when run from a powershell From 1dcf3e63535d876b2c9e7e9680cf3fae28b5e8a0 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sun, 24 Sep 2023 14:13:16 +0200 Subject: [PATCH 213/370] expose whoami function (for nushell!) --- src/uu/whoami/src/whoami.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/uu/whoami/src/whoami.rs b/src/uu/whoami/src/whoami.rs index cb8bcd9c7..738f7509a 100644 --- a/src/uu/whoami/src/whoami.rs +++ b/src/uu/whoami/src/whoami.rs @@ -5,6 +5,8 @@ /* last synced with: whoami (GNU coreutils) 8.21 */ +use std::ffi::OsString; + use clap::{crate_version, Command}; use uucore::display::println_verbatim; @@ -19,11 +21,16 @@ const USAGE: &str = help_usage!("whoami.md"); #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { uu_app().try_get_matches_from(args)?; - let username = platform::get_username().map_err_context(|| "failed to get username".into())?; + let username = whoami()?; println_verbatim(username).map_err_context(|| "failed to print username".into())?; Ok(()) } +/// Get the current username +pub fn whoami() -> UResult { + platform::get_username().map_err_context(|| "failed to get username".into()) +} + pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(crate_version!()) From b90b59c0035f3296b3defc0fc1196660f1e3ade6 Mon Sep 17 00:00:00 2001 From: Leviticoh <67531886+Leviticoh@users.noreply.github.com> Date: Sun, 24 Sep 2023 14:44:44 +0200 Subject: [PATCH 214/370] uniq: added support for deprecated `-N` option (#4228) --- src/uu/uniq/src/uniq.rs | 80 +++++++++++++++++- tests/by-util/test_uniq.rs | 92 +++++++++++++++------ tests/fixtures/uniq/skip-2-fields.expected | 3 + tests/fixtures/uniq/skip-21-fields.expected | 3 + tests/fixtures/uniq/skip-fields.txt | 3 + 5 files changed, 150 insertions(+), 31 deletions(-) create mode 100644 tests/fixtures/uniq/skip-21-fields.expected diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index 3aac7b834..72338bf96 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use clap::{builder::ValueParser, crate_version, Arg, ArgAction, ArgMatches, Command}; +use clap::{builder::ValueParser, crate_version, Arg, ArgAction, ArgGroup, ArgMatches, Command}; use std::ffi::{OsStr, OsString}; use std::fs::File; use std::io::{self, stdin, stdout, BufRead, BufReader, BufWriter, Write}; @@ -23,6 +23,7 @@ pub mod options { pub static IGNORE_CASE: &str = "ignore-case"; pub static REPEATED: &str = "repeated"; pub static SKIP_FIELDS: &str = "skip-fields"; + pub static OBSOLETE_SKIP_FIELDS: &str = "obsolete_skip_field"; pub static SKIP_CHARS: &str = "skip-chars"; pub static UNIQUE: &str = "unique"; pub static ZERO_TERMINATED: &str = "zero-terminated"; @@ -53,6 +54,8 @@ struct Uniq { zero_terminated: bool, } +const OBSOLETE_SKIP_FIELDS_DIGITS: [&str; 10] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]; + macro_rules! write_line_terminator { ($writer:expr, $line_terminator:expr) => { $writer @@ -236,6 +239,41 @@ fn opt_parsed(opt_name: &str, matches: &ArgMatches) -> UResult UResult> { + for opt_text in OBSOLETE_SKIP_FIELDS_DIGITS { + let argument = matches.get_one::(opt_text); + if matches.contains_id(opt_text) { + let mut full = opt_text.to_owned(); + if let Some(ar) = argument { + full.push_str(ar); + } + let value = full.parse::(); + + if let Ok(val) = value { + return Ok(Some(val)); + } else { + return Err(USimpleError { + code: 1, + message: format!("Invalid argument for skip-fields: {}", full), + } + .into()); + } + } + } + Ok(None) +} + #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?; @@ -247,6 +285,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .map(|mut fi| (fi.next(), fi.next())) .unwrap_or_default(); + let skip_fields_modern: Option = opt_parsed(options::SKIP_FIELDS, &matches)?; + + let skip_fields_old: Option = obsolete_skip_field(&matches)?; + let uniq = Uniq { repeats_only: matches.get_flag(options::REPEATED) || matches.contains_id(options::ALL_REPEATED), @@ -255,7 +297,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { || matches.contains_id(options::GROUP), delimiters: get_delimiter(&matches), show_counts: matches.get_flag(options::COUNT), - skip_fields: opt_parsed(options::SKIP_FIELDS, &matches)?, + skip_fields: skip_fields_modern.or(skip_fields_old), slice_start: opt_parsed(options::SKIP_CHARS, &matches)?, slice_stop: opt_parsed(options::CHECK_CHARS, &matches)?, ignore_case: matches.get_flag(options::IGNORE_CASE), @@ -276,7 +318,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } pub fn uu_app() -> Command { - Command::new(uucore::util_name()) + let mut cmd = Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) @@ -355,6 +397,7 @@ pub fn uu_app() -> Command { Arg::new(options::SKIP_FIELDS) .short('f') .long(options::SKIP_FIELDS) + .overrides_with_all(OBSOLETE_SKIP_FIELDS_DIGITS) .help("avoid comparing the first N fields") .value_name("N"), ) @@ -372,13 +415,42 @@ pub fn uu_app() -> Command { .help("end lines with 0 byte, not newline") .action(ArgAction::SetTrue), ) + .group( + // in GNU `uniq` every every digit of these arguments + // would be interpreted as a simple flag, + // these flags then are concatenated to get + // the number of fields to skip. + // in this way `uniq -1 -z -2` would be + // equal to `uniq -12 -q`, since this behavior + // is counterintuitive and it's hard to do in clap + // we handle it more like GNU `fold`: we have a flag + // for each possible initial digit, that takes the + // rest of the value as argument. + // we disallow explicitly multiple occurrences + // because then it would have a different behavior + // from GNU + ArgGroup::new(options::OBSOLETE_SKIP_FIELDS) + .multiple(false) + .args(OBSOLETE_SKIP_FIELDS_DIGITS) + ) .arg( Arg::new(ARG_FILES) .action(ArgAction::Append) .value_parser(ValueParser::os_string()) .num_args(0..=2) .value_hint(clap::ValueHint::FilePath), - ) + ); + + for i in OBSOLETE_SKIP_FIELDS_DIGITS { + cmd = cmd.arg( + Arg::new(i) + .short(i.chars().next().unwrap()) + .num_args(0..=1) + .hide(true), + ); + } + + cmd } fn get_delimiter(matches: &ArgMatches) -> Delimiters { diff --git a/tests/by-util/test_uniq.rs b/tests/by-util/test_uniq.rs index 97a829b9f..aa41de827 100644 --- a/tests/by-util/test_uniq.rs +++ b/tests/by-util/test_uniq.rs @@ -80,7 +80,7 @@ fn test_stdin_skip_and_check_2_chars() { } #[test] -fn test_stdin_skip_1_field() { +fn test_stdin_skip_2_fields() { new_ucmd!() .args(&["-f2"]) .pipe_in_fixture(SKIP_FIELDS) @@ -88,6 +88,42 @@ fn test_stdin_skip_1_field() { .stdout_is_fixture("skip-2-fields.expected"); } +#[test] +fn test_stdin_skip_2_fields_obsolete() { + new_ucmd!() + .args(&["-2"]) + .pipe_in_fixture(SKIP_FIELDS) + .run() + .stdout_is_fixture("skip-2-fields.expected"); +} + +#[test] +fn test_stdin_skip_21_fields() { + new_ucmd!() + .args(&["-f21"]) + .pipe_in_fixture(SKIP_FIELDS) + .run() + .stdout_is_fixture("skip-21-fields.expected"); +} + +#[test] +fn test_stdin_skip_21_fields_obsolete() { + new_ucmd!() + .args(&["-21"]) + .pipe_in_fixture(SKIP_FIELDS) + .run() + .stdout_is_fixture("skip-21-fields.expected"); +} + +#[test] +fn test_stdin_skip_invalid_fields_obsolete() { + new_ucmd!() + .args(&["-5deadbeef"]) + .run() + .failure() + .stderr_only("uniq: Invalid argument for skip-fields: 5deadbeef\n"); +} + #[test] fn test_stdin_all_repeated() { new_ucmd!() @@ -436,15 +472,15 @@ fn gnu_tests() { stderr: None, exit: None, }, - // // Obsolete syntax for "-f 1" - // TestCase { - // name: "obs30", - // args: &["-1"], - // input: "a a\nb a\n", - // stdout: Some("a a\n"), - // stderr: None, - // exit: None, - // }, + // Obsolete syntax for "-f 1" + TestCase { + name: "obs30", + args: &["-1"], + input: "a a\nb a\n", + stdout: Some("a a\n"), + stderr: None, + exit: None, + }, TestCase { name: "31", args: &["-f", "1"], @@ -518,23 +554,25 @@ fn gnu_tests() { stderr: None, exit: None, }, - // // Obsolete syntax for "-s 1" - // TestCase { - // name: "obs-plus44", - // args: &["+1", "--"], - // input: "aaa\naaa\n", - // stdout: Some("aaa\n"), - // stderr: None, - // exit: None, - // }, - // TestCase { - // name: "obs-plus45", - // args: &["+1", "--"], - // input: "baa\naaa\n", - // stdout: Some("baa\n"), - // stderr: None, - // exit: None, - // }, + /* + // Obsolete syntax for "-s 1" + TestCase { + name: "obs-plus44", + args: &["+1", "--"], + input: "aaa\naaa\n", + stdout: Some("aaa\n"), + stderr: None, + exit: None, + }, + TestCase { + name: "obs-plus45", + args: &["+1", "--"], + input: "baa\naaa\n", + stdout: Some("baa\n"), + stderr: None, + exit: None, + }, + */ TestCase { name: "50", args: &["-f", "1", "-s", "1"], diff --git a/tests/fixtures/uniq/skip-2-fields.expected b/tests/fixtures/uniq/skip-2-fields.expected index b971c2b2b..c7f9bde9d 100644 --- a/tests/fixtures/uniq/skip-2-fields.expected +++ b/tests/fixtures/uniq/skip-2-fields.expected @@ -1,2 +1,5 @@ aaa ⟪⟫ a aa a +a a a a a a a a a a a a a a a a a a a b a a a +a a a a a a a a a a a a a a a a a a a a b a a +a a a a a a a a a a a a a a a a a a a a a b a diff --git a/tests/fixtures/uniq/skip-21-fields.expected b/tests/fixtures/uniq/skip-21-fields.expected new file mode 100644 index 000000000..1f5295afa --- /dev/null +++ b/tests/fixtures/uniq/skip-21-fields.expected @@ -0,0 +1,3 @@ + aaa ⟪⟫ a +a a a a a a a a a a a a a a a a a a a b a a a +a a a a a a a a a a a a a a a a a a a a a b a diff --git a/tests/fixtures/uniq/skip-fields.txt b/tests/fixtures/uniq/skip-fields.txt index 4ec2744c6..0ca708a74 100644 --- a/tests/fixtures/uniq/skip-fields.txt +++ b/tests/fixtures/uniq/skip-fields.txt @@ -6,3 +6,6 @@ ZZZ aa a aa a a +a a a a a a a a a a a a a a a a a a a b a a a +a a a a a a a a a a a a a a a a a a a a b a a +a a a a a a a a a a a a a a a a a a a a a b a From ec7ced2518386be229d154fdf42675b8255a5f5d Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 20 Mar 2023 20:55:45 +0100 Subject: [PATCH 215/370] Fuzz the expr command --- .github/workflows/CICD.yml | 7 ++ fuzz/Cargo.toml | 7 ++ fuzz/fuzz_targets/fuzz_common.rs | 30 +++++ fuzz/fuzz_targets/fuzz_expr.rs | 184 +++++++++++++++++++++++++++++++ 4 files changed, 228 insertions(+) create mode 100644 fuzz/fuzz_targets/fuzz_common.rs create mode 100644 fuzz/fuzz_targets/fuzz_expr.rs diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 577e235f9..a9f04e3cf 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -149,6 +149,13 @@ jobs: ## Run it cd fuzz cargo +nightly fuzz run fuzz_test -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 + - name: Run fuzz_expr for XX seconds + continue-on-error: true + shell: bash + run: | + ## Run it + cd fuzz + cargo +nightly fuzz run fuzz_expr -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - name: Run fuzz_parse_glob for XX seconds shell: bash run: | diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 91a85b45a..549f9a6b7 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -15,6 +15,7 @@ rand = { version = "0.8", features = ["small_rng"] } uucore = { path = "../src/uucore/" } uu_date = { path = "../src/uu/date/" } uu_test = { path = "../src/uu/test/" } +uu_expr = { path = "../src/uu/expr/" } # Prevent this from interfering with workspaces @@ -27,6 +28,12 @@ path = "fuzz_targets/fuzz_date.rs" test = false doc = false +[[bin]] +name = "fuzz_expr" +path = "fuzz_targets/fuzz_expr.rs" +test = false +doc = false + [[bin]] name = "fuzz_test" path = "fuzz_targets/fuzz_test.rs" diff --git a/fuzz/fuzz_targets/fuzz_common.rs b/fuzz/fuzz_targets/fuzz_common.rs new file mode 100644 index 000000000..fb1f498e9 --- /dev/null +++ b/fuzz/fuzz_targets/fuzz_common.rs @@ -0,0 +1,30 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. + +use std::process::Command; +use std::sync::atomic::Ordering; +use std::sync::{atomic::AtomicBool, Once}; + +static CHECK_GNU: Once = Once::new(); +static IS_GNU: AtomicBool = AtomicBool::new(false); + +pub fn is_gnu_cmd(cmd_path: &str) -> Result<(), std::io::Error> { + CHECK_GNU.call_once(|| { + let version_output = Command::new(cmd_path).arg("--version").output().unwrap(); + + println!("version_output {:#?}", version_output); + + let version_str = String::from_utf8_lossy(&version_output.stdout).to_string(); + if version_str.contains("GNU coreutils") { + IS_GNU.store(true, Ordering::Relaxed); + } + }); + + if IS_GNU.load(Ordering::Relaxed) { + Ok(()) + } else { + panic!("Not the GNU implementation"); + } +} diff --git a/fuzz/fuzz_targets/fuzz_expr.rs b/fuzz/fuzz_targets/fuzz_expr.rs new file mode 100644 index 000000000..e364342b8 --- /dev/null +++ b/fuzz/fuzz_targets/fuzz_expr.rs @@ -0,0 +1,184 @@ +// This file is part of the uutils coreutils package. +// +// For the full copyright and license information, please view the LICENSE +// file that was distributed with this source code. +// spell-checker:ignore parens + +#![no_main] +use libfuzzer_sys::fuzz_target; +use uu_expr::uumain; + +use rand::seq::SliceRandom; +use rand::Rng; +use std::ffi::OsString; + +use libc::{dup, dup2, STDOUT_FILENO}; +use std::process::Command; +mod fuzz_common; +use crate::fuzz_common::is_gnu_cmd; + +static CMD_PATH: &str = "expr"; + +fn run_gnu_expr(args: &[OsString]) -> Result<(String, i32), std::io::Error> { + is_gnu_cmd(CMD_PATH)?; // Check if it's a GNU implementation + + let mut command = Command::new(CMD_PATH); + for arg in args { + command.arg(arg); + } + let output = command.output()?; + let exit_code = output.status.code().unwrap_or(-1); + if output.status.success() { + Ok(( + String::from_utf8_lossy(&output.stdout).to_string(), + exit_code, + )) + } else { + Err(std::io::Error::new( + std::io::ErrorKind::Other, + format!("GNU expr execution failed with exit code {}", exit_code), + )) + } +} + +fn generate_random_string(max_length: usize) -> String { + let mut rng = rand::thread_rng(); + let valid_utf8: Vec = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + .chars() + .collect(); + let invalid_utf8 = [0xC3, 0x28]; // Invalid UTF-8 sequence + let mut result = String::new(); + + for _ in 0..rng.gen_range(1..=max_length) { + if rng.gen_bool(0.9) { + let ch = valid_utf8.choose(&mut rng).unwrap(); + result.push(*ch); + } else { + let ch = invalid_utf8.choose(&mut rng).unwrap(); + if let Some(c) = char::from_u32(*ch as u32) { + result.push(c); + } + } + } + + result +} + +fn generate_expr(max_depth: u32) -> String { + let mut rng = rand::thread_rng(); + let ops = ["+", "-", "*", "/", "%", "<", ">", "=", "&", "|"]; + + let mut expr = String::new(); + let mut depth = 0; + let mut last_was_operator = false; + + while depth <= max_depth { + if last_was_operator || depth == 0 { + // Add a number + expr.push_str(&rng.gen_range(1..=100).to_string()); + last_was_operator = false; + } else { + // 90% chance to add an operator followed by a number + if rng.gen_bool(0.9) { + let op = *ops.choose(&mut rng).unwrap(); + expr.push_str(&format!(" {} ", op)); + last_was_operator = true; + } + // 10% chance to add a random string (potentially invalid syntax) + else { + let random_str = generate_random_string(rng.gen_range(1..=10)); + expr.push_str(&random_str); + last_was_operator = false; + } + } + depth += 1; + } + + // Ensure the expression ends with a number if it ended with an operator + if last_was_operator { + expr.push_str(&rng.gen_range(1..=100).to_string()); + } + + expr +} + +fuzz_target!(|_data: &[u8]| { + let mut rng = rand::thread_rng(); + let expr = generate_expr(rng.gen_range(0..=20)); + let mut args = vec![OsString::from("expr")]; + args.extend(expr.split_whitespace().map(OsString::from)); + + // Save the original stdout file descriptor + let original_stdout_fd = unsafe { dup(STDOUT_FILENO) }; + + // Create a pipe to capture stdout + let mut pipe_fds = [-1; 2]; + unsafe { libc::pipe(pipe_fds.as_mut_ptr()) }; + let uumain_exit_code; + { + // Redirect stdout to the write end of the pipe + unsafe { dup2(pipe_fds[1], STDOUT_FILENO) }; + + // Run uumain with the provided arguments + uumain_exit_code = uumain(args.clone().into_iter()); + + // Restore original stdout + unsafe { dup2(original_stdout_fd, STDOUT_FILENO) }; + unsafe { libc::close(original_stdout_fd) }; + } + // Close the write end of the pipe + unsafe { libc::close(pipe_fds[1]) }; + + // Read captured output from the read end of the pipe + let mut captured_output = Vec::new(); + let mut read_buffer = [0; 1024]; + loop { + let bytes_read = unsafe { + libc::read( + pipe_fds[0], + read_buffer.as_mut_ptr() as *mut libc::c_void, + read_buffer.len(), + ) + }; + if bytes_read <= 0 { + break; + } + captured_output.extend_from_slice(&read_buffer[..bytes_read as usize]); + } + + // Close the read end of the pipe + unsafe { libc::close(pipe_fds[0]) }; + + // Convert captured output to a string + let rust_output = String::from_utf8_lossy(&captured_output) + .to_string() + .trim() + .to_owned(); + + // Run GNU expr with the provided arguments and compare the output + match run_gnu_expr(&args[1..]) { + Ok((gnu_output, gnu_exit_code)) => { + let gnu_output = gnu_output.trim().to_owned(); + if uumain_exit_code != gnu_exit_code { + println!("Expression: {}", expr); + println!("Rust code: {}", uumain_exit_code); + println!("GNU code: {}", gnu_exit_code); + panic!("Different error codes"); + } + if rust_output != gnu_output { + println!("Expression: {}", expr); + println!("Rust output: {}", rust_output); + println!("GNU output: {}", gnu_output); + panic!("Different output between Rust & GNU"); + } else { + println!( + "Outputs matched for expression: {} => Result: {}", + expr, rust_output + ); + } + } + Err(_) => { + println!("GNU expr execution failed for expression: {}", expr); + } + } +}); From 6aba3a4d67200d7ade6639d688a5a6c4510bd3f2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 24 Sep 2023 20:04:53 +0000 Subject: [PATCH 216/370] fix(deps): update rust crate wild to 2.2 --- Cargo.lock | 4 ++-- src/uucore/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3723c52da..5dc160b4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3385,9 +3385,9 @@ dependencies = [ [[package]] name = "wild" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b116685a6be0c52f5a103334cbff26db643826c7b3735fc0a3ba9871310a74" +checksum = "10d01931a94d5a115a53f95292f51d316856b68a035618eb831bbba593a30b67" dependencies = [ "glob", ] diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 93bc618ce..5e555da4d 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -22,7 +22,7 @@ clap = { workspace = true } uucore_procs = { workspace = true } dns-lookup = { version = "2.0.3", optional = true } dunce = { version = "1.0.4", optional = true } -wild = "2.1" +wild = "2.2" glob = { workspace = true } # * optional itertools = { workspace = true, optional = true } From 3da58099103813c0143b3215a9e4c2f9fb83e41c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 01:21:46 +0000 Subject: [PATCH 217/370] chore(deps): update rust crate memmap2 to 0.8 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3723c52da..c51f70851 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1291,9 +1291,9 @@ checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e" [[package]] name = "memmap2" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180d4b35be83d33392d1d1bfbd2ae1eca7ff5de1a94d3fc87faaa99a069e7cbd" +checksum = "43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed" dependencies = [ "libc", ] diff --git a/Cargo.toml b/Cargo.toml index 65b23faa2..15351798d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -292,7 +292,7 @@ lscolors = { version = "0.15.0", default-features = false, features = [ "nu-ansi-term", ] } memchr = "2" -memmap2 = "0.7" +memmap2 = "0.8" nix = { version = "0.27", default-features = false } nom = "7.1.3" notify = { version = "=6.0.1", features = ["macos_kqueue"] } From 45487d47b88d7aeb792869f48250f7c01f58507e Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Mon, 25 Sep 2023 11:43:21 +0200 Subject: [PATCH 218/370] extract Base enum --- src/uu/echo/src/echo.rs | 32 ++++++++++++++++++++++++-------- tests/by-util/test_echo.rs | 4 ++-- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index 565166842..5ccc6a32a 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -21,8 +21,24 @@ mod options { pub const DISABLE_BACKSLASH_ESCAPE: &str = "disable_backslash_escape"; } +#[repr(u8)] +#[derive(Clone, Copy)] +enum Base { + Oct = 8, + Hex = 16, +} + +impl Base { + fn max_digits(&self) -> u8 { + match self { + Self::Oct => 3, + Self::Hex => 2, + } + } +} + /// Parse the numeric part of the `\xHHH` and `\0NNN` escape sequences -fn parse_code(input: &mut Peekable, base: u8, max_digits: u32) -> Option { +fn parse_code(input: &mut Peekable, base: Base) -> Option { // All arithmetic on `ret` needs to be wrapping, because octal input can // take 3 digits, which is 9 bits, and therefore more than what fits in a // `u8`. GNU just seems to wrap these values. @@ -31,15 +47,15 @@ fn parse_code(input: &mut Peekable, base: u8, max_digits: u32) -> Option< // `u8::MAX` as unicode. let mut ret = input.peek().and_then(|c| c.to_digit(base as u32))? as u8; - // We can safely ifgnore the None case because we just peeked it. + // We can safely ignore the None case because we just peeked it. let _ = input.next(); - for _ in 1..max_digits { + for _ in 1..base.max_digits() { match input.peek().and_then(|c| c.to_digit(base as u32)) { - Some(n) => ret = ret.wrapping_mul(base).wrapping_add(n as u8), + Some(n) => ret = ret.wrapping_mul(base as u8).wrapping_add(n as u8), None => break, } - // We can safely ifgnore the None case because we just peeked it. + // We can safely ignore the None case because we just peeked it. let _ = input.next(); } @@ -58,7 +74,7 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result { // Note that '0' is intentionally omitted because that // would be the \0NNN syntax. if let Some('1'..='8') = iter.peek() { - if let Some(parsed) = parse_code(&mut iter, 8, 3) { + if let Some(parsed) = parse_code(&mut iter, Base::Oct) { write!(output, "{parsed}")?; continue; } @@ -77,14 +93,14 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result { 't' => '\t', 'v' => '\x0b', 'x' => { - if let Some(c) = parse_code(&mut iter, 16, 2) { + if let Some(c) = parse_code(&mut iter, Base::Hex) { c } else { write!(output, "\\")?; 'x' } } - '0' => parse_code(&mut iter, 8, 3).unwrap_or('\0'), + '0' => parse_code(&mut iter, Base::Oct).unwrap_or('\0'), c => { write!(output, "\\")?; c diff --git a/tests/by-util/test_echo.rs b/tests/by-util/test_echo.rs index 7de963973..dce5a4c95 100644 --- a/tests/by-util/test_echo.rs +++ b/tests/by-util/test_echo.rs @@ -270,9 +270,9 @@ fn old_octal_syntax() { new_ucmd!() .arg("-e") - .arg("\\101foo") + .arg("\\101 foo") .succeeds() - .stdout_is("Afoo\n"); + .stdout_is("A foo\n"); new_ucmd!() .arg("-e") From 9fcf4cd8e5a0e3688fc2deefd36e65b927b45917 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 24 Sep 2023 22:35:27 +0200 Subject: [PATCH 219/370] run-gnu-test.sh: show if we can't find the file Otherwise, the error can be cryptic Co-authored-by: Daniel Hofstetter --- util/run-gnu-test.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/util/run-gnu-test.sh b/util/run-gnu-test.sh index 55ba8cefc..fde066ae1 100755 --- a/util/run-gnu-test.sh +++ b/util/run-gnu-test.sh @@ -33,7 +33,17 @@ if test $# -ge 1; then # if set, run only the tests passed SPECIFIC_TESTS="" for t in "$@"; do - SPECIFIC_TESTS="$SPECIFIC_TESTS $t" + + # Construct the full path + full_path="$path_GNU/$t" + + # Check if the file exists with .sh, .pl extension or without any extension in the $path_GNU directory + if [ -f "$full_path" ] || [ -f "$full_path.sh" ] || [ -f "$full_path.pl" ]; then + SPECIFIC_TESTS="$SPECIFIC_TESTS $t" + else + echo "Error: Test file $full_path, $full_path.sh, or $full_path.pl does not exist!" + exit 1 + fi done # trim it SPECIFIC_TESTS=$(echo $SPECIFIC_TESTS | xargs) From 22f72544a8bf96e94204929aae5475624af749dc Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 26 Sep 2023 09:33:14 +0200 Subject: [PATCH 220/370] run-gnu-test.sh: accept "run-root" as first param --- util/run-gnu-test.sh | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/util/run-gnu-test.sh b/util/run-gnu-test.sh index fde066ae1..1abb476b7 100755 --- a/util/run-gnu-test.sh +++ b/util/run-gnu-test.sh @@ -29,25 +29,27 @@ cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]" export RUST_BACKTRACE=1 -if test $# -ge 1; then - # if set, run only the tests passed - SPECIFIC_TESTS="" - for t in "$@"; do +if test "$1" != "run-root"; then + if test $# -ge 1; then + # if set, run only the tests passed + SPECIFIC_TESTS="" + for t in "$@"; do - # Construct the full path - full_path="$path_GNU/$t" + # Construct the full path + full_path="$path_GNU/$t" - # Check if the file exists with .sh, .pl extension or without any extension in the $path_GNU directory - if [ -f "$full_path" ] || [ -f "$full_path.sh" ] || [ -f "$full_path.pl" ]; then - SPECIFIC_TESTS="$SPECIFIC_TESTS $t" - else - echo "Error: Test file $full_path, $full_path.sh, or $full_path.pl does not exist!" - exit 1 - fi - done - # trim it - SPECIFIC_TESTS=$(echo $SPECIFIC_TESTS | xargs) - echo "Running specific tests: $SPECIFIC_TESTS" + # Check if the file exists with .sh, .pl extension or without any extension in the $path_GNU directory + if [ -f "$full_path" ] || [ -f "$full_path.sh" ] || [ -f "$full_path.pl" ]; then + SPECIFIC_TESTS="$SPECIFIC_TESTS $t" + else + echo "Error: Test file $full_path, $full_path.sh, or $full_path.pl does not exist!" + exit 1 + fi + done + # trim it + SPECIFIC_TESTS=$(echo $SPECIFIC_TESTS | xargs) + echo "Running specific tests: $SPECIFIC_TESTS" + fi fi # * timeout used to kill occasionally errant/"stuck" processes (note: 'release' testing takes ~1 hour; 'debug' testing takes ~2.5 hours) From 99120d32c13f01b6e146b1f5546c5e2520d73a16 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 24 Sep 2023 23:13:34 +0200 Subject: [PATCH 221/370] cut: fail when the input == usize::MAX --- src/uucore/src/lib/features/ranges.rs | 2 ++ tests/by-util/test_cut.rs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/uucore/src/lib/features/ranges.rs b/src/uucore/src/lib/features/ranges.rs index 29f402183..7c09f922d 100644 --- a/src/uucore/src/lib/features/ranges.rs +++ b/src/uucore/src/lib/features/ranges.rs @@ -38,6 +38,8 @@ impl FromStr for Range { fn parse(s: &str) -> Result { match s.parse::() { Ok(0) => Err("fields and positions are numbered from 1"), + // GNU fails when we are at the limit. Match their behavior + Ok(n) if n == usize::MAX => Err("byte/character offset is too large"), Ok(n) => Ok(n), Err(_) => Err("failed to parse range"), } diff --git a/tests/by-util/test_cut.rs b/tests/by-util/test_cut.rs index 7f86c803e..184e413a8 100644 --- a/tests/by-util/test_cut.rs +++ b/tests/by-util/test_cut.rs @@ -117,6 +117,14 @@ fn test_whitespace_with_char() { .code_is(1); } +#[test] +fn test_too_large() { + new_ucmd!() + .args(&["-b1-18446744073709551615", "/dev/null"]) + .fails() + .code_is(1); +} + #[test] fn test_specify_delimiter() { for param in ["-d", "--delimiter", "--del"] { From 265c25871385eaf33c1945609ae5cf6521a790f3 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 24 Sep 2023 23:23:27 +0200 Subject: [PATCH 222/370] ranges: add unit tests to verify the parsing To test them: $ cargo test -p uucore --features ranges --- src/uucore/src/lib/features/ranges.rs | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/uucore/src/lib/features/ranges.rs b/src/uucore/src/lib/features/ranges.rs index 7c09f922d..19ba23fb2 100644 --- a/src/uucore/src/lib/features/ranges.rs +++ b/src/uucore/src/lib/features/ranges.rs @@ -161,6 +161,7 @@ pub fn contain(ranges: &[Range], n: usize) -> bool { #[cfg(test)] mod test { use super::{complement, Range}; + use std::str::FromStr; fn m(a: Vec, b: &[Range]) { assert_eq!(Range::merge(a), b); @@ -231,4 +232,33 @@ mod test { // With start and end assert_eq!(complement(&[r(1, 4), r(6, usize::MAX - 1)]), vec![r(5, 5)]); } + + #[test] + fn test_from_str() { + assert_eq!(Range::from_str("5"), Ok(Range { low: 5, high: 5 })); + assert_eq!(Range::from_str("3-5"), Ok(Range { low: 3, high: 5 })); + assert_eq!( + Range::from_str("5-3"), + Err("high end of range less than low end") + ); + assert_eq!(Range::from_str("-"), Err("invalid range with no endpoint")); + assert_eq!( + Range::from_str("3-"), + Ok(Range { + low: 3, + high: usize::MAX - 1 + }) + ); + assert_eq!(Range::from_str("-5"), Ok(Range { low: 1, high: 5 })); + assert_eq!( + Range::from_str("0"), + Err("fields and positions are numbered from 1") + ); + + let max_value = format!("{}", usize::MAX); + assert_eq!( + Range::from_str(&max_value), + Err("byte/character offset is too large") + ); + } } From 2a97eab685786f7a81dea294cfbac199d4848957 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 07:45:23 +0000 Subject: [PATCH 223/370] chore(deps): update rust crate exacl to 0.11.0 --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 53e3232fc..24ef766d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,9 +149,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "blake2b_simd" @@ -640,7 +640,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "crossterm_winapi", "libc", "mio", @@ -805,11 +805,11 @@ dependencies = [ [[package]] name = "exacl" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfeb22a59deb24c3262c43ffcafd1eb807180f371f9fcc99098d181b5d639be" +checksum = "c695152c1c2777163ea93fff517edc6dd1f8fc226c14b0d60cdcde0beb316d9f" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "log", "scopeguard", "uuid", @@ -1340,7 +1340,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "cfg-if", "libc", ] @@ -1876,7 +1876,7 @@ version = "0.38.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "errno", "libc", "linux-raw-sys 0.4.5", diff --git a/Cargo.toml b/Cargo.toml index 15351798d..2ee4444b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -275,7 +275,7 @@ compare = "0.1.0" coz = { version = "0.1.3" } crossterm = ">=0.27.0" ctrlc = { version = "3.4", features = ["termination"] } -exacl = "0.10.0" +exacl = "0.11.0" file_diff = "1.0.0" filetime = "0.2" fnv = "1.0.7" From ff500d7d6f51fa64e6ba2b526c4fd1b5748f9850 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 26 Sep 2023 16:12:59 +0200 Subject: [PATCH 224/370] expr: interpret numbers != 0 as true for | and & --- src/uu/expr/src/syntax_tree.rs | 6 +++--- tests/by-util/test_expr.rs | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index 0e0795bd4..b3cd329ba 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -8,10 +8,10 @@ //! * `` //! -// spell-checker:ignore (ToDO) binop binops ints paren prec multibytes +// spell-checker:ignore (ToDO) ints paren prec multibytes use num_bigint::BigInt; -use num_traits::{One, Zero}; +use num_traits::Zero; use onig::{Regex, RegexOptions, Syntax}; use crate::tokens::Token; @@ -515,7 +515,7 @@ fn value_as_bool(s: &str) -> bool { return false; } match s.parse::() { - Ok(n) => n.is_one(), + Ok(n) => n != Zero::zero(), Err(_) => true, } } diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index 665f89615..ea5a964d9 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -113,6 +113,16 @@ fn test_or() { .args(&["foo", "|", "bar"]) .succeeds() .stdout_only("foo\n"); + + new_ucmd!() + .args(&["14", "|", "1"]) + .succeeds() + .stdout_only("14\n"); + + new_ucmd!() + .args(&["-14", "|", "1"]) + .succeeds() + .stdout_only("-14\n"); } #[test] @@ -123,6 +133,13 @@ fn test_and() { .stdout_only("foo\n"); new_ucmd!().args(&["", "&", "1"]).run().stdout_is("0\n"); + + new_ucmd!().args(&["14", "&", "1"]).run().stdout_is("14\n"); + + new_ucmd!() + .args(&["-14", "&", "1"]) + .run() + .stdout_is("-14\n"); } #[test] From 6c7a20fc1868bf636b2c331bc1fcca39983d810b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 16:57:54 +0000 Subject: [PATCH 225/370] chore(deps): update rust crate sha2 to 0.10.8 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 24ef766d0..c00755198 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1955,9 +1955,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", diff --git a/Cargo.toml b/Cargo.toml index 2ee4444b1..a40d066d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -336,7 +336,7 @@ zip = { version = "0.6.6", default_features = false, features = ["deflate"] } hex = "0.4.3" md-5 = "0.10.6" sha1 = "0.10.6" -sha2 = "0.10.7" +sha2 = "0.10.8" sha3 = "0.10.8" blake2b_simd = "1.0.2" blake3 = "1.5.0" From 2789885648053e1ff1fe9c745dddefe0a5f2840b Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 27 Sep 2023 19:16:10 +0800 Subject: [PATCH 226/370] cp: fix cp -dR --no-preserve=links d c should have different inodes (#5320) * fix issue 5308 --- src/uu/cp/src/cp.rs | 38 ++++++++++++++++++++++++-------------- tests/by-util/test_cp.rs | 2 +- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 05261c22f..b6270719c 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -931,23 +931,33 @@ impl Options { }; // Parse attributes to preserve - let attributes = if let Some(attribute_strs) = matches.get_many::(options::PRESERVE) - { - if attribute_strs.len() == 0 { + let mut attributes = + if let Some(attribute_strs) = matches.get_many::(options::PRESERVE) { + if attribute_strs.len() == 0 { + Attributes::DEFAULT + } else { + Attributes::parse_iter(attribute_strs)? + } + } else if matches.get_flag(options::ARCHIVE) { + // --archive is used. Same as --preserve=all + Attributes::ALL + } else if matches.get_flag(options::NO_DEREFERENCE_PRESERVE_LINKS) { + Attributes::LINKS + } else if matches.get_flag(options::PRESERVE_DEFAULT_ATTRIBUTES) { Attributes::DEFAULT } else { - Attributes::parse_iter(attribute_strs)? + Attributes::NONE + }; + + // handling no-preserve options and adjusting the attributes + if let Some(attribute_strs) = matches.get_many::(options::NO_PRESERVE) { + if attribute_strs.len() > 0 { + let no_preserve_attributes = Attributes::parse_iter(attribute_strs)?; + if matches!(no_preserve_attributes.links, Preserve::Yes { .. }) { + attributes.links = Preserve::No; + } } - } else if matches.get_flag(options::ARCHIVE) { - // --archive is used. Same as --preserve=all - Attributes::ALL - } else if matches.get_flag(options::NO_DEREFERENCE_PRESERVE_LINKS) { - Attributes::LINKS - } else if matches.get_flag(options::PRESERVE_DEFAULT_ATTRIBUTES) { - Attributes::DEFAULT - } else { - Attributes::NONE - }; + } #[cfg(not(feature = "feat_selinux"))] if let Preserve::Yes { required } = attributes.context { diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index afac4cd3a..1ce74572d 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -1494,7 +1494,7 @@ fn test_cp_preserve_links_case_5() { let metadata_a = std::fs::metadata(at.subdir.join("c").join("a")).unwrap(); let metadata_b = std::fs::metadata(at.subdir.join("c").join("b")).unwrap(); - assert_eq!(metadata_a.ino(), metadata_b.ino()); + assert_ne!(metadata_a.ino(), metadata_b.ino()); } } From aea986948df6375a90b3963e6c930f3a1adfce45 Mon Sep 17 00:00:00 2001 From: KAA the Wise Date: Wed, 27 Sep 2023 23:05:29 +0300 Subject: [PATCH 227/370] mkdir: make `mkdir` public and document it - Made the `mkdir` function public. Added documentation, describing the behavior and parameters - Moved the GNU dot-stripping behavior from `exec` to `mkdir`. --- src/uu/mkdir/src/mkdir.rs | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/uu/mkdir/src/mkdir.rs b/src/uu/mkdir/src/mkdir.rs index 2044855e4..354335d8c 100644 --- a/src/uu/mkdir/src/mkdir.rs +++ b/src/uu/mkdir/src/mkdir.rs @@ -141,21 +141,34 @@ pub fn uu_app() -> Command { */ fn exec(dirs: ValuesRef, recursive: bool, mode: u32, verbose: bool) -> UResult<()> { for dir in dirs { - // Special case to match GNU's behavior: - // mkdir -p foo/. should work and just create foo/ - // std::fs::create_dir("foo/."); fails in pure Rust - let path = if recursive { - dir_strip_dot_for_creation(&PathBuf::from(dir)) - } else { - // Normal case - PathBuf::from(dir) - }; - show_if_err!(mkdir(path.as_path(), recursive, mode, verbose)); + let path_buf = PathBuf::from(dir); + let path = path_buf.as_path(); + + show_if_err!(mkdir(path, recursive, mode, verbose)); } Ok(()) } -fn mkdir(path: &Path, recursive: bool, mode: u32, verbose: bool) -> UResult<()> { +/// Create directory at a given `path`. +/// +/// ## Options +/// +/// * `recursive` --- create parent directories for the `path`, if they do not +/// exist. +/// * `mode` --- file mode for the directories (not implemented on windows). +/// * `verbose` --- print a message for each printed directory. +/// +/// ## Trailing dot +/// +/// To match the GNU behavior, a path with the last directory being a single dot +/// (like `some/path/to/.`) is created (with the dot stripped). +pub fn mkdir(path: &Path, recursive: bool, mode: u32, verbose: bool) -> UResult<()> { + // Special case to match GNU's behavior: + // mkdir -p foo/. should work and just create foo/ + // std::fs::create_dir("foo/."); fails in pure Rust + let path_buf = dir_strip_dot_for_creation(path); + let path = path_buf.as_path(); + create_dir(path, recursive, verbose, false)?; chmod(path, mode) } From 9c0b9cae5610a81c2c9d152edb7fcca1c77e83dd Mon Sep 17 00:00:00 2001 From: John Shin Date: Wed, 27 Sep 2023 14:55:08 -0700 Subject: [PATCH 228/370] seq: simplyfy nan and inf parsing --- src/uu/seq/src/numberparse.rs | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/uu/seq/src/numberparse.rs b/src/uu/seq/src/numberparse.rs index 156f80fb9..07d853d58 100644 --- a/src/uu/seq/src/numberparse.rs +++ b/src/uu/seq/src/numberparse.rs @@ -69,28 +69,13 @@ fn parse_no_decimal_no_exponent(s: &str) -> Result { // Possibly "NaN" or "inf". - if let Ok(num) = f32::from_str(s) { - // pattern matching on floating point literal is not encouraged 'https://github.com/rust-lang/rust/issues/41620' - if num == f32::INFINITY { - Ok(PreciseNumber::new( - Number::Float(ExtendedBigDecimal::Infinity), - 0, - 0, - )) - } else if num == f32::NEG_INFINITY { - Ok(PreciseNumber::new( - Number::Float(ExtendedBigDecimal::MinusInfinity), - 0, - 0, - )) - } else if num.is_nan() { - Err(ParseNumberError::Nan) - } else { - Err(ParseNumberError::Float) - } - } else { - Err(ParseNumberError::Float) - } + let float_val = match s.to_ascii_lowercase().as_str() { + "inf" | "infinity" => ExtendedBigDecimal::Infinity, + "-inf" | "-infinity" => ExtendedBigDecimal::MinusInfinity, + "nan" | "-nan" => return Err(ParseNumberError::Nan), + _ => return Err(ParseNumberError::Float), + }; + Ok(PreciseNumber::new(Number::Float(float_val), 0, 0)) } } } From f0f64bd3b728c905944aaf3534f618d85ded30c6 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 28 Sep 2023 08:42:30 +0200 Subject: [PATCH 229/370] fuzz: move the common duplicated code into a function --- fuzz/fuzz_targets/fuzz_common.rs | 47 ++++++++++++++++++++++++ fuzz/fuzz_targets/fuzz_expr.rs | 49 ++----------------------- fuzz/fuzz_targets/fuzz_test.rs | 61 ++++++-------------------------- 3 files changed, 59 insertions(+), 98 deletions(-) diff --git a/fuzz/fuzz_targets/fuzz_common.rs b/fuzz/fuzz_targets/fuzz_common.rs index fb1f498e9..a33d603f1 100644 --- a/fuzz/fuzz_targets/fuzz_common.rs +++ b/fuzz/fuzz_targets/fuzz_common.rs @@ -3,6 +3,8 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. +use libc::{dup, dup2, STDOUT_FILENO}; +use std::ffi::OsString; use std::process::Command; use std::sync::atomic::Ordering; use std::sync::{atomic::AtomicBool, Once}; @@ -28,3 +30,48 @@ pub fn is_gnu_cmd(cmd_path: &str) -> Result<(), std::io::Error> { panic!("Not the GNU implementation"); } } + +pub fn generate_and_run_uumain(args: &mut Vec, uumain_function: F) -> (String, i32) +where + F: FnOnce(std::vec::IntoIter) -> i32, +{ + let uumain_exit_status; + + let original_stdout_fd = unsafe { dup(STDOUT_FILENO) }; + println!("Running test {:?}", &args[1..]); + let mut pipe_fds = [-1; 2]; + unsafe { libc::pipe(pipe_fds.as_mut_ptr()) }; + + { + unsafe { dup2(pipe_fds[1], STDOUT_FILENO) }; + uumain_exit_status = uumain_function(args.clone().into_iter()); + unsafe { dup2(original_stdout_fd, STDOUT_FILENO) }; + unsafe { libc::close(original_stdout_fd) }; + } + unsafe { libc::close(pipe_fds[1]) }; + + let mut captured_output = Vec::new(); + let mut read_buffer = [0; 1024]; + loop { + let bytes_read = unsafe { + libc::read( + pipe_fds[0], + read_buffer.as_mut_ptr() as *mut libc::c_void, + read_buffer.len(), + ) + }; + if bytes_read <= 0 { + break; + } + captured_output.extend_from_slice(&read_buffer[..bytes_read as usize]); + } + + unsafe { libc::close(pipe_fds[0]) }; + + let my_output = String::from_utf8_lossy(&captured_output) + .to_string() + .trim() + .to_owned(); + + (my_output, uumain_exit_status) +} diff --git a/fuzz/fuzz_targets/fuzz_expr.rs b/fuzz/fuzz_targets/fuzz_expr.rs index e364342b8..28fded99e 100644 --- a/fuzz/fuzz_targets/fuzz_expr.rs +++ b/fuzz/fuzz_targets/fuzz_expr.rs @@ -12,9 +12,9 @@ use rand::seq::SliceRandom; use rand::Rng; use std::ffi::OsString; -use libc::{dup, dup2, STDOUT_FILENO}; use std::process::Command; mod fuzz_common; +use crate::fuzz_common::generate_and_run_uumain; use crate::fuzz_common::is_gnu_cmd; static CMD_PATH: &str = "expr"; @@ -108,52 +108,7 @@ fuzz_target!(|_data: &[u8]| { let mut args = vec![OsString::from("expr")]; args.extend(expr.split_whitespace().map(OsString::from)); - // Save the original stdout file descriptor - let original_stdout_fd = unsafe { dup(STDOUT_FILENO) }; - - // Create a pipe to capture stdout - let mut pipe_fds = [-1; 2]; - unsafe { libc::pipe(pipe_fds.as_mut_ptr()) }; - let uumain_exit_code; - { - // Redirect stdout to the write end of the pipe - unsafe { dup2(pipe_fds[1], STDOUT_FILENO) }; - - // Run uumain with the provided arguments - uumain_exit_code = uumain(args.clone().into_iter()); - - // Restore original stdout - unsafe { dup2(original_stdout_fd, STDOUT_FILENO) }; - unsafe { libc::close(original_stdout_fd) }; - } - // Close the write end of the pipe - unsafe { libc::close(pipe_fds[1]) }; - - // Read captured output from the read end of the pipe - let mut captured_output = Vec::new(); - let mut read_buffer = [0; 1024]; - loop { - let bytes_read = unsafe { - libc::read( - pipe_fds[0], - read_buffer.as_mut_ptr() as *mut libc::c_void, - read_buffer.len(), - ) - }; - if bytes_read <= 0 { - break; - } - captured_output.extend_from_slice(&read_buffer[..bytes_read as usize]); - } - - // Close the read end of the pipe - unsafe { libc::close(pipe_fds[0]) }; - - // Convert captured output to a string - let rust_output = String::from_utf8_lossy(&captured_output) - .to_string() - .trim() - .to_owned(); + let (rust_output, uumain_exit_code) = generate_and_run_uumain(&mut args, uumain); // Run GNU expr with the provided arguments and compare the output match run_gnu_expr(&args[1..]) { diff --git a/fuzz/fuzz_targets/fuzz_test.rs b/fuzz/fuzz_targets/fuzz_test.rs index 537e21abd..535696b45 100644 --- a/fuzz/fuzz_targets/fuzz_test.rs +++ b/fuzz/fuzz_targets/fuzz_test.rs @@ -12,9 +12,11 @@ use rand::seq::SliceRandom; use rand::Rng; use std::ffi::OsString; -use libc::{dup, dup2, STDOUT_FILENO}; use std::process::Command; +mod fuzz_common; +use crate::fuzz_common::generate_and_run_uumain; + #[derive(PartialEq, Debug, Clone)] enum ArgType { STRING, @@ -26,8 +28,11 @@ enum ArgType { // Add any other types as needed } +static CMD_PATH: &str = "/usr/bin/test"; + fn run_gnu_test(args: &[OsString]) -> Result<(String, i32), std::io::Error> { - let mut command = Command::new("test"); + let mut command = Command::new(CMD_PATH); + for arg in args { command.arg(arg); } @@ -210,58 +215,12 @@ fuzz_target!(|_data: &[u8]| { let mut rng = rand::thread_rng(); let max_args = rng.gen_range(1..=6); let mut args = vec![OsString::from("test")]; - let uumain_exit_status; for _ in 0..max_args { args.push(OsString::from(generate_test_arg())); } - // Save the original stdout file descriptor - let original_stdout_fd = unsafe { dup(STDOUT_FILENO) }; - println!("Running test {:?}", &args[1..]); - // Create a pipe to capture stdout - let mut pipe_fds = [-1; 2]; - unsafe { libc::pipe(pipe_fds.as_mut_ptr()) }; - - { - // Redirect stdout to the write end of the pipe - unsafe { dup2(pipe_fds[1], STDOUT_FILENO) }; - - // Run uumain with the provided arguments - uumain_exit_status = uumain(args.clone().into_iter()); - - // Restore original stdout - unsafe { dup2(original_stdout_fd, STDOUT_FILENO) }; - unsafe { libc::close(original_stdout_fd) }; - } - // Close the write end of the pipe - unsafe { libc::close(pipe_fds[1]) }; - - // Read captured output from the read end of the pipe - let mut captured_output = Vec::new(); - let mut read_buffer = [0; 1024]; - loop { - let bytes_read = unsafe { - libc::read( - pipe_fds[0], - read_buffer.as_mut_ptr() as *mut libc::c_void, - read_buffer.len(), - ) - }; - if bytes_read <= 0 { - break; - } - captured_output.extend_from_slice(&read_buffer[..bytes_read as usize]); - } - - // Close the read end of the pipe - unsafe { libc::close(pipe_fds[0]) }; - - // Convert captured output to a string - let my_output = String::from_utf8_lossy(&captured_output) - .to_string() - .trim() - .to_owned(); + let (rust_output, uumain_exit_status) = generate_and_run_uumain(&mut args, uumain); // Run GNU test with the provided arguments and compare the output match run_gnu_test(&args[1..]) { @@ -269,10 +228,10 @@ fuzz_target!(|_data: &[u8]| { let gnu_output = gnu_output.trim().to_owned(); println!("gnu_exit_status {}", gnu_exit_status); println!("uumain_exit_status {}", uumain_exit_status); - if my_output != gnu_output || uumain_exit_status != gnu_exit_status { + if rust_output != gnu_output || uumain_exit_status != gnu_exit_status { println!("Discrepancy detected!"); println!("Test: {:?}", &args[1..]); - println!("My output: {}", my_output); + println!("My output: {}", rust_output); println!("GNU output: {}", gnu_output); println!("My exit status: {}", uumain_exit_status); println!("GNU exit status: {}", gnu_exit_status); From 51eb20a15d768b0b24b60a78b98c27602ed5cc50 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 28 Sep 2023 10:50:56 +0200 Subject: [PATCH 230/370] fmt: use clap's value parser for goal & width --- src/uu/fmt/src/fmt.rs | 30 ++++++++---------------------- tests/by-util/test_fmt.rs | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index c5eac7073..c30d923b7 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -131,16 +131,8 @@ fn parse_arguments(args: impl uucore::Args) -> UResult<(Vec, FmtOptions) fmt_opts.use_anti_prefix = true; }; - if let Some(s) = matches.get_one::(OPT_WIDTH) { - fmt_opts.width = match s.parse::() { - Ok(t) => t, - Err(e) => { - return Err(USimpleError::new( - 1, - format!("Invalid WIDTH specification: {}: {}", s.quote(), e), - )); - } - }; + if let Some(width) = matches.get_one::(OPT_WIDTH) { + fmt_opts.width = *width; if fmt_opts.width > MAX_WIDTH { return Err(USimpleError::new( 1, @@ -156,16 +148,8 @@ fn parse_arguments(args: impl uucore::Args) -> UResult<(Vec, FmtOptions) ); }; - if let Some(s) = matches.get_one::(OPT_GOAL) { - fmt_opts.goal = match s.parse::() { - Ok(t) => t, - Err(e) => { - return Err(USimpleError::new( - 1, - format!("Invalid GOAL specification: {}: {}", s.quote(), e), - )); - } - }; + if let Some(goal) = matches.get_one::(OPT_GOAL) { + fmt_opts.goal = *goal; if !matches.contains_id(OPT_WIDTH) { fmt_opts.width = cmp::max( fmt_opts.goal * 100 / DEFAULT_GOAL_TO_WIDTH_RATIO, @@ -372,14 +356,16 @@ pub fn uu_app() -> Command { .short('w') .long("width") .help("Fill output lines up to a maximum of WIDTH columns, default 75.") - .value_name("WIDTH"), + .value_name("WIDTH") + .value_parser(clap::value_parser!(usize)), ) .arg( Arg::new(OPT_GOAL) .short('g') .long("goal") .help("Goal width, default of 93% of WIDTH. Must be less than WIDTH.") - .value_name("GOAL"), + .value_name("GOAL") + .value_parser(clap::value_parser!(usize)), ) .arg( Arg::new(OPT_QUICK) diff --git a/tests/by-util/test_fmt.rs b/tests/by-util/test_fmt.rs index 7d23cbd52..4fd059080 100644 --- a/tests/by-util/test_fmt.rs +++ b/tests/by-util/test_fmt.rs @@ -48,6 +48,17 @@ fn test_fmt_width_too_big() { } } +#[test] +fn test_fmt_invalid_width() { + for param in ["-w", "--width"] { + new_ucmd!() + .args(&["one-word-per-line.txt", param, "invalid"]) + .fails() + .code_is(1) + .stderr_contains("invalid value 'invalid'"); + } +} + #[ignore] #[test] fn test_fmt_goal() { @@ -70,6 +81,17 @@ fn test_fmt_goal_too_big() { } } +#[test] +fn test_fmt_invalid_goal() { + for param in ["-g", "--goal"] { + new_ucmd!() + .args(&["one-word-per-line.txt", param, "invalid"]) + .fails() + .code_is(1) + .stderr_contains("invalid value 'invalid'"); + } +} + #[test] fn test_fmt_set_goal_not_contain_width() { for param in ["-g", "--goal"] { From a17ede9ef02ca864dc7fcd5bda681e990339b674 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 28 Sep 2023 15:36:06 +0200 Subject: [PATCH 231/370] Remove the full path to test --- fuzz/fuzz_targets/fuzz_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fuzz/fuzz_targets/fuzz_test.rs b/fuzz/fuzz_targets/fuzz_test.rs index 535696b45..dbd2db54a 100644 --- a/fuzz/fuzz_targets/fuzz_test.rs +++ b/fuzz/fuzz_targets/fuzz_test.rs @@ -28,7 +28,7 @@ enum ArgType { // Add any other types as needed } -static CMD_PATH: &str = "/usr/bin/test"; +static CMD_PATH: &str = "test"; fn run_gnu_test(args: &[OsString]) -> Result<(String, i32), std::io::Error> { let mut command = Command::new(CMD_PATH); From e6f9e358d4f3365ea62ef86ddbe5b5b3f71a3dbf Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 28 Sep 2023 21:48:34 +0200 Subject: [PATCH 232/370] fuzz: create a function run_gnu_cmd to deduplicate the code --- fuzz/fuzz_targets/fuzz_common.rs | 30 ++++++++++++++++++++++++++++++ fuzz/fuzz_targets/fuzz_expr.rs | 28 ++-------------------------- fuzz/fuzz_targets/fuzz_test.rs | 20 ++------------------ 3 files changed, 34 insertions(+), 44 deletions(-) diff --git a/fuzz/fuzz_targets/fuzz_common.rs b/fuzz/fuzz_targets/fuzz_common.rs index a33d603f1..351a7e8e8 100644 --- a/fuzz/fuzz_targets/fuzz_common.rs +++ b/fuzz/fuzz_targets/fuzz_common.rs @@ -5,6 +5,7 @@ use libc::{dup, dup2, STDOUT_FILENO}; use std::ffi::OsString; +use std::io; use std::process::Command; use std::sync::atomic::Ordering; use std::sync::{atomic::AtomicBool, Once}; @@ -75,3 +76,32 @@ where (my_output, uumain_exit_status) } + +pub fn run_gnu_cmd( + cmd_path: &str, + args: &[OsString], + check_gnu: bool, +) -> Result<(String, i32), io::Error> { + if check_gnu { + is_gnu_cmd(cmd_path)?; // Check if it's a GNU implementation + } + + let mut command = Command::new(cmd_path); + for arg in args { + command.arg(arg); + } + + let output = command.output()?; + let exit_code = output.status.code().unwrap_or(-1); + if output.status.success() || !check_gnu { + Ok(( + String::from_utf8_lossy(&output.stdout).to_string(), + exit_code, + )) + } else { + Err(io::Error::new( + io::ErrorKind::Other, + format!("GNU command execution failed with exit code {}", exit_code), + )) + } +} diff --git a/fuzz/fuzz_targets/fuzz_expr.rs b/fuzz/fuzz_targets/fuzz_expr.rs index 28fded99e..6344c0525 100644 --- a/fuzz/fuzz_targets/fuzz_expr.rs +++ b/fuzz/fuzz_targets/fuzz_expr.rs @@ -12,35 +12,11 @@ use rand::seq::SliceRandom; use rand::Rng; use std::ffi::OsString; -use std::process::Command; mod fuzz_common; -use crate::fuzz_common::generate_and_run_uumain; -use crate::fuzz_common::is_gnu_cmd; +use crate::fuzz_common::{generate_and_run_uumain, run_gnu_cmd}; static CMD_PATH: &str = "expr"; -fn run_gnu_expr(args: &[OsString]) -> Result<(String, i32), std::io::Error> { - is_gnu_cmd(CMD_PATH)?; // Check if it's a GNU implementation - - let mut command = Command::new(CMD_PATH); - for arg in args { - command.arg(arg); - } - let output = command.output()?; - let exit_code = output.status.code().unwrap_or(-1); - if output.status.success() { - Ok(( - String::from_utf8_lossy(&output.stdout).to_string(), - exit_code, - )) - } else { - Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!("GNU expr execution failed with exit code {}", exit_code), - )) - } -} - fn generate_random_string(max_length: usize) -> String { let mut rng = rand::thread_rng(); let valid_utf8: Vec = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" @@ -111,7 +87,7 @@ fuzz_target!(|_data: &[u8]| { let (rust_output, uumain_exit_code) = generate_and_run_uumain(&mut args, uumain); // Run GNU expr with the provided arguments and compare the output - match run_gnu_expr(&args[1..]) { + match run_gnu_cmd(CMD_PATH, &args[1..], true) { Ok((gnu_output, gnu_exit_code)) => { let gnu_output = gnu_output.trim().to_owned(); if uumain_exit_code != gnu_exit_code { diff --git a/fuzz/fuzz_targets/fuzz_test.rs b/fuzz/fuzz_targets/fuzz_test.rs index dbd2db54a..bfde25246 100644 --- a/fuzz/fuzz_targets/fuzz_test.rs +++ b/fuzz/fuzz_targets/fuzz_test.rs @@ -12,10 +12,8 @@ use rand::seq::SliceRandom; use rand::Rng; use std::ffi::OsString; -use std::process::Command; - mod fuzz_common; -use crate::fuzz_common::generate_and_run_uumain; +use crate::fuzz_common::{generate_and_run_uumain, run_gnu_cmd}; #[derive(PartialEq, Debug, Clone)] enum ArgType { @@ -30,20 +28,6 @@ enum ArgType { static CMD_PATH: &str = "test"; -fn run_gnu_test(args: &[OsString]) -> Result<(String, i32), std::io::Error> { - let mut command = Command::new(CMD_PATH); - - for arg in args { - command.arg(arg); - } - let output = command.output()?; - let exit_status = output.status.code().unwrap_or(-1); // Capture the exit status code - Ok(( - String::from_utf8_lossy(&output.stdout).to_string(), - exit_status, - )) -} - fn generate_random_string(max_length: usize) -> String { let mut rng = rand::thread_rng(); let valid_utf8: Vec = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" @@ -223,7 +207,7 @@ fuzz_target!(|_data: &[u8]| { let (rust_output, uumain_exit_status) = generate_and_run_uumain(&mut args, uumain); // Run GNU test with the provided arguments and compare the output - match run_gnu_test(&args[1..]) { + match run_gnu_cmd(CMD_PATH, &args[1..], false) { Ok((gnu_output, gnu_exit_status)) => { let gnu_output = gnu_output.trim().to_owned(); println!("gnu_exit_status {}", gnu_exit_status); From a576054d42373ee3e502f015ffb998cc232df824 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 28 Sep 2023 21:52:26 +0200 Subject: [PATCH 233/370] fuzz: fix clippy warnings --- fuzz/fuzz_targets/fuzz_common.rs | 4 ++-- fuzz/fuzz_targets/fuzz_date.rs | 2 +- fuzz/fuzz_targets/fuzz_expr.rs | 14 +++++++------- fuzz/fuzz_targets/fuzz_parse_glob.rs | 2 +- fuzz/fuzz_targets/fuzz_test.rs | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fuzz/fuzz_targets/fuzz_common.rs b/fuzz/fuzz_targets/fuzz_common.rs index 351a7e8e8..a94963ef0 100644 --- a/fuzz/fuzz_targets/fuzz_common.rs +++ b/fuzz/fuzz_targets/fuzz_common.rs @@ -32,7 +32,7 @@ pub fn is_gnu_cmd(cmd_path: &str) -> Result<(), std::io::Error> { } } -pub fn generate_and_run_uumain(args: &mut Vec, uumain_function: F) -> (String, i32) +pub fn generate_and_run_uumain(args: &[OsString], uumain_function: F) -> (String, i32) where F: FnOnce(std::vec::IntoIter) -> i32, { @@ -45,7 +45,7 @@ where { unsafe { dup2(pipe_fds[1], STDOUT_FILENO) }; - uumain_exit_status = uumain_function(args.clone().into_iter()); + uumain_exit_status = uumain_function(args.to_owned().into_iter()); unsafe { dup2(original_stdout_fd, STDOUT_FILENO) }; unsafe { libc::close(original_stdout_fd) }; } diff --git a/fuzz/fuzz_targets/fuzz_date.rs b/fuzz/fuzz_targets/fuzz_date.rs index 96c56cc6b..0f9cb262c 100644 --- a/fuzz/fuzz_targets/fuzz_date.rs +++ b/fuzz/fuzz_targets/fuzz_date.rs @@ -9,6 +9,6 @@ fuzz_target!(|data: &[u8]| { let args = data .split(|b| *b == delim) .filter_map(|e| std::str::from_utf8(e).ok()) - .map(|e| OsString::from(e)); + .map(OsString::from); uumain(args); }); diff --git a/fuzz/fuzz_targets/fuzz_expr.rs b/fuzz/fuzz_targets/fuzz_expr.rs index 6344c0525..fb7b17309 100644 --- a/fuzz/fuzz_targets/fuzz_expr.rs +++ b/fuzz/fuzz_targets/fuzz_expr.rs @@ -84,7 +84,7 @@ fuzz_target!(|_data: &[u8]| { let mut args = vec![OsString::from("expr")]; args.extend(expr.split_whitespace().map(OsString::from)); - let (rust_output, uumain_exit_code) = generate_and_run_uumain(&mut args, uumain); + let (rust_output, uumain_exit_code) = generate_and_run_uumain(&args, uumain); // Run GNU expr with the provided arguments and compare the output match run_gnu_cmd(CMD_PATH, &args[1..], true) { @@ -96,16 +96,16 @@ fuzz_target!(|_data: &[u8]| { println!("GNU code: {}", gnu_exit_code); panic!("Different error codes"); } - if rust_output != gnu_output { - println!("Expression: {}", expr); - println!("Rust output: {}", rust_output); - println!("GNU output: {}", gnu_output); - panic!("Different output between Rust & GNU"); - } else { + if rust_output == gnu_output { println!( "Outputs matched for expression: {} => Result: {}", expr, rust_output ); + } else { + println!("Expression: {}", expr); + println!("Rust output: {}", rust_output); + println!("GNU output: {}", gnu_output); + panic!("Different output between Rust & GNU"); } } Err(_) => { diff --git a/fuzz/fuzz_targets/fuzz_parse_glob.rs b/fuzz/fuzz_targets/fuzz_parse_glob.rs index 061569bc4..e235c0c9d 100644 --- a/fuzz/fuzz_targets/fuzz_parse_glob.rs +++ b/fuzz/fuzz_targets/fuzz_parse_glob.rs @@ -5,6 +5,6 @@ use uucore::parse_glob; fuzz_target!(|data: &[u8]| { if let Ok(s) = std::str::from_utf8(data) { - _ = parse_glob::from_str(s) + _ = parse_glob::from_str(s); } }); diff --git a/fuzz/fuzz_targets/fuzz_test.rs b/fuzz/fuzz_targets/fuzz_test.rs index bfde25246..4805a41af 100644 --- a/fuzz/fuzz_targets/fuzz_test.rs +++ b/fuzz/fuzz_targets/fuzz_test.rs @@ -142,7 +142,7 @@ fn generate_test_arg() -> String { 0 => { arg.push_str(&rng.gen_range(-100..=100).to_string()); } - 1 | 2 | 3 => { + 1..=3 => { let test_arg = test_args .choose(&mut rng) .expect("Failed to choose a random test argument"); @@ -204,7 +204,7 @@ fuzz_target!(|_data: &[u8]| { args.push(OsString::from(generate_test_arg())); } - let (rust_output, uumain_exit_status) = generate_and_run_uumain(&mut args, uumain); + let (rust_output, uumain_exit_status) = generate_and_run_uumain(&args, uumain); // Run GNU test with the provided arguments and compare the output match run_gnu_cmd(CMD_PATH, &args[1..], false) { From 55fd1f3617958209180b596c5e75fd017a2b1fb9 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 28 Sep 2023 21:25:38 +0200 Subject: [PATCH 234/370] Replace list of digit by is_ascii_digit and some ride along simplification --- src/uu/chmod/src/chmod.rs | 14 +++++------ src/uu/install/src/mode.rs | 5 +--- src/uu/mkdir/src/mkdir.rs | 36 +++++++++++++---------------- src/uu/mknod/src/parsemode.rs | 3 +-- src/uucore/src/lib/features/mode.rs | 3 +-- 5 files changed, 26 insertions(+), 35 deletions(-) diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index b007bb1d7..31663b1af 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -335,9 +335,7 @@ impl Chmoder { let mut new_mode = fperm; let mut naively_expected_new_mode = new_mode; for mode in cmode_unwrapped.split(',') { - // cmode is guaranteed to be Some in this case - let arr: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; - let result = if mode.contains(arr) { + let result = if mode.chars().any(|c| c.is_ascii_digit()) { mode::parse_numeric(new_mode, mode, file.is_dir()).map(|v| (v, v)) } else { mode::parse_symbolic(new_mode, mode, get_umask(), file.is_dir()).map(|m| { @@ -352,20 +350,22 @@ impl Chmoder { (m, naive_mode) }) }; + match result { Ok((mode, naive_mode)) => { new_mode = mode; naively_expected_new_mode = naive_mode; } Err(f) => { - if self.quiet { - return Err(ExitCode::new(1)); + return if self.quiet { + Err(ExitCode::new(1)) } else { - return Err(USimpleError::new(1, f)); - } + Err(USimpleError::new(1, f)) + }; } } } + self.change_file(fperm, new_mode, file)?; // if a permission would have been removed if umask was 0, but it wasn't because umask was not 0, print an error and fail if (new_mode & !naively_expected_new_mode) != 0 { diff --git a/src/uu/install/src/mode.rs b/src/uu/install/src/mode.rs index f9018e16f..ebdec14af 100644 --- a/src/uu/install/src/mode.rs +++ b/src/uu/install/src/mode.rs @@ -9,10 +9,7 @@ use uucore::mode; /// Takes a user-supplied string and tries to parse to u16 mode bitmask. pub fn parse(mode_string: &str, considering_dir: bool, umask: u32) -> Result { - let numbers: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; - - // Passing 000 as the existing permissions seems to mirror GNU behavior. - if mode_string.contains(numbers) { + if mode_string.chars().any(|c| c.is_ascii_digit()) { mode::parse_numeric(0, mode_string, considering_dir) } else { mode::parse_symbolic(0, mode_string, umask, considering_dir) diff --git a/src/uu/mkdir/src/mkdir.rs b/src/uu/mkdir/src/mkdir.rs index 2044855e4..76aa51f07 100644 --- a/src/uu/mkdir/src/mkdir.rs +++ b/src/uu/mkdir/src/mkdir.rs @@ -38,31 +38,27 @@ fn get_mode(_matches: &ArgMatches, _mode_had_minus_prefix: bool) -> Result Result { - let digits: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; - // Translate a ~str in octal form to u16, default to 777 // Not tested on Windows let mut new_mode = DEFAULT_PERM; - match matches.get_one::(options::MODE) { - Some(m) => { - for mode in m.split(',') { - if mode.contains(digits) { - new_mode = mode::parse_numeric(new_mode, m, true)?; + + if let Some(m) = matches.get_one::(options::MODE) { + for mode in m.split(',') { + if mode.chars().any(|c| c.is_ascii_digit()) { + new_mode = mode::parse_numeric(new_mode, m, true)?; + } else { + let cmode = if mode_had_minus_prefix { + // clap parsing is finished, now put prefix back + format!("-{mode}") } else { - let cmode = if mode_had_minus_prefix { - // clap parsing is finished, now put prefix back - format!("-{mode}") - } else { - mode.to_string() - }; - new_mode = mode::parse_symbolic(new_mode, &cmode, mode::get_umask(), true)?; - } + mode.to_string() + }; + new_mode = mode::parse_symbolic(new_mode, &cmode, mode::get_umask(), true)?; } - Ok(new_mode) - } - None => { - // If no mode argument is specified return the mode derived from umask - Ok(!mode::get_umask() & 0o0777) } + Ok(new_mode) + } else { + // If no mode argument is specified return the mode derived from umask + Ok(!mode::get_umask() & 0o0777) } } diff --git a/src/uu/mknod/src/parsemode.rs b/src/uu/mknod/src/parsemode.rs index adacaa45b..c38800bcb 100644 --- a/src/uu/mknod/src/parsemode.rs +++ b/src/uu/mknod/src/parsemode.rs @@ -11,8 +11,7 @@ use uucore::mode; pub const MODE_RW_UGO: mode_t = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; pub fn parse_mode(mode: &str) -> Result { - let arr: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; - let result = if mode.contains(arr) { + let result = if mode.chars().any(|c| c.is_ascii_digit()) { mode::parse_numeric(MODE_RW_UGO as u32, mode) } else { mode::parse_symbolic(MODE_RW_UGO as u32, mode, true) diff --git a/src/uucore/src/lib/features/mode.rs b/src/uucore/src/lib/features/mode.rs index cbaea71bf..147624891 100644 --- a/src/uucore/src/lib/features/mode.rs +++ b/src/uucore/src/lib/features/mode.rs @@ -147,8 +147,7 @@ pub fn parse_mode(mode: &str) -> Result { #[cfg(any(target_os = "freebsd", target_vendor = "apple", target_os = "android"))] let fperm = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; - let arr: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; - let result = if mode.contains(arr) { + let result = if mode.chars().any(|c| c.is_ascii_digit()) { parse_numeric(fperm, mode, true) } else { parse_symbolic(fperm, mode, get_umask(), true) From 718a527e9be7dbaf15b7369f2b7650e9729a9e93 Mon Sep 17 00:00:00 2001 From: tommady Date: Sat, 30 Sep 2023 07:09:57 +0000 Subject: [PATCH 235/370] add testcase for no preserve mode --- tests/by-util/test_cp.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 1ce74572d..f6d339a7e 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -1550,6 +1550,32 @@ fn test_cp_preserve_links_case_7() { assert!(at.plus("dest").join("g").exists()); } +#[test] +#[cfg(all(unix, not(target_os = "freebsd")))] +fn test_cp_no_preserve_mode_case() { + use libc::umask; + use uucore::fs as uufs; + let (at, mut ucmd) = at_and_ucmd!(); + + at.touch("a"); + at.set_mode("a", 0o731); + unsafe { umask(0o077) }; + + ucmd.arg("-a") + .arg("--no-preserve=mode") + .arg("a") + .arg("b") + .succeeds(); + + assert!(at.file_exists("b")); + + let metadata_b = std::fs::metadata(at.subdir.join("b")).unwrap(); + let permission_b = uufs::display_permissions(&metadata_b, false); + assert_eq!(permission_b, "rw-------".to_string()); + + unsafe { umask(0o022) }; +} + #[test] // For now, disable the test on Windows. Symlinks aren't well support on Windows. // It works on Unix for now and it works locally when run from a powershell From f92066cee2554813aacd5dceac19c5d79b571b0f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 30 Sep 2023 13:25:14 +0000 Subject: [PATCH 236/370] chore(deps): update rust crate regex to 1.9.6 --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c00755198..4dc36c88f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1740,9 +1740,9 @@ checksum = "f1bfbf25d7eb88ddcbb1ec3d755d0634da8f7657b2cb8b74089121409ab8228f" [[package]] name = "regex" -version = "1.9.5" +version = "1.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" dependencies = [ "aho-corasick", "memchr", @@ -1752,9 +1752,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" dependencies = [ "aho-corasick", "memchr", diff --git a/Cargo.toml b/Cargo.toml index a40d066d4..831d4ae48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -310,7 +310,7 @@ rand = { version = "0.8", features = ["small_rng"] } rand_core = "0.6" rayon = "1.8" redox_syscall = "0.4" -regex = "1.9.5" +regex = "1.9.6" rstest = "0.18.2" rust-ini = "0.19.0" same-file = "1.0.6" From 95ccc54d05892db5630e1a9413474041605fe2f0 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 30 Sep 2023 15:35:05 +0200 Subject: [PATCH 237/370] nl: defer showing "line number overflow" error --- src/uu/nl/src/nl.rs | 17 ++++++++++------- tests/by-util/test_nl.rs | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index ea37e00dc..71b4aac28 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -56,14 +56,14 @@ impl Default for Settings { } struct Stats { - line_number: i64, + line_number: Option, consecutive_empty_lines: u64, } impl Stats { fn new(starting_line_number: i64) -> Self { Self { - line_number: starting_line_number, + line_number: Some(starting_line_number), consecutive_empty_lines: 0, } } @@ -344,7 +344,7 @@ fn nl(reader: &mut BufReader, stats: &mut Stats, settings: &Settings if let Some(new_style) = new_numbering_style { current_numbering_style = new_style; if settings.renumber { - stats.line_number = settings.starting_line_number; + stats.line_number = Some(settings.starting_line_number); } println!(); } else { @@ -364,18 +364,21 @@ fn nl(reader: &mut BufReader, stats: &mut Stats, settings: &Settings }; if is_line_numbered { + let Some(line_number) = stats.line_number else { + return Err(USimpleError::new(1, "line number overflow")); + }; println!( "{}{}{}", settings .number_format - .format(stats.line_number, settings.number_width), + .format(line_number, settings.number_width), settings.number_separator, line ); // update line number for the potential next line - match stats.line_number.checked_add(settings.line_increment) { - Some(new_line_number) => stats.line_number = new_line_number, - None => return Err(USimpleError::new(1, "line number overflow")), + match line_number.checked_add(settings.line_increment) { + Some(new_line_number) => stats.line_number = Some(new_line_number), + None => stats.line_number = None, // overflow } } else { let spaces = " ".repeat(settings.number_width + 1); diff --git a/tests/by-util/test_nl.rs b/tests/by-util/test_nl.rs index 87f218166..78c8975a8 100644 --- a/tests/by-util/test_nl.rs +++ b/tests/by-util/test_nl.rs @@ -539,6 +539,22 @@ fn test_line_number_overflow() { .stderr_is("nl: line number overflow\n"); } +#[test] +fn test_line_number_no_overflow() { + new_ucmd!() + .arg(format!("--starting-line-number={}", i64::MAX)) + .pipe_in("a\n\\:\\:\nb") + .succeeds() + .stdout_is(format!("{0}\ta\n\n{0}\tb\n", i64::MAX)); + + new_ucmd!() + .arg(format!("--starting-line-number={}", i64::MIN)) + .arg("--line-increment=-1") + .pipe_in("a\n\\:\\:\nb") + .succeeds() + .stdout_is(format!("{0}\ta\n\n{0}\tb\n", i64::MIN)); +} + #[test] fn test_section_delimiter() { for arg in ["-dabc", "--section-delimiter=abc"] { From 7337cd51691b0345308c1e1c37f2a7d1e1b3390e Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 1 Oct 2023 09:58:09 +0200 Subject: [PATCH 238/370] ls -R1: add a test to replicate GNU's recursive.sh --- tests/by-util/test_ls.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 23dfafa32..7d0f86298 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -1928,6 +1928,35 @@ fn test_ls_recursive() { result.stdout_contains("a\\b:\nb"); } +#[test] +fn test_ls_recursive_1() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.mkdir("x"); + at.mkdir("y"); + at.mkdir("a"); + at.mkdir("b"); + at.mkdir("c"); + at.mkdir("a/1"); + at.mkdir("a/2"); + at.mkdir("a/3"); + at.touch("f"); + at.touch("a/1/I"); + at.touch("a/1/II"); + #[cfg(unix)] + let out = "a:\n1\n2\n3\n\na/1:\nI\nII\n\na/2:\n\na/3:\n\nb:\n\nc:\n"; + #[cfg(windows)] + let out = "a:\n1\n2\n3\n\na\\1:\nI\nII\n\na\\2:\n\na\\3:\n\nb:\n\nc:\n"; + scene + .ucmd() + .arg("-R1") + .arg("a") + .arg("b") + .arg("c") + .succeeds() + .stdout_is(out); +} + #[test] fn test_ls_color() { let scene = TestScenario::new(util_name!()); From c27fcc4084cf0b3de255b16a34071e82e96d67c6 Mon Sep 17 00:00:00 2001 From: Daniel Clarke Date: Sun, 1 Oct 2023 12:01:46 -0400 Subject: [PATCH 239/370] Update parse_datetime to 0.5.0 (#5313) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/uu/date/src/date.rs | 4 +++- src/uu/touch/src/touch.rs | 41 +++++++++++++------------------------ tests/by-util/test_touch.rs | 12 +++++++++++ 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4dc36c88f..98f95032f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1499,9 +1499,9 @@ dependencies = [ [[package]] name = "parse_datetime" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fecceaede7767a9a98058687a321bc91742eff7670167a34104afb30fc8757df" +checksum = "3bbf4e25b13841080e018a1e666358adfe5e39b6d353f986ca5091c210b586a1" dependencies = [ "chrono", "regex", diff --git a/Cargo.toml b/Cargo.toml index 831d4ae48..d6feeb0ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -301,7 +301,7 @@ num-traits = "0.2.16" number_prefix = "0.4" once_cell = "1.18.0" onig = { version = "~6.4", default-features = false } -parse_datetime = "0.4.0" +parse_datetime = "0.5.0" phf = "0.11.2" phf_codegen = "0.11.2" platform-info = "2.0.2" diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index 745fd5423..b5ab8993a 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -166,7 +166,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { }; let date_source = if let Some(date) = matches.get_one::(OPT_DATE) { - if let Ok(duration) = parse_datetime::from_str(date.as_str()) { + let ref_time = Local::now(); + if let Ok(new_time) = parse_datetime::parse_datetime_at_date(ref_time, date.as_str()) { + let duration = new_time.signed_duration_since(ref_time); DateSource::Human(duration) } else { DateSource::Custom(date.into()) diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index 85eb97bc4..6555773ee 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -68,6 +68,10 @@ fn datetime_to_filetime(dt: &DateTime) -> FileTime { FileTime::from_unix_time(dt.timestamp(), dt.timestamp_subsec_nanos()) } +fn filetime_to_datetime(ft: &FileTime) -> Option> { + Some(DateTime::from_timestamp(ft.unix_seconds(), ft.nanoseconds())?.into()) +} + #[uucore::main] #[allow(clippy::cognitive_complexity)] pub fn uumain(args: impl uucore::Args) -> UResult<()> { @@ -88,35 +92,19 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { ) { (Some(reference), Some(date)) => { let (atime, mtime) = stat(Path::new(reference), !matches.get_flag(options::NO_DEREF))?; - if let Ok(offset) = parse_datetime::from_str(date) { - let seconds = offset.num_seconds(); - let nanos = offset.num_nanoseconds().unwrap_or(0) % 1_000_000_000; - - let ref_atime_secs = atime.unix_seconds(); - let ref_atime_nanos = atime.nanoseconds(); - let atime = FileTime::from_unix_time( - ref_atime_secs + seconds, - ref_atime_nanos + nanos as u32, - ); - - let ref_mtime_secs = mtime.unix_seconds(); - let ref_mtime_nanos = mtime.nanoseconds(); - let mtime = FileTime::from_unix_time( - ref_mtime_secs + seconds, - ref_mtime_nanos + nanos as u32, - ); - - (atime, mtime) - } else { - let timestamp = parse_date(date)?; - (timestamp, timestamp) - } + let atime = filetime_to_datetime(&atime).ok_or_else(|| { + USimpleError::new(1, "Could not process the reference access time") + })?; + let mtime = filetime_to_datetime(&mtime).ok_or_else(|| { + USimpleError::new(1, "Could not process the reference modification time") + })?; + (parse_date(atime, date)?, parse_date(mtime, date)?) } (Some(reference), None) => { stat(Path::new(reference), !matches.get_flag(options::NO_DEREF))? } (None, Some(date)) => { - let timestamp = parse_date(date)?; + let timestamp = parse_date(Local::now(), date)?; (timestamp, timestamp) } (None, None) => { @@ -336,7 +324,7 @@ fn stat(path: &Path, follow: bool) -> UResult<(FileTime, FileTime)> { )) } -fn parse_date(s: &str) -> UResult { +fn parse_date(ref_time: DateTime, s: &str) -> UResult { // This isn't actually compatible with GNU touch, but there doesn't seem to // be any simple specification for what format this parameter allows and I'm // not about to implement GNU parse_datetime. @@ -385,8 +373,7 @@ fn parse_date(s: &str) -> UResult { } } - if let Ok(duration) = parse_datetime::from_str(s) { - let dt = Local::now() + duration; + if let Ok(dt) = parse_datetime::parse_datetime_at_date(ref_time, s) { return Ok(datetime_to_filetime(&dt)); } diff --git a/tests/by-util/test_touch.rs b/tests/by-util/test_touch.rs index c9c0d700e..7b659fc51 100644 --- a/tests/by-util/test_touch.rs +++ b/tests/by-util/test_touch.rs @@ -844,3 +844,15 @@ fn test_touch_dash() { ucmd.args(&["-h", "-"]).succeeds().no_stderr().no_stdout(); } + +#[test] +// Chrono panics for now +#[ignore] +fn test_touch_invalid_date_format() { + let (_at, mut ucmd) = at_and_ucmd!(); + let file = "test_touch_invalid_date_format"; + + ucmd.args(&["-m", "-t", "+1000000000000 years", file]) + .fails() + .stderr_contains("touch: invalid date format ‘+1000000000000 years’"); +} From d4220e9bb75a524707474dfca4f3c04f71f1d275 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 20:03:02 +0000 Subject: [PATCH 240/370] chore(deps): update rust crate bytecount to 0.6.4 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 98f95032f..76e1dd72c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,9 +205,9 @@ checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] name = "bytecount" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" +checksum = "ad152d03a2c813c80bb94fedbf3a3f02b28f793e39e7c214c8a0bcc196343de7" [[package]] name = "byteorder" diff --git a/Cargo.toml b/Cargo.toml index d6feeb0ca..c4c3fc2ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -261,7 +261,7 @@ test = ["uu_test"] bigdecimal = "0.4" binary-heap-plus = "0.5.0" bstr = "1.6" -bytecount = "0.6.3" +bytecount = "0.6.4" byteorder = "1.4.3" chrono = { version = "^0.4.31", default-features = false, features = [ "std", From fda762b91cfe1833830583d03668dda6ff0c0e28 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 2 Oct 2023 14:31:41 +0200 Subject: [PATCH 241/370] mv: show no "skipped" msg with -vi/-vin --- src/uu/mv/src/mv.rs | 10 +--------- tests/by-util/test_mv.rs | 5 +++-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 9f7a96618..43f8eb6b6 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -448,19 +448,11 @@ fn rename( match b.overwrite { OverwriteMode::NoClobber => { - let err_msg = if b.verbose { - println!("skipped {}", to.quote()); - String::new() - } else { - format!("not replacing {}", to.quote()) - }; + let err_msg = format!("not replacing {}", to.quote()); return Err(io::Error::new(io::ErrorKind::Other, err_msg)); } OverwriteMode::Interactive => { if !prompt_yes!("overwrite {}?", to.quote()) { - if b.verbose { - println!("skipped {}", to.quote()); - } return Err(io::Error::new(io::ErrorKind::Other, "")); } } diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index eb8a30ac4..0490d4119 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -1350,7 +1350,7 @@ fn test_mv_arg_interactive_skipped() { .ignore_stdin_write_error() .fails() .stderr_is("mv: overwrite 'b'? ") - .stdout_is("skipped 'b'\n"); + .no_stdout(); } #[test] @@ -1360,7 +1360,8 @@ fn test_mv_arg_interactive_skipped_vin() { at.touch("b"); ucmd.args(&["-vin", "a", "b"]) .fails() - .stdout_is("skipped 'b'\n"); + .stderr_is("mv: not replacing 'b'\n") + .no_stdout(); } #[test] From 8ee69d2b92b7cffa54e7118c989b0044d854ce60 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 2 Oct 2023 15:29:13 +0200 Subject: [PATCH 242/370] cp: show no "skipped" msg with -vi/-vin --- src/uu/cp/src/cp.rs | 19 ++++++------------- tests/by-util/test_cp.rs | 6 ++++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index b6270719c..f9f6d8763 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1276,23 +1276,16 @@ fn copy_source( } impl OverwriteMode { - fn verify(&self, path: &Path, verbose: bool) -> CopyResult<()> { + fn verify(&self, path: &Path) -> CopyResult<()> { match *self { Self::NoClobber => { - if verbose { - println!("skipped {}", path.quote()); - } else { - eprintln!("{}: not replacing {}", util_name(), path.quote()); - } + eprintln!("{}: not replacing {}", util_name(), path.quote()); Err(Error::NotAllFilesCopied) } Self::Interactive(_) => { if prompt_yes!("overwrite {}?", path.quote()) { Ok(()) } else { - if verbose { - println!("skipped {}", path.quote()); - } Err(Error::Skipped) } } @@ -1500,7 +1493,7 @@ fn handle_existing_dest( return Err(format!("{} and {} are the same file", source.quote(), dest.quote()).into()); } - options.overwrite.verify(dest, options.verbose)?; + options.overwrite.verify(dest)?; let backup_path = backup_control::get_backup_path(options.backup, dest, &options.backup_suffix); if let Some(backup_path) = backup_path { @@ -1895,7 +1888,7 @@ fn copy_helper( File::create(dest).context(dest.display().to_string())?; } else if source_is_fifo && options.recursive && !options.copy_contents { #[cfg(unix)] - copy_fifo(dest, options.overwrite, options.verbose)?; + copy_fifo(dest, options.overwrite)?; } else if source_is_symlink { copy_link(source, dest, symlinked_files)?; } else { @@ -1920,9 +1913,9 @@ fn copy_helper( // "Copies" a FIFO by creating a new one. This workaround is because Rust's // built-in fs::copy does not handle FIFOs (see rust-lang/rust/issues/79390). #[cfg(unix)] -fn copy_fifo(dest: &Path, overwrite: OverwriteMode, verbose: bool) -> CopyResult<()> { +fn copy_fifo(dest: &Path, overwrite: OverwriteMode) -> CopyResult<()> { if dest.exists() { - overwrite.verify(dest, verbose)?; + overwrite.verify(dest)?; fs::remove_file(dest)?; } diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 1ce74572d..70d4038bd 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -483,7 +483,8 @@ fn test_cp_arg_interactive_verbose() { ucmd.args(&["-vi", "a", "b"]) .pipe_in("N\n") .fails() - .stdout_is("skipped 'b'\n"); + .stderr_is("cp: overwrite 'b'? ") + .no_stdout(); } #[test] @@ -494,7 +495,8 @@ fn test_cp_arg_interactive_verbose_clobber() { at.touch("b"); ucmd.args(&["-vin", "a", "b"]) .fails() - .stdout_is("skipped 'b'\n"); + .stderr_is("cp: not replacing 'b'\n") + .no_stdout(); } #[test] From 9f6a720582f8a373cce9521cfe54610dab06f89c Mon Sep 17 00:00:00 2001 From: Yury Zhytkou <54360928+zhitkoff@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:46:00 -0400 Subject: [PATCH 243/370] Introducing DEVELOPMENT.md (#5209) --- CONTRIBUTING.md | 225 +-------------------------------- DEVELOPMENT.md | 329 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 335 insertions(+), 219 deletions(-) create mode 100644 DEVELOPMENT.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6f67eb828..695e5ad18 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,205 +38,15 @@ CI. However, you can use `#[cfg(...)]` attributes to create platform dependent f VirtualBox and Parallels) for development: -## Tools +## Setting up your development environment -We have an extensive CI that will check your code before it can be merged. This -section explains how to run those checks locally to avoid waiting for the CI. +To setup your local development environment for this project please follow [DEVELOPMENT.md guide](DEVELOPMENT.md) -### pre-commit hooks +It covers [installation of necessary tools and prerequisites](DEVELOPMENT.md#tools) as well as using those tools to [test your code changes locally](DEVELOPMENT.md#testing) -A configuration for `pre-commit` is provided in the repository. It allows -automatically checking every git commit you make to ensure it compiles, and -passes `clippy` and `rustfmt` without warnings. +## Improving the GNU compatibility -To use the provided hook: - -1. [Install `pre-commit`](https://pre-commit.com/#install) -1. Run `pre-commit install` while in the repository directory - -Your git commits will then automatically be checked. If a check fails, an error -message will explain why, and your commit will be canceled. You can then make -the suggested changes, and run `git commit ...` again. - -### clippy - -```shell -cargo clippy --all-targets --all-features -``` - -The `msrv` key in the clippy configuration file `clippy.toml` is used to disable -lints pertaining to newer features by specifying the minimum supported Rust -version (MSRV). - -### rustfmt - -```shell -cargo fmt --all -``` - -### cargo-deny - -This project uses [cargo-deny](https://github.com/EmbarkStudios/cargo-deny/) to -detect duplicate dependencies, checks licenses, etc. To run it locally, first -install it and then run with: - -``` -cargo deny --all-features check all -``` - -### Markdown linter - -We use [markdownlint](https://github.com/DavidAnson/markdownlint) to lint the -Markdown files in the repository. - -### Spell checker - -We use `cspell` as spell checker for all files in the project. If you are using -VS Code, you can install the -[code spell checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) -extension to enable spell checking within your editor. Otherwise, you can -install [cspell](https://cspell.org/) separately. - -If you want to make the spell checker ignore a word, you can add - -```rust -// spell-checker:ignore word_to_ignore -``` - -at the top of the file. - -## Testing - -Testing can be done using either Cargo or `make`. - -### Testing with Cargo - -Just like with building, we follow the standard procedure for testing using -Cargo: - -```shell -cargo test -``` - -By default, `cargo test` only runs the common programs. To run also platform -specific tests, run: - -```shell -cargo test --features unix -``` - -If you would prefer to test a select few utilities: - -```shell -cargo test --features "chmod mv tail" --no-default-features -``` - -If you also want to test the core utilities: - -```shell -cargo test -p uucore -p coreutils -``` - -Or to test the pure Rust tests in the utility itself: - -```shell -cargo test -p uu_ls --lib -``` - -Running the complete test suite might take a while. We use [nextest](https://nexte.st/index.html) in -the CI and you might want to try it out locally. It can speed up the execution time of the whole -test run significantly if the cpu has multiple cores. - -```shell -cargo nextest run --features unix --no-fail-fast -``` - -To debug: - -```shell -gdb --args target/debug/coreutils ls -(gdb) b ls.rs:79 -(gdb) run -``` - -### Testing with GNU Make - -To simply test all available utilities: - -```shell -make test -``` - -To test all but a few of the available utilities: - -```shell -make SKIP_UTILS='UTILITY_1 UTILITY_2' test -``` - -To test only a few of the available utilities: - -```shell -make UTILS='UTILITY_1 UTILITY_2' test -``` - -To include tests for unimplemented behavior: - -```shell -make UTILS='UTILITY_1 UTILITY_2' SPEC=y test -``` - -To run tests with `nextest` just use the nextest target. Note you'll need to -[install](https://nexte.st/book/installation.html) `nextest` first. The `nextest` target accepts the -same arguments like the default `test` target, so it's possible to pass arguments to `nextest run` -via `CARGOFLAGS`: - -```shell -make CARGOFLAGS='--no-fail-fast' UTILS='UTILITY_1 UTILITY_2' nextest -``` - -### Run Busybox Tests - -This testing functionality is only available on *nix operating systems and -requires `make`. - -To run busybox tests for all utilities for which busybox has tests - -```shell -make busytest -``` - -To run busybox tests for a few of the available utilities - -```shell -make UTILS='UTILITY_1 UTILITY_2' busytest -``` - -To pass an argument like "-v" to the busybox test runtime - -```shell -make UTILS='UTILITY_1 UTILITY_2' RUNTEST_ARGS='-v' busytest -``` - -### Comparing with GNU - -To run uutils against the GNU test suite locally, run the following commands: - -```shell -bash util/build-gnu.sh -# Build uutils without release optimizations -UU_MAKE_PROFILE=debug bash util/build-gnu.sh -bash util/run-gnu-test.sh -# To run a single test: -bash util/run-gnu-test.sh tests/touch/not-owner.sh # for example -# To run several tests: -bash util/run-gnu-test.sh tests/touch/not-owner.sh tests/rm/no-give-up.sh # for example -# If this is a perl (.pl) test, to run in debug: -DEBUG=1 bash util/run-gnu-test.sh tests/misc/sm3sum.pl -``` - -Note that it relies on individual utilities (not the multicall binary). - -### Improving the GNU compatibility +Please make sure you have installed [GNU utils and prerequisites](DEVELOPMENT.md#gnu-utils-and-prerequisites) and can execute commands described in [Comparing with GNU](DEVELOPMENT.md#comparing-with-gnu) section of [DEVELOPMENT.md](DEVELOPMENT.md) The Python script `./util/remaining-gnu-error.py` shows the list of failing tests in the CI. @@ -326,30 +136,7 @@ gitignore: add temporary files ## Code coverage - - -Code coverage report can be generated using [grcov](https://github.com/mozilla/grcov). - -### Using Nightly Rust - -To generate [gcov-based](https://github.com/mozilla/grcov#example-how-to-generate-gcda-files-for-a-rust-project) coverage report - -```shell -export CARGO_INCREMENTAL=0 -export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" -export RUSTDOCFLAGS="-Cpanic=abort" -cargo build # e.g., --features feat_os_unix -cargo test # e.g., --features feat_os_unix test_pathchk -grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --ignore build.rs --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?\#\[derive\()" -o ./target/debug/coverage/ -# open target/debug/coverage/index.html in browser -``` - -if changes are not reflected in the report then run `cargo clean` and run the above commands. - -### Using Stable Rust - -If you are using stable version of Rust that doesn't enable code coverage instrumentation by default -then add `-Z-Zinstrument-coverage` flag to `RUSTFLAGS` env variable specified above. +To generate code coverage report locally please follow [Code coverage report](DEVELOPMENT.md#code-coverage-report) section of [DEVELOPMENT.md](DEVELOPMENT.md) ## Other implementations diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 000000000..24a1bdeb5 --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,329 @@ + + +# Setting up your local development environment + +For contributing rules and best practices please refer to [CONTRIBUTING.md](CONTRIBUTING.md) + +## Before you start + +For this guide we assume that you already have GitHub account and have `git` and your favorite code editor or IDE installed and configured. +Before you start working on coreutils, please follow these steps: + +1. Fork the [coreutils repository](https://github.com/uutils/coreutils) to your GitHub account. +***Tip:*** See [this GitHub guide](https://docs.github.com/en/get-started/quickstart/fork-a-repo) for more information on this step. +2. Clone that fork to your local development environment: + +```shell +git clone https://github.com/YOUR-GITHUB-ACCOUNT/coreutils +cd coreutils +``` + +## Tools + +You will need the tools mentioned in this section to build and test your code changes locally. +This section will explain how to install and configure these tools. +We also have an extensive CI that uses these tools and will check your code before it can be merged. +The next section [Testing](#testing) will explain how to run those checks locally to avoid waiting for the CI. + +### Rust toolchain + +[Install Rust](https://www.rust-lang.org/tools/install) + +If you're using rustup to install and manage your Rust toolchains, `clippy` and `rustfmt` are usually already installed. If you are using one of the alternative methods, please make sure to install them manually. See following sub-sections for their usage: [clippy](#clippy) [rustfmt](#rustfmt). + +***Tip*** You might also need to add 'llvm-tools' component if you are going to [generate code coverage reports locally](#code-coverage-report): + +```shell +rustup component add llvm-tools-preview +``` + +### GNU utils and prerequisites + +If you are developing on Linux, most likely you already have all/most GNU utilities and prerequisites installed. + +To make sure, please check GNU coreutils [README-prereq](https://github.com/coreutils/coreutils/blob/master/README-prereq). + +You will need these to [run uutils against the GNU test suite locally](#comparing-with-gnu). + +For MacOS and Windows platform specific setup please check [MacOS GNU utils](#macos-gnu-utils) and [Windows GNU utils](#windows-gnu-utils) sections respectfully. + +### pre-commit hooks + +A configuration for `pre-commit` is provided in the repository. It allows +automatically checking every git commit you make to ensure it compiles, and +passes `clippy` and `rustfmt` without warnings. + +To use the provided hook: + +1. [Install `pre-commit`](https://pre-commit.com/#install) +1. Run `pre-commit install` while in the repository directory + +Your git commits will then automatically be checked. If a check fails, an error +message will explain why, and your commit will be canceled. You can then make +the suggested changes, and run `git commit ...` again. + +**NOTE: On MacOS** the pre-commit hooks are currently broken. There are workarounds involving switching to unstable nightly Rust and components. + +### clippy + +```shell +cargo clippy --all-targets --all-features +``` + +The `msrv` key in the clippy configuration file `clippy.toml` is used to disable +lints pertaining to newer features by specifying the minimum supported Rust +version (MSRV). + +### rustfmt + +```shell +cargo fmt --all +``` + +### cargo-deny + +This project uses [cargo-deny](https://github.com/EmbarkStudios/cargo-deny/) to +detect duplicate dependencies, checks licenses, etc. To run it locally, first +install it and then run with: + +```shell +cargo deny --all-features check all +``` + +### Markdown linter + +We use [markdownlint](https://github.com/DavidAnson/markdownlint) to lint the +Markdown files in the repository. + +### Spell checker + +We use `cspell` as spell checker for all files in the project. If you are using +VS Code, you can install the +[code spell checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) +extension to enable spell checking within your editor. Otherwise, you can +install [cspell](https://cspell.org/) separately. + +If you want to make the spell checker ignore a word, you can add + +```rust +// spell-checker:ignore word_to_ignore +``` + +at the top of the file. + +## Testing + +This section explains how to run our CI checks locally. +Testing can be done using either Cargo or `make`. + +### Testing with Cargo + +Just like with building, we follow the standard procedure for testing using +Cargo: + +```shell +cargo test +``` + +By default, `cargo test` only runs the common programs. To run also platform +specific tests, run: + +```shell +cargo test --features unix +``` + +If you would prefer to test a select few utilities: + +```shell +cargo test --features "chmod mv tail" --no-default-features +``` + +If you also want to test the core utilities: + +```shell +cargo test -p uucore -p coreutils +``` + +Running the complete test suite might take a while. We use [nextest](https://nexte.st/index.html) in +the CI and you might want to try it out locally. It can speed up the execution time of the whole +test run significantly if the cpu has multiple cores. + +```shell +cargo nextest run --features unix --no-fail-fast +``` + +To debug: + +```shell +gdb --args target/debug/coreutils ls +(gdb) b ls.rs:79 +(gdb) run +``` + +### Testing with GNU Make + +To simply test all available utilities: + +```shell +make test +``` + +To test all but a few of the available utilities: + +```shell +make SKIP_UTILS='UTILITY_1 UTILITY_2' test +``` + +To test only a few of the available utilities: + +```shell +make UTILS='UTILITY_1 UTILITY_2' test +``` + +To include tests for unimplemented behavior: + +```shell +make UTILS='UTILITY_1 UTILITY_2' SPEC=y test +``` + +To run tests with `nextest` just use the nextest target. Note you'll need to +[install](https://nexte.st/book/installation.html) `nextest` first. The `nextest` target accepts the +same arguments like the default `test` target, so it's possible to pass arguments to `nextest run` +via `CARGOFLAGS`: + +```shell +make CARGOFLAGS='--no-fail-fast' UTILS='UTILITY_1 UTILITY_2' nextest +``` + +### Run Busybox Tests + +This testing functionality is only available on *nix operating systems and +requires `make`. + +To run busybox tests for all utilities for which busybox has tests + +```shell +make busytest +``` + +To run busybox tests for a few of the available utilities + +```shell +make UTILS='UTILITY_1 UTILITY_2' busytest +``` + +To pass an argument like "-v" to the busybox test runtime + +```shell +make UTILS='UTILITY_1 UTILITY_2' RUNTEST_ARGS='-v' busytest +``` + +### Comparing with GNU + +To run uutils against the GNU test suite locally, run the following commands: + +```shell +bash util/build-gnu.sh +# Build uutils without release optimizations +UU_MAKE_PROFILE=debug bash util/build-gnu.sh +bash util/run-gnu-test.sh +# To run a single test: +bash util/run-gnu-test.sh tests/touch/not-owner.sh # for example +# To run several tests: +bash util/run-gnu-test.sh tests/touch/not-owner.sh tests/rm/no-give-up.sh # for example +# If this is a perl (.pl) test, to run in debug: +DEBUG=1 bash util/run-gnu-test.sh tests/misc/sm3sum.pl +``` + +***Tip:*** First time you run `bash util/build-gnu.sh` command, it will provide instructions on how to checkout GNU coreutils repository at the correct release tag. Please follow those instructions and when done, run `bash util/build-gnu.sh` command again. + +Note that GNU test suite relies on individual utilities (not the multicall binary). + +## Code coverage report + +Code coverage report can be generated using [grcov](https://github.com/mozilla/grcov). + +### Using Nightly Rust + +To generate [gcov-based](https://github.com/mozilla/grcov#example-how-to-generate-gcda-files-for-a-rust-project) coverage report + +```shell +export CARGO_INCREMENTAL=0 +export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" +export RUSTDOCFLAGS="-Cpanic=abort" +cargo build # e.g., --features feat_os_unix +cargo test # e.g., --features feat_os_unix test_pathchk +grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --ignore build.rs --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?\#\[derive\()" -o ./target/debug/coverage/ +# open target/debug/coverage/index.html in browser +``` + +if changes are not reflected in the report then run `cargo clean` and run the above commands. + +### Using Stable Rust + +If you are using stable version of Rust that doesn't enable code coverage instrumentation by default +then add `-Z-Zinstrument-coverage` flag to `RUSTFLAGS` env variable specified above. + +## Tips for setting up on Mac + +### C Compiler and linker + +On MacOS you'll need to install C compiler & linker: + +```shell +xcode-select --install +``` + +### MacOS GNU utils + +On MacOS you will need to install [Homebrew](https://docs.brew.sh/Installation) and use it to install the following Homebrew formulas: + +```shell +brew install \ + coreutils \ + autoconf \ + gettext \ + wget \ + texinfo \ + xz \ + automake \ + gnu-sed \ + m4 \ + bison \ + pre-commit \ + findutils +``` + +After installing these Homebrew formulas, please make sure to add the following lines to your `zsh` or `bash` rc file, i.e. `~/.profile` or `~/.zshrc` or `~/.bashrc` ... +(assuming Homebrew is installed at default location `/opt/homebrew`): + +```shell +eval "$(/opt/homebrew/bin/brew shellenv)" +export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH" +export PATH="/opt/homebrew/opt/bison/bin:$PATH" +export PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH" +``` + +Last step is to link Homebrew coreutils version of `timeout` to `/usr/local/bin` (as admin user): + +```shell +sudo ln -s /opt/homebrew/bin/timeout /usr/local/bin/timeout +``` + +Do not forget to either source updated rc file or restart you terminal session to update environment variables. + +## Tips for setting up on Windows + +### MSVC build tools + +On Windows you'll need the MSVC build tools for Visual Studio 2013 or later. + +If you are using `rustup-init.exe` to install Rust toolchain, it will guide you through the process of downloading and installing these prerequisites. + +Otherwise please follow [this guide](https://learn.microsoft.com/en-us/windows/dev-environment/rust/setup). + +### Windows GNU utils + +If you have used [Git for Windows](https://gitforwindows.org) to install `git` on you Windows system you might already have some GNU core utilities installed as part of "GNU Bash" included in Git for Windows package, but it is not a complete package. [This article](https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058) provides instruction on how to add more to it. + +Alternatively you can install [Cygwin](https://www.cygwin.com) and/or use [WSL2](https://learn.microsoft.com/en-us/windows/wsl/compare-versions#whats-new-in-wsl-2) to get access to all GNU core utilities on Windows. From c5a0aa92f8b31741e2be6128fbb9c5f29d22ec69 Mon Sep 17 00:00:00 2001 From: Yury Zhytkou <54360928+zhitkoff@users.noreply.github.com> Date: Mon, 2 Oct 2023 18:42:46 -0400 Subject: [PATCH 244/370] split: implementing separator option (#5331) * split: implementing separator option * split: separator option - handle multiple update * split: style * split: separator tests * split: separator tests - stdin in ci/cd * split: tests - ci/cd stdin errors * split: refactor based on feedback * split: improve test coverage * split: fix broken pipe error in tests with stdin * split: fix for handle_multiple_separator_options * split: comments * split: refactor separator code * split: changes based on feedback * split: changes based on feedback --- src/uu/split/split.md | 13 + src/uu/split/src/split.rs | 133 ++++++++--- tests/by-util/test_split.rs | 239 +++++++++++++++++++ tests/fixtures/split/separator_nul.txt | Bin 0 -> 10 bytes tests/fixtures/split/separator_semicolon.txt | 1 + 5 files changed, 348 insertions(+), 38 deletions(-) create mode 100644 tests/fixtures/split/separator_nul.txt create mode 100644 tests/fixtures/split/separator_semicolon.txt diff --git a/src/uu/split/split.md b/src/uu/split/split.md index d3a481fd3..836e3a0c6 100644 --- a/src/uu/split/split.md +++ b/src/uu/split/split.md @@ -11,3 +11,16 @@ Create output files containing consecutive or interleaved sections of input ## After Help Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default size is 1000, and default PREFIX is 'x'. With no INPUT, or when INPUT is -, read standard input. + +The SIZE argument is an integer and optional unit (example: 10K is 10*1024). +Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024) or KB,MB,... (powers of 1000). +Binary prefixes can be used, too: KiB=K, MiB=M, and so on. + +CHUNKS may be: + +- N split into N files based on size of input +- K/N output Kth of N to stdout +- l/N split into N files without splitting lines/records +- l/K/N output Kth of N to stdout without splitting lines/records +- r/N like 'l' but use round robin distribution +- r/K/N likewise but only output Kth of N to stdout diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index a61c0e812..756248539 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -11,7 +11,7 @@ mod platform; use crate::filenames::FilenameIterator; use crate::filenames::SuffixType; -use clap::{crate_version, parser::ValueSource, Arg, ArgAction, ArgMatches, Command}; +use clap::{crate_version, parser::ValueSource, Arg, ArgAction, ArgMatches, Command, ValueHint}; use std::env; use std::ffi::OsString; use std::fmt; @@ -39,6 +39,7 @@ static OPT_HEX_SUFFIXES_SHORT: &str = "-x"; static OPT_SUFFIX_LENGTH: &str = "suffix-length"; static OPT_DEFAULT_SUFFIX_LENGTH: &str = "0"; static OPT_VERBOSE: &str = "verbose"; +static OPT_SEPARATOR: &str = "separator"; //The ---io and ---io-blksize parameters are consumed and ignored. //The parameter is included to make GNU coreutils tests pass. static OPT_IO: &str = "-io"; @@ -55,7 +56,6 @@ const AFTER_HELP: &str = help_section!("after help", "split.md"); #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let (args, obs_lines) = handle_obsolete(args); - let matches = uu_app().try_get_matches_from(args)?; match Settings::from(&matches, &obs_lines) { @@ -145,6 +145,7 @@ fn should_extract_obs_lines( && !slice.starts_with("-C") && !slice.starts_with("-l") && !slice.starts_with("-n") + && !slice.starts_with("-t") } /// Helper function to [`filter_args`] @@ -208,13 +209,18 @@ fn handle_preceding_options( || &slice[2..] == OPT_ADDITIONAL_SUFFIX || &slice[2..] == OPT_FILTER || &slice[2..] == OPT_NUMBER - || &slice[2..] == OPT_SUFFIX_LENGTH; + || &slice[2..] == OPT_SUFFIX_LENGTH + || &slice[2..] == OPT_SEPARATOR; } // capture if current slice is a preceding short option that requires value and does not have value in the same slice (value separated by whitespace) // following slice should be treaded as value for this option // even if it starts with '-' (which would be treated as hyphen prefixed value) - *preceding_short_opt_req_value = - slice == "-b" || slice == "-C" || slice == "-l" || slice == "-n" || slice == "-a"; + *preceding_short_opt_req_value = slice == "-b" + || slice == "-C" + || slice == "-l" + || slice == "-n" + || slice == "-a" + || slice == "-t"; // slice is a value // reset preceding option flags if !slice.starts_with('-') { @@ -278,7 +284,7 @@ pub fn uu_app() -> Command { .long(OPT_FILTER) .allow_hyphen_values(true) .value_name("COMMAND") - .value_hint(clap::ValueHint::CommandName) + .value_hint(ValueHint::CommandName) .help( "write to shell COMMAND; file name is $FILE (Currently not implemented for Windows)", ), @@ -293,7 +299,7 @@ pub fn uu_app() -> Command { .arg( Arg::new(OPT_NUMERIC_SUFFIXES_SHORT) .short('d') - .action(clap::ArgAction::SetTrue) + .action(ArgAction::SetTrue) .overrides_with_all([ OPT_NUMERIC_SUFFIXES, OPT_NUMERIC_SUFFIXES_SHORT, @@ -314,12 +320,13 @@ pub fn uu_app() -> Command { OPT_HEX_SUFFIXES, OPT_HEX_SUFFIXES_SHORT ]) + .value_name("FROM") .help("same as -d, but allow setting the start value"), ) .arg( Arg::new(OPT_HEX_SUFFIXES_SHORT) .short('x') - .action(clap::ArgAction::SetTrue) + .action(ArgAction::SetTrue) .overrides_with_all([ OPT_NUMERIC_SUFFIXES, OPT_NUMERIC_SUFFIXES_SHORT, @@ -340,6 +347,7 @@ pub fn uu_app() -> Command { OPT_HEX_SUFFIXES, OPT_HEX_SUFFIXES_SHORT ]) + .value_name("FROM") .help("same as -x, but allow setting the start value"), ) .arg( @@ -357,6 +365,15 @@ pub fn uu_app() -> Command { .help("print a diagnostic just before each output file is opened") .action(ArgAction::SetTrue), ) + .arg( + Arg::new(OPT_SEPARATOR) + .short('t') + .long(OPT_SEPARATOR) + .allow_hyphen_values(true) + .value_name("SEP") + .action(ArgAction::Append) + .help("use SEP instead of newline as the record separator; '\0' (zero) specifies the NUL character"), + ) .arg( Arg::new(OPT_IO) .long("io") @@ -372,7 +389,7 @@ pub fn uu_app() -> Command { .arg( Arg::new(ARG_INPUT) .default_value("-") - .value_hint(clap::ValueHint::FilePath), + .value_hint(ValueHint::FilePath), ) .arg( Arg::new(ARG_PREFIX) @@ -696,6 +713,7 @@ struct Settings { filter: Option, strategy: Strategy, verbose: bool, + separator: u8, /// Whether to *not* produce empty files when using `-n`. /// @@ -722,6 +740,12 @@ enum SettingsError { /// Suffix is not large enough to split into specified chunks SuffixTooSmall(usize), + /// Multi-character (Invalid) separator + MultiCharacterSeparator(String), + + /// Multiple different separator characters + MultipleSeparatorCharacters, + /// The `--filter` option is not supported on Windows. #[cfg(windows)] NotSupported, @@ -743,6 +767,12 @@ impl fmt::Display for SettingsError { Self::Strategy(e) => e.fmt(f), Self::SuffixNotParsable(s) => write!(f, "invalid suffix length: {}", s.quote()), Self::SuffixTooSmall(i) => write!(f, "the suffix length needs to be at least {i}"), + Self::MultiCharacterSeparator(s) => { + write!(f, "multi-character separator {}", s.quote()) + } + Self::MultipleSeparatorCharacters => { + write!(f, "multiple separator characters specified") + } Self::SuffixContainsSeparator(s) => write!( f, "invalid suffix {}, contains directory separator", @@ -783,6 +813,26 @@ impl Settings { } } } + + // Make sure that separator is only one UTF8 character (if specified) + // defaults to '\n' - newline character + // If the same separator (the same value) was used multiple times - `split` should NOT fail + // If the separator was used multiple times but with different values (not all values are the same) - `split` should fail + let separator = match matches.get_many::(OPT_SEPARATOR) { + Some(mut sep_values) => { + let first = sep_values.next().unwrap(); // it is safe to just unwrap here since Clap should not return empty ValuesRef<'_,String> in the option from get_many() call + if !sep_values.all(|s| s == first) { + return Err(SettingsError::MultipleSeparatorCharacters); + } + match first.as_str() { + "\\0" => b'\0', + s if s.as_bytes().len() == 1 => s.as_bytes()[0], + s => return Err(SettingsError::MultiCharacterSeparator(s.to_owned())), + } + } + None => b'\n', + }; + let result = Self { suffix_length: suffix_length_str .parse() @@ -791,6 +841,7 @@ impl Settings { suffix_start, additional_suffix, verbose: matches.value_source("verbose") == Some(ValueSource::CommandLine), + separator, strategy, input: matches.get_one::(ARG_INPUT).unwrap().to_owned(), prefix: matches.get_one::(ARG_PREFIX).unwrap().to_owned(), @@ -1019,7 +1070,8 @@ impl<'a> Write for LineChunkWriter<'a> { // corresponds to the current chunk number. let mut prev = 0; let mut total_bytes_written = 0; - for i in memchr::memchr_iter(b'\n', buf) { + let sep = self.settings.separator; + for i in memchr::memchr_iter(sep, buf) { // If we have exceeded the number of lines to write in the // current chunk, then start a new chunk and its // corresponding writer. @@ -1036,8 +1088,8 @@ impl<'a> Write for LineChunkWriter<'a> { } // Write the line, starting from *after* the previous - // newline character and ending *after* the current - // newline character. + // separator character and ending *after* the current + // separator character. let n = self.inner.write(&buf[prev..i + 1])?; total_bytes_written += n; prev = i + 1; @@ -1175,21 +1227,22 @@ impl<'a> Write for LineBytesChunkWriter<'a> { self.num_bytes_remaining_in_current_chunk = self.chunk_size.try_into().unwrap(); } - // Find the first newline character in the buffer. - match memchr::memchr(b'\n', buf) { - // If there is no newline character and the buffer is + // Find the first separator (default - newline character) in the buffer. + let sep = self.settings.separator; + match memchr::memchr(sep, buf) { + // If there is no separator 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. None => { let end = self.num_bytes_remaining_in_current_chunk; // This is ugly but here to match GNU behavior. If the input - // doesn't end with a \n, pretend that it does for handling + // doesn't end with a separator, pretend that it does for handling // the second to last segment chunk. See `line-bytes.sh`. if end == buf.len() && self.num_bytes_remaining_in_current_chunk < self.chunk_size.try_into().unwrap() - && buf[buf.len() - 1] != b'\n' + && buf[buf.len() - 1] != sep { self.num_bytes_remaining_in_current_chunk = 0; } else { @@ -1200,8 +1253,8 @@ impl<'a> Write for LineBytesChunkWriter<'a> { } } - // If there is a newline character and the line - // (including the newline character) will fit in the + // If there is a separator character and the line + // (including the separator character) will fit in the // current chunk, then write the entire line and // continue to the next iteration. (See chunk 1 in the // example comment above.) @@ -1212,8 +1265,8 @@ impl<'a> Write for LineBytesChunkWriter<'a> { buf = &buf[num_bytes_written..]; } - // If there is a newline character, the line - // (including the newline character) will not fit in + // If there is a separator character, the line + // (including the separator character) will not fit in // the current chunk, *and* no other lines have been // written to the current chunk, then write as many // bytes as we can and continue to the next @@ -1230,8 +1283,8 @@ impl<'a> Write for LineBytesChunkWriter<'a> { buf = &buf[num_bytes_written..]; } - // If there is a newline character, the line - // (including the newline character) will not fit in + // If there is a separator character, the line + // (including the separator character) will not fit in // the current chunk, and at least one other line has // been written to the current chunk, then signal to // the next iteration that a new chunk needs to be @@ -1489,15 +1542,16 @@ where let mut num_bytes_remaining_in_current_chunk = chunk_size; let mut i = 0; - for line_result in reader.lines() { + let sep = settings.separator; + for line_result in reader.split(sep) { let line = line_result.unwrap(); let maybe_writer = writers.get_mut(i); let writer = maybe_writer.unwrap(); - let bytes = line.as_bytes(); + let bytes = line.as_slice(); writer.write_all(bytes)?; - writer.write_all(b"\n")?; + writer.write_all(&[sep])?; - // Add one byte for the newline character. + // Add one byte for the separator character. let num_bytes = bytes.len() + 1; if num_bytes > num_bytes_remaining_in_current_chunk { num_bytes_remaining_in_current_chunk = chunk_size; @@ -1546,15 +1600,16 @@ where let mut num_bytes_remaining_in_current_chunk = chunk_size; let mut i = 0; - for line_result in reader.lines() { + let sep = settings.separator; + for line_result in reader.split(sep) { let line = line_result?; - let bytes = line.as_bytes(); + let bytes = line.as_slice(); if i == chunk_number { writer.write_all(bytes)?; - writer.write_all(b"\n")?; + writer.write_all(&[sep])?; } - // Add one byte for the newline character. + // Add one byte for the separator character. let num_bytes = bytes.len() + 1; if num_bytes >= num_bytes_remaining_in_current_chunk { num_bytes_remaining_in_current_chunk = chunk_size; @@ -1601,13 +1656,14 @@ where } let num_chunks: usize = num_chunks.try_into().unwrap(); - for (i, line_result) in reader.lines().enumerate() { + let sep = settings.separator; + for (i, line_result) in reader.split(sep).enumerate() { let line = line_result.unwrap(); let maybe_writer = writers.get_mut(i % num_chunks); let writer = maybe_writer.unwrap(); - let bytes = line.as_bytes(); + let bytes = line.as_slice(); writer.write_all(bytes)?; - writer.write_all(b"\n")?; + writer.write_all(&[sep])?; } Ok(()) @@ -1632,7 +1688,7 @@ where /// * [`split_into_n_chunks_by_line_round_robin`], which splits its input in the /// same way, but writes each chunk to its own file. fn kth_chunk_by_line_round_robin( - _settings: &Settings, + settings: &Settings, reader: &mut R, chunk_number: u64, num_chunks: u64, @@ -1646,12 +1702,13 @@ where let num_chunks: usize = num_chunks.try_into().unwrap(); let chunk_number: usize = chunk_number.try_into().unwrap(); - for (i, line_result) in reader.lines().enumerate() { + let sep = settings.separator; + for (i, line_result) in reader.split(sep).enumerate() { let line = line_result?; - let bytes = line.as_bytes(); + let bytes = line.as_slice(); if (i % num_chunks) == chunk_number { writer.write_all(bytes)?; - writer.write_all(b"\n")?; + writer.write_all(&[sep])?; } } Ok(()) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 7c6d271e6..6fc3a3706 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -1483,3 +1483,242 @@ fn test_split_non_utf8_argument_windows() { .fails() .stderr_contains("error: invalid UTF-8 was detected in one or more arguments"); } + +// Test '--separator' / '-t' option following GNU tests example +// test separators: '\n' , '\0' , ';' +// test with '--lines=2' , '--line-bytes=4' , '--number=l/3' , '--number=r/3' , '--number=l/1/3' , '--number=r/1/3' +#[test] +fn test_split_separator_nl_lines() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--lines=2", "-t", "\n"]) + .pipe_in("1\n2\n3\n4\n5\n") + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1\n2\n"); + assert_eq!(file_read(&at, "xab"), "3\n4\n"); + assert_eq!(file_read(&at, "xac"), "5\n"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_nl_line_bytes() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--line-bytes=4", "-t", "\n"]) + .pipe_in("1\n2\n3\n4\n5\n") + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1\n2\n"); + assert_eq!(file_read(&at, "xab"), "3\n4\n"); + assert_eq!(file_read(&at, "xac"), "5\n"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_nl_number_l() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--number=l/3", "--separator=\n", "fivelines.txt"]) + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1\n2\n"); + assert_eq!(file_read(&at, "xab"), "3\n4\n"); + assert_eq!(file_read(&at, "xac"), "5\n"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_nl_number_r() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--number=r/3", "--separator", "\n", "fivelines.txt"]) + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1\n4\n"); + assert_eq!(file_read(&at, "xab"), "2\n5\n"); + assert_eq!(file_read(&at, "xac"), "3\n"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_nul_lines() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--lines=2", "-t", "\\0", "separator_nul.txt"]) + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1\02\0"); + assert_eq!(file_read(&at, "xab"), "3\04\0"); + assert_eq!(file_read(&at, "xac"), "5\0"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_nul_line_bytes() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--line-bytes=4", "-t", "\\0", "separator_nul.txt"]) + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1\02\0"); + assert_eq!(file_read(&at, "xab"), "3\04\0"); + assert_eq!(file_read(&at, "xac"), "5\0"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_nul_number_l() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--number=l/3", "--separator=\\0", "separator_nul.txt"]) + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1\02\0"); + assert_eq!(file_read(&at, "xab"), "3\04\0"); + assert_eq!(file_read(&at, "xac"), "5\0"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_nul_number_r() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--number=r/3", "--separator=\\0", "separator_nul.txt"]) + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1\04\0"); + assert_eq!(file_read(&at, "xab"), "2\05\0"); + assert_eq!(file_read(&at, "xac"), "3\0"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_semicolon_lines() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--lines=2", "-t", ";", "separator_semicolon.txt"]) + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1;2;"); + assert_eq!(file_read(&at, "xab"), "3;4;"); + assert_eq!(file_read(&at, "xac"), "5;"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_semicolon_line_bytes() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--line-bytes=4", "-t", ";", "separator_semicolon.txt"]) + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1;2;"); + assert_eq!(file_read(&at, "xab"), "3;4;"); + assert_eq!(file_read(&at, "xac"), "5;"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_semicolon_number_l() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--number=l/3", "--separator=;", "separator_semicolon.txt"]) + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1;2;"); + assert_eq!(file_read(&at, "xab"), "3;4;"); + assert_eq!(file_read(&at, "xac"), "5;"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_semicolon_number_r() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["--number=r/3", "--separator=;", "separator_semicolon.txt"]) + .succeeds(); + + assert_eq!(file_read(&at, "xaa"), "1;4;"); + assert_eq!(file_read(&at, "xab"), "2;5;"); + assert_eq!(file_read(&at, "xac"), "3;"); + assert!(!at.plus("xad").exists()); +} + +#[test] +fn test_split_separator_semicolon_number_kth_l() { + new_ucmd!() + .args(&[ + "--number=l/1/3", + "--separator", + ";", + "separator_semicolon.txt", + ]) + .succeeds() + .stdout_only("1;2;"); +} + +#[test] +fn test_split_separator_semicolon_number_kth_r() { + new_ucmd!() + .args(&[ + "--number=r/1/3", + "--separator", + ";", + "separator_semicolon.txt", + ]) + .succeeds() + .stdout_only("1;4;"); +} + +// Test error edge cases for separator option +#[test] +fn test_split_separator_no_value() { + new_ucmd!() + .args(&["-t"]) + .ignore_stdin_write_error() + .pipe_in("a\n") + .fails() + .stderr_contains( + "error: a value is required for '--separator ' but none was supplied", + ); +} + +#[test] +fn test_split_separator_invalid_usage() { + let scene = TestScenario::new(util_name!()); + scene + .ucmd() + .args(&["--separator=xx"]) + .ignore_stdin_write_error() + .pipe_in("a\n") + .fails() + .no_stdout() + .stderr_contains("split: multi-character separator 'xx'"); + scene + .ucmd() + .args(&["-ta", "-tb"]) + .ignore_stdin_write_error() + .pipe_in("a\n") + .fails() + .no_stdout() + .stderr_contains("split: multiple separator characters specified"); + scene + .ucmd() + .args(&["-t'\n'", "-tb"]) + .ignore_stdin_write_error() + .pipe_in("a\n") + .fails() + .no_stdout() + .stderr_contains("split: multiple separator characters specified"); +} + +// Test using same separator multiple times +#[test] +fn test_split_separator_same_multiple() { + let scene = TestScenario::new(util_name!()); + scene + .ucmd() + .args(&["--separator=:", "--separator=:", "fivelines.txt"]) + .succeeds(); + scene + .ucmd() + .args(&["-t:", "--separator=:", "fivelines.txt"]) + .succeeds(); + scene + .ucmd() + .args(&["-t", ":", "-t", ":", "fivelines.txt"]) + .succeeds(); + scene + .ucmd() + .args(&["-t:", "-t:", "-t,", "fivelines.txt"]) + .fails(); +} diff --git a/tests/fixtures/split/separator_nul.txt b/tests/fixtures/split/separator_nul.txt new file mode 100644 index 0000000000000000000000000000000000000000..c4c49609dbd79d27ec1457c489741e63995dc080 GIT binary patch literal 10 RcmXqHFk&!fFkvud000H>0RR91 literal 0 HcmV?d00001 diff --git a/tests/fixtures/split/separator_semicolon.txt b/tests/fixtures/split/separator_semicolon.txt new file mode 100644 index 000000000..a8396d8ee --- /dev/null +++ b/tests/fixtures/split/separator_semicolon.txt @@ -0,0 +1 @@ +1;2;3;4;5; \ No newline at end of file From 252d01ac33b2eb4fdd0640a07840d0ef3318f886 Mon Sep 17 00:00:00 2001 From: PGIII Date: Mon, 2 Oct 2023 18:48:22 -0400 Subject: [PATCH 245/370] cp: fail when trying to copy to read only file on mac (#5261) * cp: fail when trying to copy to read only file * fix spelling error in macos.rs * simplify permissions check * add comment * fix typo --- src/uu/cp/src/platform/macos.rs | 11 +++++++++-- tests/by-util/test_cp.rs | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/uu/cp/src/platform/macos.rs b/src/uu/cp/src/platform/macos.rs index 8c62c78d9..77bdbbbdb 100644 --- a/src/uu/cp/src/platform/macos.rs +++ b/src/uu/cp/src/platform/macos.rs @@ -63,8 +63,15 @@ pub(crate) fn copy_on_write( { // clonefile(2) fails if the destination exists. Remove it and try again. Do not // bother to check if removal worked because we're going to try to clone again. - let _ = fs::remove_file(dest); - error = pfn(src.as_ptr(), dst.as_ptr(), 0); + // first lets make sure the dest file is not read only + if fs::metadata(dest).map_or(false, |md| !md.permissions().readonly()) { + // remove and copy again + // TODO: rewrite this to better match linux behavior + // linux first opens the source file and destination file then uses the file + // descriptors to do the clone. + let _ = fs::remove_file(dest); + error = pfn(src.as_ptr(), dst.as_ptr(), 0); + } } } } diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 1ce74572d..fe56d1160 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -3440,3 +3440,19 @@ fn test_cp_only_source_no_target() { panic!("Failure: stderr was \n{stderr_str}"); } } + +#[test] +fn test_cp_dest_no_permissions() { + let ts = TestScenario::new(util_name!()); + let at = &ts.fixtures; + + at.touch("valid.txt"); + at.touch("invalid_perms.txt"); + at.set_readonly("invalid_perms.txt"); + + ts.ucmd() + .args(&["valid.txt", "invalid_perms.txt"]) + .fails() + .stderr_contains("invalid_perms.txt") + .stderr_contains("denied"); +} From a107374c8286796b170fbabbd65a6a28656a7415 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Tue, 3 Oct 2023 12:10:20 +0200 Subject: [PATCH 246/370] echo: use controlflow instead of bool --- src/uu/echo/src/echo.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index 5ccc6a32a..947887210 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -6,6 +6,7 @@ use clap::{crate_version, Arg, ArgAction, Command}; use std::io::{self, Write}; use std::iter::Peekable; +use std::ops::ControlFlow; use std::str::Chars; use uucore::error::{FromIo, UResult}; use uucore::{format_usage, help_about, help_section, help_usage}; @@ -62,7 +63,7 @@ fn parse_code(input: &mut Peekable, base: Base) -> Option { Some(ret.into()) } -fn print_escaped(input: &str, mut output: impl Write) -> io::Result { +fn print_escaped(input: &str, mut output: impl Write) -> io::Result> { let mut iter = input.chars().peekable(); while let Some(c) = iter.next() { if c != '\\' { @@ -85,7 +86,7 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result { '\\' => '\\', 'a' => '\x07', 'b' => '\x08', - 'c' => return Ok(true), + 'c' => return Ok(ControlFlow::Break(())), 'e' => '\x1b', 'f' => '\x0c', 'n' => '\n', @@ -112,7 +113,7 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result { } } - Ok(false) + Ok(ControlFlow::Continue(())) } #[uucore::main] @@ -173,8 +174,7 @@ fn execute(no_newline: bool, escaped: bool, free: &[String]) -> io::Result<()> { write!(output, " ")?; } if escaped { - let should_stop = print_escaped(input, &mut output)?; - if should_stop { + if print_escaped(input, &mut output)?.is_break() { break; } } else { From c29bcb219f6d10028ba5b9137730f45c158f93b1 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 3 Oct 2023 14:37:15 +0200 Subject: [PATCH 247/370] echo: don't output "\n" if "\c" is encountered --- src/uu/echo/src/echo.rs | 2 +- tests/by-util/test_echo.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index 947887210..b3707b6f8 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -175,7 +175,7 @@ fn execute(no_newline: bool, escaped: bool, free: &[String]) -> io::Result<()> { } if escaped { if print_escaped(input, &mut output)?.is_break() { - break; + return Ok(()); } } else { write!(output, "{input}")?; diff --git a/tests/by-util/test_echo.rs b/tests/by-util/test_echo.rs index dce5a4c95..875ff66cb 100644 --- a/tests/by-util/test_echo.rs +++ b/tests/by-util/test_echo.rs @@ -122,7 +122,7 @@ fn test_escape_no_further_output() { new_ucmd!() .args(&["-e", "a\\cb", "c"]) .succeeds() - .stdout_only("a\n"); + .stdout_only("a"); } #[test] From 54ba81ecbb9a810d3672ae6e378effb5c0dcb352 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 3 Oct 2023 15:09:20 +0200 Subject: [PATCH 248/370] mv: fix typo in test function name test_mv_info_self -> test_mv_into_self --- tests/by-util/test_mv.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index 0490d4119..f7f9622f5 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -1323,7 +1323,7 @@ fn test_mv_interactive_error() { } #[test] -fn test_mv_info_self() { +fn test_mv_into_self() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; let dir1 = "dir1"; From b591bedcab64851ec8d5091cc092db1144687369 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 15:34:37 +0000 Subject: [PATCH 249/370] chore(deps): update rust crate memmap2 to 0.9 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76e1dd72c..33ee7ff14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1291,9 +1291,9 @@ checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e" [[package]] name = "memmap2" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed" +checksum = "deaba38d7abf1d4cca21cc89e932e542ba2b9258664d2a9ef0e61512039c9375" dependencies = [ "libc", ] diff --git a/Cargo.toml b/Cargo.toml index c4c3fc2ff..e7fc2851b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -292,7 +292,7 @@ lscolors = { version = "0.15.0", default-features = false, features = [ "nu-ansi-term", ] } memchr = "2" -memmap2 = "0.8" +memmap2 = "0.9" nix = { version = "0.27", default-features = false } nom = "7.1.3" notify = { version = "=6.0.1", features = ["macos_kqueue"] } From 6c30a1df78704773257f9f1272b2e0d492a3feec Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 4 Oct 2023 06:04:46 +0000 Subject: [PATCH 250/370] fix-5327 --- src/uu/cp/src/cp.rs | 59 ++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index b6270719c..285a696a9 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -184,7 +184,7 @@ pub struct Attributes { #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Preserve { - No, + No { explicit: bool }, Yes { required: bool }, } @@ -197,9 +197,9 @@ impl PartialOrd for Preserve { impl Ord for Preserve { fn cmp(&self, other: &Self) -> Ordering { match (self, other) { - (Self::No, Self::No) => Ordering::Equal, - (Self::Yes { .. }, Self::No) => Ordering::Greater, - (Self::No, Self::Yes { .. }) => Ordering::Less, + (Self::No { .. }, Self::No { .. }) => Ordering::Equal, + (Self::Yes { .. }, Self::No { .. }) => Ordering::Greater, + (Self::No { .. }, Self::Yes { .. }) => Ordering::Less, ( Self::Yes { required: req_self }, Self::Yes { @@ -800,7 +800,7 @@ impl Attributes { } #[cfg(not(feature = "feat_selinux"))] { - Preserve::No + Preserve::No { explicit: false } } }, links: Preserve::Yes { required: true }, @@ -809,12 +809,12 @@ impl Attributes { pub const NONE: Self = Self { #[cfg(unix)] - ownership: Preserve::No, - mode: Preserve::No, - timestamps: Preserve::No, - context: Preserve::No, - links: Preserve::No, - xattr: Preserve::No, + ownership: Preserve::No { explicit: false }, + mode: Preserve::No { explicit: false }, + timestamps: Preserve::No { explicit: false }, + context: Preserve::No { explicit: false }, + links: Preserve::No { explicit: false }, + xattr: Preserve::No { explicit: false }, }; // TODO: ownership is required if the user is root, for non-root users it's not required. @@ -954,7 +954,9 @@ impl Options { if attribute_strs.len() > 0 { let no_preserve_attributes = Attributes::parse_iter(attribute_strs)?; if matches!(no_preserve_attributes.links, Preserve::Yes { .. }) { - attributes.links = Preserve::No; + attributes.links = Preserve::No { explicit: true }; + } else if matches!(no_preserve_attributes.mode, Preserve::Yes { .. }) { + attributes.mode = Preserve::No { explicit: true }; } } } @@ -1050,11 +1052,21 @@ impl Options { fn preserve_hard_links(&self) -> bool { match self.attributes.links { - Preserve::No => false, + Preserve::No { .. } => false, Preserve::Yes { .. } => true, } } + fn preserve_mode(&self) -> (bool, bool) { + match self.attributes.mode { + Preserve::No { explicit } => match explicit { + true => (false, true), + false => (false, false), + }, + Preserve::Yes { .. } => (true, false), + } + } + /// Whether to force overwriting the destination file. fn force(&self) -> bool { matches!(self.overwrite, OverwriteMode::Clobber(ClobberMode::Force)) @@ -1306,7 +1318,7 @@ impl OverwriteMode { /// If it's required, then the error is thrown. fn handle_preserve CopyResult<()>>(p: &Preserve, f: F) -> CopyResult<()> { match p { - Preserve::No => {} + Preserve::No { .. } => {} Preserve::Yes { required } => { let result = f(); if *required { @@ -1735,15 +1747,24 @@ fn copy_file( let mut permissions = source_metadata.permissions(); #[cfg(unix)] { - use uucore::mode::get_umask; - let mut mode = permissions.mode(); - // remove sticky bit, suid and gid bit - const SPECIAL_PERMS_MASK: u32 = 0o7000; - mode &= !SPECIAL_PERMS_MASK; + let (is_preserve_mode, is_explicit_no_preserve_mode) = options.preserve_mode(); + if !is_preserve_mode { + use libc::{ + S_IRGRP, S_IROTH, S_IRUSR, S_IRWXG, S_IRWXO, S_IRWXU, S_IWGRP, S_IWOTH, S_IWUSR, + }; + const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; + const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; + + match is_explicit_no_preserve_mode { + true => mode = MODE_RW_UGO, + false => mode &= S_IRWXUGO, + } + } // apply umask + use uucore::mode::get_umask; mode &= !get_umask(); permissions.set_mode(mode); From 88f88e51cc54c8f53dc7d24d59d84508cf1c5fb1 Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 4 Oct 2023 07:12:25 +0000 Subject: [PATCH 251/370] fix expected , found and spelling errors --- src/uu/cp/src/cp.rs | 8 +++++--- tests/by-util/test_cp.rs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 285a696a9..fc6332f3b 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) copydir ficlone fiemap ftruncate linkgs lstat nlink nlinks pathbuf pwrite reflink strs xattrs symlinked deduplicated advcpmv nushell +// spell-checker:ignore (ToDO) copydir ficlone fiemap ftruncate linkgs lstat nlink nlinks pathbuf pwrite reflink strs xattrs symlinked deduplicated advcpmv nushell IRWXG IRWXO IRWXU IRWXUGO IRWXU IRWXG IRWXO IRWXUGO #![allow(clippy::missing_safety_doc)] #![allow(clippy::extra_unused_lifetimes)] @@ -1057,6 +1057,7 @@ impl Options { } } + #[cfg(unix)] fn preserve_mode(&self) -> (bool, bool) { match self.attributes.mode { Preserve::No { explicit } => match explicit { @@ -1754,8 +1755,9 @@ fn copy_file( use libc::{ S_IRGRP, S_IROTH, S_IRUSR, S_IRWXG, S_IRWXO, S_IRWXU, S_IWGRP, S_IWOTH, S_IWUSR, }; - const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; - const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; + const MODE_RW_UGO: u32 = + (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; + const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; match is_explicit_no_preserve_mode { true => mode = MODE_RW_UGO, diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index f6d339a7e..95d130f88 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs ROOTDIR USERDIR procfs outfile +// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs ROOTDIR USERDIR procfs outfile uufs use crate::common::util::TestScenario; #[cfg(not(windows))] From cdde57608c028a8a678a4b55464589a299bcc4d0 Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 4 Oct 2023 08:06:30 +0000 Subject: [PATCH 252/370] fix macos mode_t is u16 but other unix platforms are u32 --- src/uu/cp/src/cp.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index fc6332f3b..e0a7984f2 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1755,8 +1755,16 @@ fn copy_file( use libc::{ S_IRGRP, S_IROTH, S_IRUSR, S_IRWXG, S_IRWXO, S_IRWXU, S_IWGRP, S_IWOTH, S_IWUSR, }; + + #[cfg(not(macos))] + const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; + #[cfg(not(macos))] + const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; + + #[cfg(macos)] const MODE_RW_UGO: u32 = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; + #[cfg(macos)] const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; match is_explicit_no_preserve_mode { From 74c393974c7c5582d2251a54b68805e5eb1dbf0a Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 4 Oct 2023 08:17:40 +0000 Subject: [PATCH 253/370] fix android mode_t is u16 but other unix platforms are u32 --- src/uu/cp/src/cp.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index c45436b8d..c3ad34118 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1749,15 +1749,15 @@ fn copy_file( S_IRGRP, S_IROTH, S_IRUSR, S_IRWXG, S_IRWXO, S_IRWXU, S_IWGRP, S_IWOTH, S_IWUSR, }; - #[cfg(not(macos))] + #[cfg(not(any(target_os = "android", target_os = "macos")))] const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; - #[cfg(not(macos))] + #[cfg(not(any(target_os = "android", target_os = "macos")))] const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; - #[cfg(macos)] + #[cfg(any(target_os = "android", target_os = "macos"))] const MODE_RW_UGO: u32 = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; - #[cfg(macos)] + #[cfg(any(target_os = "android", target_os = "macos"))] const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; match is_explicit_no_preserve_mode { From 6c05385d77454a2cfe89bd371d3fb2af17b3bfc4 Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 4 Oct 2023 08:31:07 +0000 Subject: [PATCH 254/370] fix macos-12 mode_t is u16 but other unix platforms are u32 --- src/uu/cp/src/cp.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index c3ad34118..1a9d5059d 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1749,15 +1749,23 @@ fn copy_file( S_IRGRP, S_IROTH, S_IRUSR, S_IRWXG, S_IRWXO, S_IRWXU, S_IWGRP, S_IWOTH, S_IWUSR, }; - #[cfg(not(any(target_os = "android", target_os = "macos")))] + #[cfg(not(any( + target_os = "android", + target_os = "macos", + target_os = "macos-12" + )))] const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; - #[cfg(not(any(target_os = "android", target_os = "macos")))] + #[cfg(not(any( + target_os = "android", + target_os = "macos", + target_os = "macos-12" + )))] const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; - #[cfg(any(target_os = "android", target_os = "macos"))] + #[cfg(any(target_os = "android", target_os = "macos", target_os = "macos-12"))] const MODE_RW_UGO: u32 = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; - #[cfg(any(target_os = "android", target_os = "macos"))] + #[cfg(any(target_os = "android", target_os = "macos", target_os = "macos-12"))] const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; match is_explicit_no_preserve_mode { From 5ce372082077bad27f2857979e1a09427f97d921 Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 4 Oct 2023 09:12:26 +0000 Subject: [PATCH 255/370] fix freebds mode_t is u16 but other unix platforms are u32 --- src/uu/cp/src/cp.rs | 20 ++++++++++++++++---- tests/by-util/test_cp.rs | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 1a9d5059d..f8c5ef3ce 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1752,20 +1752,32 @@ fn copy_file( #[cfg(not(any( target_os = "android", target_os = "macos", - target_os = "macos-12" + target_os = "macos-12", + target_os = "freebds", )))] const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; #[cfg(not(any( target_os = "android", target_os = "macos", - target_os = "macos-12" + target_os = "macos-12", + target_os = "freebds", )))] const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; - #[cfg(any(target_os = "android", target_os = "macos", target_os = "macos-12"))] + #[cfg(any( + target_os = "android", + target_os = "macos", + target_os = "macos-12", + target_os = "freebds", + ))] const MODE_RW_UGO: u32 = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; - #[cfg(any(target_os = "android", target_os = "macos", target_os = "macos-12"))] + #[cfg(any( + target_os = "android", + target_os = "macos", + target_os = "macos-12", + target_os = "freebds", + ))] const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; match is_explicit_no_preserve_mode { diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index e85cd0c57..96b47cd43 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -1553,7 +1553,7 @@ fn test_cp_preserve_links_case_7() { } #[test] -#[cfg(all(unix, not(target_os = "freebsd")))] +#[cfg(all(unix))] fn test_cp_no_preserve_mode_case() { use libc::umask; use uucore::fs as uufs; From aaea3b40fba455156bf927746e5076d0de30a686 Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 4 Oct 2023 09:16:54 +0000 Subject: [PATCH 256/370] fix freebsd typo --- src/uu/cp/src/cp.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index f8c5ef3ce..72431cc12 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1753,14 +1753,14 @@ fn copy_file( target_os = "android", target_os = "macos", target_os = "macos-12", - target_os = "freebds", + target_os = "freebsd", )))] const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; #[cfg(not(any( target_os = "android", target_os = "macos", target_os = "macos-12", - target_os = "freebds", + target_os = "freebsd", )))] const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; @@ -1768,7 +1768,7 @@ fn copy_file( target_os = "android", target_os = "macos", target_os = "macos-12", - target_os = "freebds", + target_os = "freebsd", ))] const MODE_RW_UGO: u32 = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; @@ -1776,7 +1776,7 @@ fn copy_file( target_os = "android", target_os = "macos", target_os = "macos-12", - target_os = "freebds", + target_os = "freebsd", ))] const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; From e88183174b9592c6a490658f0ef09938459ffcdd Mon Sep 17 00:00:00 2001 From: boxdot Date: Wed, 4 Oct 2023 16:12:02 +0200 Subject: [PATCH 257/370] relpath: remove Closes #5236 --- Cargo.lock | 9 -- Cargo.toml | 2 - GNUmakefile | 1 - docs/compiles_table.csv | 42 ++++---- src/uu/relpath/Cargo.toml | 23 ----- src/uu/relpath/LICENSE | 1 - src/uu/relpath/relpath.md | 8 -- src/uu/relpath/src/main.rs | 1 - src/uu/relpath/src/relpath.rs | 91 ---------------- tests/by-util/test_relpath.rs | 189 ---------------------------------- tests/tests.rs | 4 - util/show-utils.BAT | 4 +- util/show-utils.sh | 4 +- 13 files changed, 25 insertions(+), 354 deletions(-) delete mode 100644 src/uu/relpath/Cargo.toml delete mode 120000 src/uu/relpath/LICENSE delete mode 100644 src/uu/relpath/relpath.md delete mode 100644 src/uu/relpath/src/main.rs delete mode 100644 src/uu/relpath/src/relpath.rs delete mode 100644 tests/by-util/test_relpath.rs diff --git a/Cargo.lock b/Cargo.lock index 33ee7ff14..252be5d67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -470,7 +470,6 @@ dependencies = [ "uu_pwd", "uu_readlink", "uu_realpath", - "uu_relpath", "uu_rm", "uu_rmdir", "uu_runcon", @@ -2866,14 +2865,6 @@ dependencies = [ "uucore", ] -[[package]] -name = "uu_relpath" -version = "0.0.21" -dependencies = [ - "clap", - "uucore", -] - [[package]] name = "uu_rm" version = "0.0.21" diff --git a/Cargo.toml b/Cargo.toml index e7fc2851b..88bd1635b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,7 +100,6 @@ feat_common_core = [ "pwd", "readlink", "realpath", - "relpath", "rm", "rmdir", "seq", @@ -430,7 +429,6 @@ ptx = { optional = true, version = "0.0.21", package = "uu_ptx", path = "src/uu/ pwd = { optional = true, version = "0.0.21", package = "uu_pwd", path = "src/uu/pwd" } readlink = { optional = true, version = "0.0.21", package = "uu_readlink", path = "src/uu/readlink" } realpath = { optional = true, version = "0.0.21", package = "uu_realpath", path = "src/uu/realpath" } -relpath = { optional = true, version = "0.0.21", package = "uu_relpath", path = "src/uu/relpath" } rm = { optional = true, version = "0.0.21", package = "uu_rm", path = "src/uu/rm" } rmdir = { optional = true, version = "0.0.21", package = "uu_rmdir", path = "src/uu/rmdir" } runcon = { optional = true, version = "0.0.21", package = "uu_runcon", path = "src/uu/runcon" } diff --git a/GNUmakefile b/GNUmakefile index c672458a1..ad2d38081 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -102,7 +102,6 @@ PROGS := \ pwd \ readlink \ realpath \ - relpath \ rm \ rmdir \ seq \ diff --git a/docs/compiles_table.csv b/docs/compiles_table.csv index d18854e0e..e263067b7 100644 --- a/docs/compiles_table.csv +++ b/docs/compiles_table.csv @@ -1,21 +1,21 @@ -target,arch,base32,base64,basename,cat,chgrp,chmod,chown,chroot,cksum,comm,cp,csplit,cut,date,df,dircolors,dirname,du,echo,env,expand,expr,factor,false,fmt,fold,groups,hashsum,head,hostid,hostname,id,install,join,kill,link,ln,logname,ls,mkdir,mkfifo,mknod,mktemp,more,mv,nice,nl,nohup,nproc,numfmt,od,paste,pathchk,pinky,printenv,printf,ptx,pwd,readlink,realpath,relpath,rm,rmdir,seq,shred,shuf,sleep,sort,split,stat,stdbuf,sum,sync,tac,tail,tee,test,timeout,touch,tr,true,truncate,tsort,tty,uname,unexpand,uniq,unlink,uptime,users,wc,who,whoami,yes,chcon,pr,dir,vdir,dd,basenc,runcon -aarch64-unknown-linux-gnu,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -i686-unknown-linux-gnu,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -powerpc64-unknown-linux-gnu,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -riscv64gc-unknown-linux-gnu,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 -x86_64-unknown-linux-gnu,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -aarch64-pc-windows-msvc,0,0,0,0,0,101,101,101,101,0,0,0,0,0,0,0,0,0,101,0,0,0,101,0,0,0,0,101,0,0,0,0,101,101,0,101,0,0,0,101,0,101,101,0,0,0,101,0,101,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,101,0,101,0,101,101,0,0,0,0,0,0,0,0 -i686-pc-windows-gnu,0,0,0,0,0,101,101,101,101,0,0,0,0,0,0,0,0,0,101,0,0,0,101,0,0,0,0,101,0,0,0,0,101,101,0,101,0,0,0,0,0,101,101,0,0,0,101,0,101,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,101,0,101,0,101,0,0,0,0,0,0,0,0,0 -i686-pc-windows-msvc,0,0,0,0,0,101,101,101,101,0,0,0,0,0,0,0,0,0,101,0,0,0,101,0,0,0,0,101,0,0,0,0,101,101,0,101,0,0,0,0,0,101,101,0,0,0,101,0,101,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,101,0,101,0,101,0,0,0,0,0,0,0,0,0 -x86_64-pc-windows-gnu,0,0,0,0,0,101,101,101,101,0,0,0,0,0,0,0,0,0,101,0,0,0,101,0,0,0,0,101,0,0,0,0,101,101,0,101,0,0,0,0,0,101,101,0,0,0,101,0,101,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,101,0,101,0,101,0,0,0,0,0,0,0,0,0 -x86_64-pc-windows-msvc,0,0,0,0,0,101,101,101,101,0,0,0,0,0,0,0,0,0,101,0,0,0,101,0,0,0,0,101,0,0,0,0,101,101,0,101,0,0,0,0,0,101,101,0,0,0,101,0,101,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,101,0,101,0,101,0,0,0,0,0,0,0,0,0 -x86_64-apple-darwin,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -x86_64-unknown-freebsd,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -x86_64-unknown-netbsd,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,101,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,101,101,0,101,0,0,0,0,0,0,0,0,0 -aarch64-linux-android,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,101,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,101,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,101,101,0,101,0,0,0,0,0,0,0,0,0 -x86_64-linux-android,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,101,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,101,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,101,101,0,101,0,0,0,0,0,0,0,0,0 -x86_64-sun-solaris,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 -wasm32-wasi,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 -x86_64-unknown-redox,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 -aarch64-fuchsia,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 -x86_64-fuchsia,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 +target,arch,base32,base64,basename,cat,chgrp,chmod,chown,chroot,cksum,comm,cp,csplit,cut,date,df,dircolors,dirname,du,echo,env,expand,expr,factor,false,fmt,fold,groups,hashsum,head,hostid,hostname,id,install,join,kill,link,ln,logname,ls,mkdir,mkfifo,mknod,mktemp,more,mv,nice,nl,nohup,nproc,numfmt,od,paste,pathchk,pinky,printenv,printf,ptx,pwd,readlink,realpath,rm,rmdir,seq,shred,shuf,sleep,sort,split,stat,stdbuf,sum,sync,tac,tail,tee,test,timeout,touch,tr,true,truncate,tsort,tty,uname,unexpand,uniq,unlink,uptime,users,wc,who,whoami,yes,chcon,pr,dir,vdir,dd,basenc,runcon +aarch64-unknown-linux-gnu,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +i686-unknown-linux-gnu,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +powerpc64-unknown-linux-gnu,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +riscv64gc-unknown-linux-gnu,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 +x86_64-unknown-linux-gnu,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +aarch64-pc-windows-msvc,0,0,0,0,0,101,101,101,101,0,0,0,0,0,0,0,0,0,101,0,0,0,101,0,0,0,0,101,0,0,0,0,101,101,0,101,0,0,0,101,0,101,101,0,0,0,101,0,101,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,101,0,101,0,101,101,0,0,0,0,0,0,0,0 +i686-pc-windows-gnu,0,0,0,0,0,101,101,101,101,0,0,0,0,0,0,0,0,0,101,0,0,0,101,0,0,0,0,101,0,0,0,0,101,101,0,101,0,0,0,0,0,101,101,0,0,0,101,0,101,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,101,0,101,0,101,0,0,0,0,0,0,0,0,0 +i686-pc-windows-msvc,0,0,0,0,0,101,101,101,101,0,0,0,0,0,0,0,0,0,101,0,0,0,101,0,0,0,0,101,0,0,0,0,101,101,0,101,0,0,0,0,0,101,101,0,0,0,101,0,101,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,101,0,101,0,101,0,0,0,0,0,0,0,0,0 +x86_64-pc-windows-gnu,0,0,0,0,0,101,101,101,101,0,0,0,0,0,0,0,0,0,101,0,0,0,101,0,0,0,0,101,0,0,0,0,101,101,0,101,0,0,0,0,0,101,101,0,0,0,101,0,101,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,101,0,101,0,101,0,0,0,0,0,0,0,0,0 +x86_64-pc-windows-msvc,0,0,0,0,0,101,101,101,101,0,0,0,0,0,0,0,0,0,101,0,0,0,101,0,0,0,0,101,0,0,0,0,101,101,0,101,0,0,0,0,0,101,101,0,0,0,101,0,101,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,101,0,101,0,101,0,0,0,0,0,0,0,0,0 +x86_64-apple-darwin,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +x86_64-unknown-freebsd,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +x86_64-unknown-netbsd,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,101,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,101,101,0,101,0,0,0,0,0,0,0,0,0 +aarch64-linux-android,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,101,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,101,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,101,101,0,101,0,0,0,0,0,0,0,0,0 +x86_64-linux-android,0,0,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,101,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,101,0,0,0,0,101,0,0,0,0,0,0,101,0,0,0,101,101,0,101,0,0,0,0,0,0,0,0,0 +x86_64-sun-solaris,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 +wasm32-wasi,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 +x86_64-unknown-redox,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 +aarch64-fuchsia,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 +x86_64-fuchsia,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101 diff --git a/src/uu/relpath/Cargo.toml b/src/uu/relpath/Cargo.toml deleted file mode 100644 index 0df32efd2..000000000 --- a/src/uu/relpath/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "uu_relpath" -version = "0.0.21" -authors = ["uutils developers"] -license = "MIT" -description = "relpath ~ (uutils) display relative path of PATHNAME_TO from PATHNAME_FROM" - -homepage = "https://github.com/uutils/coreutils" -repository = "https://github.com/uutils/coreutils/tree/main/src/uu/relpath" -keywords = ["coreutils", "uutils", "cross-platform", "cli", "utility"] -categories = ["command-line-utilities"] -edition = "2021" - -[lib] -path = "src/relpath.rs" - -[dependencies] -clap = { workspace = true } -uucore = { workspace = true, features = ["fs"] } - -[[bin]] -name = "relpath" -path = "src/main.rs" diff --git a/src/uu/relpath/LICENSE b/src/uu/relpath/LICENSE deleted file mode 120000 index 5853aaea5..000000000 --- a/src/uu/relpath/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../../LICENSE \ No newline at end of file diff --git a/src/uu/relpath/relpath.md b/src/uu/relpath/relpath.md deleted file mode 100644 index a1ff9bf4a..000000000 --- a/src/uu/relpath/relpath.md +++ /dev/null @@ -1,8 +0,0 @@ -# relpath - -``` -relpath [-d DIR] TO [FROM] -``` - -Convert TO destination to the relative path from the FROM dir. -If FROM path is omitted, current working dir will be used. \ No newline at end of file diff --git a/src/uu/relpath/src/main.rs b/src/uu/relpath/src/main.rs deleted file mode 100644 index b7dba76ce..000000000 --- a/src/uu/relpath/src/main.rs +++ /dev/null @@ -1 +0,0 @@ -uucore::bin!(uu_relpath); diff --git a/src/uu/relpath/src/relpath.rs b/src/uu/relpath/src/relpath.rs deleted file mode 100644 index aa8b5caab..000000000 --- a/src/uu/relpath/src/relpath.rs +++ /dev/null @@ -1,91 +0,0 @@ -// This file is part of the uutils coreutils package. -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. - -// spell-checker:ignore (ToDO) subpath absto absfrom absbase - -use clap::{crate_version, Arg, Command}; -use std::env; -use std::path::{Path, PathBuf}; -use uucore::display::println_verbatim; -use uucore::error::{FromIo, UResult}; -use uucore::fs::{canonicalize, MissingHandling, ResolveMode}; -use uucore::{format_usage, help_about, help_usage}; - -const USAGE: &str = help_usage!("relpath.md"); -const ABOUT: &str = help_about!("relpath.md"); - -mod options { - pub const DIR: &str = "DIR"; - pub const TO: &str = "TO"; - pub const FROM: &str = "FROM"; -} - -#[uucore::main] -pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let args = args.collect_lossy(); - - let matches = uu_app().get_matches_from(args); - - let to = Path::new(matches.get_one::(options::TO).unwrap()).to_path_buf(); // required - let from = match matches.get_one::(options::FROM) { - Some(p) => Path::new(p).to_path_buf(), - None => env::current_dir().unwrap(), - }; - let absto = canonicalize(to, MissingHandling::Normal, ResolveMode::Logical) - .map_err_context(String::new)?; - let absfrom = canonicalize(from, MissingHandling::Normal, ResolveMode::Logical) - .map_err_context(String::new)?; - - if matches.contains_id(options::DIR) { - let base = Path::new(&matches.get_one::(options::DIR).unwrap()).to_path_buf(); - let absbase = canonicalize(base, MissingHandling::Normal, ResolveMode::Logical) - .map_err_context(String::new)?; - if !absto.as_path().starts_with(absbase.as_path()) - || !absfrom.as_path().starts_with(absbase.as_path()) - { - return println_verbatim(absto).map_err_context(String::new); - } - } - - let mut suffix_pos = 0; - for (f, t) in absfrom.components().zip(absto.components()) { - if f == t { - suffix_pos += 1; - } else { - break; - } - } - - let mut result = PathBuf::new(); - absfrom - .components() - .skip(suffix_pos) - .map(|_| result.push("..")) - .last(); - absto - .components() - .skip(suffix_pos) - .map(|x| result.push(x.as_os_str())) - .last(); - - println_verbatim(result).map_err_context(String::new) -} - -pub fn uu_app() -> Command { - Command::new(uucore::util_name()) - .version(crate_version!()) - .about(ABOUT) - .override_usage(format_usage(USAGE)) - .infer_long_args(true) - .arg(Arg::new(options::DIR).short('d').help( - "If any of FROM and TO is not subpath of DIR, output absolute path instead of relative", - )) - .arg( - Arg::new(options::TO) - .value_hint(clap::ValueHint::AnyPath) - .required(true), - ) - .arg(Arg::new(options::FROM).value_hint(clap::ValueHint::AnyPath)) -} diff --git a/tests/by-util/test_relpath.rs b/tests/by-util/test_relpath.rs deleted file mode 100644 index f506e01c5..000000000 --- a/tests/by-util/test_relpath.rs +++ /dev/null @@ -1,189 +0,0 @@ -// This file is part of the uutils coreutils package. -// -// For the full copyright and license information, please view the LICENSE -// file that was distributed with this source code. -use crate::common::util::TestScenario; -use std::borrow::Cow; -use std::path::Path; - -struct TestCase<'a> { - from: &'a str, - to: &'a str, - expected: &'a str, -} - -const TESTS: [TestCase; 10] = [ - TestCase { - from: "A/B/C", - to: "A", - expected: "../..", - }, - TestCase { - from: "A/B/C", - to: "A/B", - expected: "..", - }, - TestCase { - from: "A/B/C", - to: "A/B/C", - expected: "", - }, - TestCase { - from: "A/B/C", - to: "A/B/C/D", - expected: "D", - }, - TestCase { - from: "A/B/C", - to: "A/B/C/D/E", - expected: "D/E", - }, - TestCase { - from: "A/B/C", - to: "A/B/D", - expected: "../D", - }, - TestCase { - from: "A/B/C", - to: "A/B/D/E", - expected: "../D/E", - }, - TestCase { - from: "A/B/C", - to: "A/D", - expected: "../../D", - }, - TestCase { - from: "A/B/C", - to: "D/E/F", - expected: "../../../D/E/F", - }, - TestCase { - from: "A/B/C", - to: "A/D/E", - expected: "../../D/E", - }, -]; - -#[allow(clippy::needless_lifetimes)] -fn convert_path<'a>(path: &'a str) -> Cow<'a, str> { - #[cfg(windows)] - return path.replace('/', "\\").into(); - #[cfg(not(windows))] - return path.into(); -} - -#[test] -fn test_relpath_with_from_no_d() { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - - for test in &TESTS { - let from: &str = &convert_path(test.from); - let to: &str = &convert_path(test.to); - let expected: &str = &convert_path(test.expected); - - at.mkdir_all(to); - at.mkdir_all(from); - - scene - .ucmd() - .arg(to) - .arg(from) - .succeeds() - .stdout_only(&format!("{expected}\n")); - } -} - -#[test] -fn test_relpath_with_from_with_d() { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - - for test in &TESTS { - let from: &str = &convert_path(test.from); - let to: &str = &convert_path(test.to); - let pwd = at.as_string(); - at.mkdir_all(to); - at.mkdir_all(from); - - // d is part of subpath -> expect relative path - let mut _result_stdout = scene - .ucmd() - .arg(to) - .arg(from) - .arg(&format!("-d{pwd}")) - .succeeds() - .stdout_move_str(); - // relax rules for windows test environment - #[cfg(not(windows))] - assert!(Path::new(&_result_stdout).is_relative()); - - // d is not part of subpath -> expect absolute path - _result_stdout = scene - .ucmd() - .arg(to) - .arg(from) - .arg("-dnon_existing") // spell-checker:disable-line - .succeeds() - .stdout_move_str(); - assert!(Path::new(&_result_stdout).is_absolute()); - } -} - -#[test] -fn test_relpath_no_from_no_d() { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - - for test in &TESTS { - let to: &str = &convert_path(test.to); - at.mkdir_all(to); - - let _result_stdout = scene.ucmd().arg(to).succeeds().stdout_move_str(); - #[cfg(not(windows))] - assert_eq!(_result_stdout, format!("{to}\n")); - // relax rules for windows test environment - #[cfg(windows)] - assert!(_result_stdout.ends_with(&format!("{to}\n"))); - } -} - -#[test] -fn test_relpath_no_from_with_d() { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - - for test in &TESTS { - let to: &str = &convert_path(test.to); - let pwd = at.as_string(); - at.mkdir_all(to); - - // d is part of subpath -> expect relative path - let _result_stdout = scene - .ucmd() - .arg(to) - .arg(&format!("-d{pwd}")) - .succeeds() - .stdout_move_str(); - // relax rules for windows test environment - #[cfg(not(windows))] - assert!(Path::new(&_result_stdout).is_relative()); - - // d is not part of subpath -> expect absolute path - let result_stdout = scene - .ucmd() - .arg(to) - .arg("-dnon_existing") // spell-checker:disable-line - .succeeds() - .stdout_move_str(); - assert!(Path::new(&result_stdout).is_absolute()); - } -} - -#[test] -fn test_relpath_no_to() { - new_ucmd!() - .fails() - .stderr_contains("required arguments were not provided"); -} diff --git a/tests/tests.rs b/tests/tests.rs index 8d4a6855c..1fb5735eb 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -269,10 +269,6 @@ mod test_readlink; #[path = "by-util/test_realpath.rs"] mod test_realpath; -#[cfg(feature = "relpath")] -#[path = "by-util/test_relpath.rs"] -mod test_relpath; - #[cfg(feature = "rm")] #[path = "by-util/test_rm.rs"] mod test_rm; diff --git a/util/show-utils.BAT b/util/show-utils.BAT index 9fa5e2ffa..f6d900734 100644 --- a/util/show-utils.BAT +++ b/util/show-utils.BAT @@ -2,7 +2,7 @@ @echo off @rem ::# spell-checker:ignore (CMD) ERRORLEVEL -@rem ::# spell-checker:ignore (utils) cksum coreutils dircolors hashsum mkdir mktemp printenv printf readlink realpath relpath rmdir shuf tsort unexpand +@rem ::# spell-checker:ignore (utils) cksum coreutils dircolors hashsum mkdir mktemp printenv printf readlink realpath rmdir shuf tsort unexpand @rem ::# spell-checker:ignore (jq) deps startswith set "ME=%~0" @@ -12,7 +12,7 @@ set "ME_parent_dir=%~dp0.\.." @rem refs: , @rem :: default ("Tier 1" cross-platform) utility list -set "default_utils=base32 base64 basename cat cksum comm cp cut date dircolors dirname echo env expand expr factor false fmt fold hashsum head join link ln ls mkdir mktemp more mv nl od paste printenv printf ptx pwd readlink realpath relpath rm rmdir seq shred shuf sleep sort split sum tac tail tee test tr true truncate tsort unexpand uniq wc yes" +set "default_utils=base32 base64 basename cat cksum comm cp cut date dircolors dirname echo env expand expr factor false fmt fold hashsum head join link ln ls mkdir mktemp more mv nl od paste printenv printf ptx pwd readlink realpath rm rmdir seq shred shuf sleep sort split sum tac tail tee test tr true truncate tsort unexpand uniq wc yes" set "project_dir=%ME_parent_dir%" cd "%project_dir%" diff --git a/util/show-utils.sh b/util/show-utils.sh index b6a0f9856..dda01abe2 100755 --- a/util/show-utils.sh +++ b/util/show-utils.sh @@ -1,6 +1,6 @@ #!/bin/sh -# spell-checker:ignore (utils) cksum coreutils dircolors hashsum mkdir mktemp printenv printf readlink realpath relpath rmdir shuf tsort unexpand +# spell-checker:ignore (utils) cksum coreutils dircolors hashsum mkdir mktemp printenv printf readlink realpath rmdir shuf tsort unexpand # spell-checker:ignore (jq) deps startswith ME="${0}" @@ -12,7 +12,7 @@ ME_parent_dir_abs="$(realpath -mP -- "${ME_parent_dir}" || realpath -- "${ME_par # refs: , # default ("Tier 1" cross-platform) utility list -default_utils="base32 base64 basename cat cksum comm cp cut date dircolors dirname echo env expand expr factor false fmt fold hashsum head join link ln ls mkdir mktemp more mv nl od paste printenv printf ptx pwd readlink realpath relpath rm rmdir seq shred shuf sleep sort split sum tac tail tee test tr true truncate tsort unexpand uniq wc yes" +default_utils="base32 base64 basename cat cksum comm cp cut date dircolors dirname echo env expand expr factor false fmt fold hashsum head join link ln ls mkdir mktemp more mv nl od paste printenv printf ptx pwd readlink realpath rm rmdir seq shred shuf sleep sort split sum tac tail tee test tr true truncate tsort unexpand uniq wc yes" project_main_dir="${ME_parent_dir_abs}" # printf 'project_main_dir="%s"\n' "${project_main_dir}" From b87e1f56764db61beae80970d3a7a52fee53cfa7 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 5 Oct 2023 09:31:43 +0200 Subject: [PATCH 258/370] chown: move uid & gid detections into their own functions --- src/uu/chown/src/chown.rs | 95 ++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs index 8e97d5652..ea25050bb 100644 --- a/src/uu/chown/src/chown.rs +++ b/src/uu/chown/src/chown.rs @@ -195,6 +195,53 @@ pub fn uu_app() -> Command { ) } +/// Parses the user string to extract the UID. +fn parse_uid(user: &str, spec: &str, sep: char) -> UResult> { + if user.is_empty() { + return Ok(None); + } + match Passwd::locate(user) { + Ok(u) => Ok(Some(u.uid)), // We have been able to get the uid + Err(_) => { + // we have NOT been able to find the uid + // but we could be in the case where we have user.group + if spec.contains('.') && !spec.contains(':') && sep == ':' { + // but the input contains a '.' but not a ':' + // we might have something like username.groupname + // So, try to parse it this way + return parse_spec(spec, '.').map(|(uid, _)| uid); + } else { + // It's possible that the `user` string contains a + // numeric user ID, in which case, we respect that. + match user.parse() { + Ok(uid) => Ok(Some(uid)), + Err(_) => Err(USimpleError::new( + 1, + format!("invalid user: {}", spec.quote()), + )), + } + } + } + } +} + +/// Parses the group string to extract the GID. +fn parse_gid(group: &str, spec: &str) -> UResult> { + if group.is_empty() { + return Ok(None); + } + match Group::locate(group) { + Ok(g) => Ok(Some(g.gid)), + Err(_) => match group.parse() { + Ok(gid) => Ok(Some(gid)), + Err(_) => Err(USimpleError::new( + 1, + format!("invalid group: {}", spec.quote()), + )), + }, + } +} + /// Parse the owner/group specifier string into a user ID and a group ID. /// /// The `spec` can be of the form: @@ -213,52 +260,8 @@ fn parse_spec(spec: &str, sep: char) -> UResult<(Option, Option)> { let user = args.next().unwrap_or(""); let group = args.next().unwrap_or(""); - let uid = if user.is_empty() { - None - } else { - Some(match Passwd::locate(user) { - Ok(u) => u.uid, // We have been able to get the uid - Err(_) => - // we have NOT been able to find the uid - // but we could be in the case where we have user.group - { - if spec.contains('.') && !spec.contains(':') && sep == ':' { - // but the input contains a '.' but not a ':' - // we might have something like username.groupname - // So, try to parse it this way - return parse_spec(spec, '.'); - } else { - // It's possible that the `user` string contains a - // numeric user ID, in which case, we respect that. - match user.parse() { - Ok(uid) => uid, - Err(_) => { - return Err(USimpleError::new( - 1, - format!("invalid user: {}", spec.quote()), - )) - } - } - } - } - }) - }; - let gid = if group.is_empty() { - None - } else { - Some(match Group::locate(group) { - Ok(g) => g.gid, - Err(_) => match group.parse() { - Ok(gid) => gid, - Err(_) => { - return Err(USimpleError::new( - 1, - format!("invalid group: {}", spec.quote()), - )); - } - }, - }) - }; + let uid = parse_uid(user, spec, sep)?; + let gid = parse_gid(group, spec)?; if user.chars().next().map(char::is_numeric).unwrap_or(false) && group.is_empty() From d756a05be6f420b56a96a7d103c37227e720f23e Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 5 Oct 2023 19:18:00 +0200 Subject: [PATCH 259/370] touch: fix clippy warning - redundant guard --- src/uu/touch/src/touch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index 6555773ee..d9399a051 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -489,7 +489,7 @@ fn pathbuf_from_stdout() -> UResult { format!("GetFinalPathNameByHandleW failed with code {ret}"), )) } - e if e == 0 => { + 0 => { return Err(USimpleError::new( 1, format!( From f18e8983b189ed62fb381c3c3ce808281daae6d2 Mon Sep 17 00:00:00 2001 From: terade <134976752+terade@users.noreply.github.com.> Date: Wed, 4 Oct 2023 16:32:30 +0200 Subject: [PATCH 260/370] rm: Refactor prompt_file, lower nesting depth Addressing issue #5345. Introduce new helper function: prompt_file_permission_read_only --- src/uu/rm/src/rm.rs | 61 +++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 87767b904..0f4d04598 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -486,7 +486,6 @@ fn prompt_dir(path: &Path, options: &Options) -> bool { } } -#[allow(clippy::cognitive_complexity)] fn prompt_file(path: &Path, options: &Options) -> bool { // If interactive is Never we never want to send prompts if options.interactive == InteractiveMode::Never { @@ -503,47 +502,43 @@ fn prompt_file(path: &Path, options: &Options) -> bool { // File::open(path) doesn't open the file in write mode so we need to use file options to open it in also write mode to check if it can written too match File::options().read(true).write(true).open(path) { Ok(file) => { - if let Ok(metadata) = file.metadata() { - if metadata.permissions().readonly() { - if metadata.len() == 0 { - prompt_yes!( - "remove write-protected regular empty file {}?", - path.quote() - ) - } else { - prompt_yes!("remove write-protected regular file {}?", path.quote()) - } - } else if options.interactive == InteractiveMode::Always { - if metadata.len() == 0 { - prompt_yes!("remove regular empty file {}?", path.quote()) - } else { - prompt_yes!("remove file {}?", path.quote()) - } + let Ok(metadata) = file.metadata() else { + return true; + }; + + if options.interactive == InteractiveMode::Always && !metadata.permissions().readonly() + { + return if metadata.len() == 0 { + prompt_yes!("remove regular empty file {}?", path.quote()) } else { - true - } - } else { - true + prompt_yes!("remove file {}?", path.quote()) + }; } + prompt_file_permission_readonly(path, Ok(metadata)) } Err(err) => { - if err.kind() == ErrorKind::PermissionDenied { - match fs::metadata(path) { - Ok(metadata) if metadata.len() == 0 => { - prompt_yes!( - "remove write-protected regular empty file {}?", - path.quote() - ) - } - _ => prompt_yes!("remove write-protected regular file {}?", path.quote()), - } - } else { - true + if err.kind() != ErrorKind::PermissionDenied { + return true; } + prompt_file_permission_readonly(path, fs::metadata(path)) } } } +fn prompt_file_permission_readonly( + path: &Path, + metadata_or_err: Result, +) -> bool { + match metadata_or_err { + Ok(metadata) if !metadata.permissions().readonly() => true, + Ok(metadata) if metadata.len() == 0 => prompt_yes!( + "remove write-protected regular empty file {}?", + path.quote() + ), + _ => prompt_yes!("remove write-protected regular file {}?", path.quote()), + } +} + // For directories finding if they are writable or not is a hassle. In Unix we can use the built-in rust crate to to check mode bits. But other os don't have something similar afaik // Most cases are covered by keep eye out for edge cases #[cfg(unix)] From 7c3de4084294bef465ff38132b60884a7c40c4b3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 6 Oct 2023 05:01:49 +0000 Subject: [PATCH 261/370] chore(deps): update rust crate byteorder to 1.5.0 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33ee7ff14..19ea899d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -211,9 +211,9 @@ checksum = "ad152d03a2c813c80bb94fedbf3a3f02b28f793e39e7c214c8a0bcc196343de7" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" diff --git a/Cargo.toml b/Cargo.toml index e7fc2851b..83697cf00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -262,7 +262,7 @@ bigdecimal = "0.4" binary-heap-plus = "0.5.0" bstr = "1.6" bytecount = "0.6.4" -byteorder = "1.4.3" +byteorder = "1.5.0" chrono = { version = "^0.4.31", default-features = false, features = [ "std", "alloc", From 4760b1f340dfe30f23fdc8676211c7ae48b963da Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 6 Oct 2023 07:49:36 +0200 Subject: [PATCH 262/370] chown: remove unnecessary return --- src/uu/chown/src/chown.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs index ea25050bb..0e9b8b242 100644 --- a/src/uu/chown/src/chown.rs +++ b/src/uu/chown/src/chown.rs @@ -209,7 +209,7 @@ fn parse_uid(user: &str, spec: &str, sep: char) -> UResult> { // but the input contains a '.' but not a ':' // we might have something like username.groupname // So, try to parse it this way - return parse_spec(spec, '.').map(|(uid, _)| uid); + parse_spec(spec, '.').map(|(uid, _)| uid) } else { // It's possible that the `user` string contains a // numeric user ID, in which case, we respect that. From 6dd53c7a717daac2dcc5f71f4efcf3c4351e7154 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 6 Oct 2023 10:11:26 +0200 Subject: [PATCH 263/370] clippy: fix warnings in tests --- tests/by-util/test_cp.rs | 1 - tests/by-util/test_split.rs | 40 ++++++++++++++++++------------------- tests/by-util/test_tee.rs | 17 +++++++++++++--- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 15713587c..9894087e8 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -1545,7 +1545,6 @@ fn test_cp_preserve_links_case_7() { .arg("dest") .fails() .stderr_contains("not replacing"); - (); assert!(at.dir_exists("dest")); assert!(at.plus("dest").join("f").exists()); diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 6fc3a3706..ce80844cf 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -438,7 +438,7 @@ fn test_split_obs_lines_within_combined_shorts() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; let name = "obs-lines-within-shorts"; - RandomFile::new(&at, name).add_lines(400); + RandomFile::new(at, name).add_lines(400); scene .ucmd() @@ -446,9 +446,9 @@ fn test_split_obs_lines_within_combined_shorts() { .succeeds() .no_stderr() .no_stdout(); - let glob = Glob::new(&at, ".", r"x\d\d$"); + let glob = Glob::new(at, ".", r"x\d\d$"); assert_eq!(glob.count(), 2); - assert_eq!(glob.collate(), at.read_bytes(name)) + assert_eq!(glob.collate(), at.read_bytes(name)); } /// Test for obsolete lines option as part of combined short options with tailing suffix length with value @@ -470,7 +470,7 @@ fn test_split_obs_lines_starts_combined_shorts() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; let name = "obs-lines-starts-shorts"; - RandomFile::new(&at, name).add_lines(400); + RandomFile::new(at, name).add_lines(400); scene .ucmd() @@ -478,9 +478,9 @@ fn test_split_obs_lines_starts_combined_shorts() { .succeeds() .no_stderr() .no_stdout(); - let glob = Glob::new(&at, ".", r"x\d\d$"); + let glob = Glob::new(at, ".", r"x\d\d$"); assert_eq!(glob.count(), 2); - assert_eq!(glob.collate(), at.read_bytes(name)) + assert_eq!(glob.collate(), at.read_bytes(name)); } /// Test for using both obsolete lines (standalone) option and short/long lines option simultaneously @@ -585,7 +585,7 @@ fn test_split_multiple_obs_lines_standalone() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; let name = "multiple-obs-lines"; - RandomFile::new(&at, name).add_lines(400); + RandomFile::new(at, name).add_lines(400); scene .ucmd() @@ -593,9 +593,9 @@ fn test_split_multiple_obs_lines_standalone() { .succeeds() .no_stderr() .no_stdout(); - let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + let glob = Glob::new(at, ".", r"x[[:alpha:]][[:alpha:]]$"); assert_eq!(glob.count(), 2); - assert_eq!(glob.collate(), at.read_bytes(name)) + assert_eq!(glob.collate(), at.read_bytes(name)); } /// Test for using more than one obsolete lines option within combined shorts @@ -605,7 +605,7 @@ fn test_split_multiple_obs_lines_within_combined() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; let name = "multiple-obs-lines"; - RandomFile::new(&at, name).add_lines(400); + RandomFile::new(at, name).add_lines(400); scene .ucmd() @@ -613,9 +613,9 @@ fn test_split_multiple_obs_lines_within_combined() { .succeeds() .no_stderr() .no_stdout(); - let glob = Glob::new(&at, ".", r"x\d\d$"); + let glob = Glob::new(at, ".", r"x\d\d$"); assert_eq!(glob.count(), 2); - assert_eq!(glob.collate(), at.read_bytes(name)) + assert_eq!(glob.collate(), at.read_bytes(name)); } /// Test for using both obsolete lines option within combined shorts with conflicting -n option simultaneously @@ -1543,8 +1543,8 @@ fn test_split_separator_nul_lines() { ucmd.args(&["--lines=2", "-t", "\\0", "separator_nul.txt"]) .succeeds(); - assert_eq!(file_read(&at, "xaa"), "1\02\0"); - assert_eq!(file_read(&at, "xab"), "3\04\0"); + assert_eq!(file_read(&at, "xaa"), "1\x002\0"); + assert_eq!(file_read(&at, "xab"), "3\x004\0"); assert_eq!(file_read(&at, "xac"), "5\0"); assert!(!at.plus("xad").exists()); } @@ -1555,8 +1555,8 @@ fn test_split_separator_nul_line_bytes() { ucmd.args(&["--line-bytes=4", "-t", "\\0", "separator_nul.txt"]) .succeeds(); - assert_eq!(file_read(&at, "xaa"), "1\02\0"); - assert_eq!(file_read(&at, "xab"), "3\04\0"); + assert_eq!(file_read(&at, "xaa"), "1\x002\0"); + assert_eq!(file_read(&at, "xab"), "3\x004\0"); assert_eq!(file_read(&at, "xac"), "5\0"); assert!(!at.plus("xad").exists()); } @@ -1567,8 +1567,8 @@ fn test_split_separator_nul_number_l() { ucmd.args(&["--number=l/3", "--separator=\\0", "separator_nul.txt"]) .succeeds(); - assert_eq!(file_read(&at, "xaa"), "1\02\0"); - assert_eq!(file_read(&at, "xab"), "3\04\0"); + assert_eq!(file_read(&at, "xaa"), "1\x002\0"); + assert_eq!(file_read(&at, "xab"), "3\x004\0"); assert_eq!(file_read(&at, "xac"), "5\0"); assert!(!at.plus("xad").exists()); } @@ -1579,8 +1579,8 @@ fn test_split_separator_nul_number_r() { ucmd.args(&["--number=r/3", "--separator=\\0", "separator_nul.txt"]) .succeeds(); - assert_eq!(file_read(&at, "xaa"), "1\04\0"); - assert_eq!(file_read(&at, "xab"), "2\05\0"); + assert_eq!(file_read(&at, "xaa"), "1\x004\0"); + assert_eq!(file_read(&at, "xab"), "2\x005\0"); assert_eq!(file_read(&at, "xac"), "3\0"); assert!(!at.plus("xad").exists()); } diff --git a/tests/by-util/test_tee.rs b/tests/by-util/test_tee.rs index 6f04edfc3..2b3fd2670 100644 --- a/tests/by-util/test_tee.rs +++ b/tests/by-util/test_tee.rs @@ -3,6 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. use crate::common::util::TestScenario; +use std::fmt::Write; // tests for basic tee functionality. // inspired by: @@ -74,7 +75,10 @@ fn test_tee_append() { fn test_tee_no_more_writeable_1() { // equals to 'tee /dev/full out2 (); + let content = (1..=10).fold(String::new(), |mut output, x| { + let _ = writeln!(output, "{x}"); + output + }); let file_out = "tee_file_out"; ucmd.arg("/dev/full") @@ -94,7 +98,10 @@ fn test_tee_no_more_writeable_2() { // but currently there is no way to redirect stdout to /dev/full // so this test is disabled let (_at, mut ucmd) = at_and_ucmd!(); - let _content = (1..=10).map(|x| format!("{x}\n")).collect::(); + let _content = (1..=10).fold(String::new(), |mut output, x| { + let _ = writeln!(output, "{x}"); + output + }); let file_out_a = "tee_file_out_a"; let file_out_b = "tee_file_out_b"; @@ -114,6 +121,7 @@ fn test_tee_no_more_writeable_2() { mod linux_only { use crate::common::util::{AtPath, TestScenario, UCommand}; + use std::fmt::Write; use std::fs::File; use std::process::{Output, Stdio}; @@ -135,7 +143,10 @@ mod linux_only { } fn run_tee(proc: &mut UCommand) -> (String, Output) { - let content = (1..=100_000).map(|x| format!("{x}\n")).collect::(); + let content = (1..=100_000).fold(String::new(), |mut output, x| { + let _ = writeln!(output, "{x}"); + output + }); #[allow(deprecated)] let output = proc From fa2a14ccd262f102ca04e47529d5f79a556a1692 Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Fri, 6 Oct 2023 22:55:30 +0800 Subject: [PATCH 264/370] expr: unify debug message --- src/uu/expr/src/syntax_tree.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index b3cd329ba..335405d06 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -52,7 +52,7 @@ impl AstNode { operands, } => { println!( - "Node( {} ) at #{} (evaluate -> {:?})", + "Node( {} ) at #{} ( evaluate -> {:?} )", op_type, token_idx, self.evaluate() From 6091bafe08178f88f57aed9d28a1e1dda659bfd4 Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Mon, 25 Sep 2023 18:24:20 -0400 Subject: [PATCH 265/370] feat(mv): expose functionality, document for nushell --- src/uu/mv/src/mv.rs | 169 +++++++++++++++++++++++++++++--------------- 1 file changed, 112 insertions(+), 57 deletions(-) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 43f8eb6b6..267179bbf 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) sourcepath targetpath +// spell-checker:ignore (ToDO) sourcepath targetpath nushell mod error; @@ -23,6 +23,7 @@ use uucore::backup_control::{self, source_is_target_backup, BackupMode}; use uucore::display::Quotable; use uucore::error::{set_exit_code, FromIo, UError, UResult, USimpleError, UUsageError}; use uucore::fs::{are_hardlinks_or_one_way_symlink_to_same_file, are_hardlinks_to_same_file}; +use uucore::libc::ENOTEMPTY; use uucore::update_control::{self, UpdateMode}; use uucore::{format_usage, help_about, help_section, help_usage, prompt_yes, show}; @@ -32,23 +33,56 @@ use fs_extra::dir::{ }; use crate::error::MvError; +/// Options contains all the possible behaviors and flags for mv. +/// +/// All options are public so that the options can be programmatically +/// constructed by other crates, such as nushell. That means that this struct +/// is part of our public API. It should therefore not be changed without good +/// reason. +/// The fields are documented with the arguments that determine their value. +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct Options { + /// specifies overwrite behavior + /// '-n' '--no-clobber' + /// '-i' '--interactive' + /// '-f' '--force' + pub overwrite: OverwriteMode, -pub struct Behavior { - overwrite: OverwriteMode, - backup: BackupMode, - suffix: String, - update: UpdateMode, - target_dir: Option, - no_target_dir: bool, - verbose: bool, - strip_slashes: bool, - progress_bar: bool, + /// `--backup[=CONTROL]`, `-b` + pub backup: BackupMode, + + /// '-S' --suffix' backup suffix + pub suffix: String, + + /// Available update mode "--update-mode=all|none|older" + pub update: UpdateMode, + + /// Specifies target directory + /// '-t, --target-directory=DIRECTORY' + pub target_dir: Option, + + /// Treat destination as a normal file + /// '-T, --no-target-directory + pub no_target_dir: bool, + + /// '-v, --verbose' + pub verbose: bool, + + /// '--strip-trailing-slashes' + pub strip_slashes: bool, + + /// '-g, --progress' + pub progress_bar: bool, } -#[derive(Clone, Eq, PartialEq)] +/// specifies behavior of the overwrite flag +#[derive(Clone, Debug, Eq, PartialEq)] pub enum OverwriteMode { + /// '-n' '--no-clobber' do not overwrite NoClobber, + /// '-i' '--interactive' prompt before overwrite Interactive, + ///'-f' '--force' overwrite without prompt Force, } @@ -116,7 +150,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } - let behavior = Behavior { + let opts = Options { overwrite: overwrite_mode, backup: backup_mode, suffix: backup_suffix, @@ -128,7 +162,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { progress_bar: matches.get_flag(OPT_PROGRESS), }; - exec(&files[..], &behavior) + exec_mv(&files[..], &opts) } pub fn uu_app() -> Command { @@ -220,7 +254,7 @@ pub fn uu_app() -> Command { ) } -fn determine_overwrite_mode(matches: &ArgMatches) -> OverwriteMode { +pub fn determine_overwrite_mode(matches: &ArgMatches) -> OverwriteMode { // This does not exactly match the GNU implementation: // The GNU mv defaults to Force, but if more than one of the // overwrite options are supplied, only the last takes effect. @@ -235,10 +269,10 @@ fn determine_overwrite_mode(matches: &ArgMatches) -> OverwriteMode { } } -fn parse_paths(files: &[OsString], b: &Behavior) -> Vec { +fn parse_paths(files: &[OsString], opts: &Options) -> Vec { let paths = files.iter().map(Path::new); - if b.strip_slashes { + if opts.strip_slashes { paths .map(|p| p.components().as_path().to_owned()) .collect::>() @@ -247,8 +281,10 @@ fn parse_paths(files: &[OsString], b: &Behavior) -> Vec { } } -fn handle_two_paths(source: &Path, target: &Path, b: &Behavior) -> UResult<()> { - if b.backup == BackupMode::SimpleBackup && source_is_target_backup(source, target, &b.suffix) { +fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()> { + if opts.backup == BackupMode::SimpleBackup + && source_is_target_backup(source, target, &opts.suffix) + { return Err(io::Error::new( io::ErrorKind::NotFound, format!( @@ -266,7 +302,7 @@ fn handle_two_paths(source: &Path, target: &Path, b: &Behavior) -> UResult<()> { if (source.eq(target) || are_hardlinks_to_same_file(source, target) || are_hardlinks_or_one_way_symlink_to_same_file(source, target)) - && b.backup == BackupMode::NoBackup + && opts.backup == BackupMode::NoBackup { if source.eq(Path::new(".")) || source.ends_with("/.") || source.is_file() { return Err( @@ -278,19 +314,19 @@ fn handle_two_paths(source: &Path, target: &Path, b: &Behavior) -> UResult<()> { } if target.is_dir() { - if b.no_target_dir { + if opts.no_target_dir { if source.is_dir() { - rename(source, target, b, None).map_err_context(|| { + rename(source, target, opts, None).map_err_context(|| { format!("cannot move {} to {}", source.quote(), target.quote()) }) } else { Err(MvError::DirectoryToNonDirectory(target.quote().to_string()).into()) } } else { - move_files_into_dir(&[source.to_path_buf()], target, b) + move_files_into_dir(&[source.to_path_buf()], target, opts) } } else if target.exists() && source.is_dir() { - match b.overwrite { + match opts.overwrite { OverwriteMode::NoClobber => return Ok(()), OverwriteMode::Interactive => { if !prompt_yes!("overwrite {}? ", target.quote()) { @@ -305,12 +341,12 @@ fn handle_two_paths(source: &Path, target: &Path, b: &Behavior) -> UResult<()> { ) .into()) } else { - rename(source, target, b, None).map_err(|e| USimpleError::new(1, format!("{e}"))) + rename(source, target, opts, None).map_err(|e| USimpleError::new(1, format!("{e}"))) } } -fn handle_multiple_paths(paths: &[PathBuf], b: &Behavior) -> UResult<()> { - if b.no_target_dir { +fn handle_multiple_paths(paths: &[PathBuf], opts: &Options) -> UResult<()> { + if opts.no_target_dir { return Err(UUsageError::new( 1, format!("mv: extra operand {}", paths[2].quote()), @@ -319,24 +355,29 @@ fn handle_multiple_paths(paths: &[PathBuf], b: &Behavior) -> UResult<()> { let target_dir = paths.last().unwrap(); let sources = &paths[..paths.len() - 1]; - move_files_into_dir(sources, target_dir, b) + move_files_into_dir(sources, target_dir, opts) } -fn exec(files: &[OsString], b: &Behavior) -> UResult<()> { - let paths = parse_paths(files, b); +/// Execute mv command, moving 'source' to 'target', where +/// 'target' is a directory. If 'target' does not exist, and source is a single +/// file or directory, then 'source' will be renamed to 'target'. +/// +/// returns MvError | UError +pub fn exec_mv(files: &[OsString], opts: &Options) -> UResult<()> { + let paths = parse_paths(files, opts); - if let Some(ref name) = b.target_dir { - return move_files_into_dir(&paths, &PathBuf::from(name), b); + if let Some(ref name) = opts.target_dir { + return move_files_into_dir(&paths, &PathBuf::from(name), opts); } match paths.len() { - 2 => handle_two_paths(&paths[0], &paths[1], b), - _ => handle_multiple_paths(&paths, b), + 2 => handle_two_paths(&paths[0], &paths[1], opts), + _ => handle_multiple_paths(&paths, opts), } } #[allow(clippy::cognitive_complexity)] -fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> UResult<()> { +fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, opts: &Options) -> UResult<()> { if !target_dir.is_dir() { return Err(MvError::NotADirectory(target_dir.quote().to_string()).into()); } @@ -345,7 +386,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> UR .canonicalize() .unwrap_or_else(|_| target_dir.to_path_buf()); - let multi_progress = b.progress_bar.then(MultiProgress::new); + let multi_progress = opts.progress_bar.then(MultiProgress::new); let count_progress = if let Some(ref multi_progress) = multi_progress { if files.len() > 1 { @@ -396,24 +437,37 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> UR } } - match rename(sourcepath, &targetpath, b, multi_progress.as_ref()) { + match rename(sourcepath, &targetpath, opts, multi_progress.as_ref()) { Err(e) if e.to_string().is_empty() => set_exit_code(1), Err(e) => { - let e = e.map_err_context(|| { - format!( - "cannot move {} to {}", - sourcepath.quote(), - targetpath.quote() - ) - }); - match multi_progress { - Some(ref pb) => pb.suspend(|| show!(e)), - None => show!(e), - }; + match e.raw_os_error() { + Some(ENOTEMPTY) => { + // The error message was changed to match GNU's decision + // when an issue was filed. These will match when merged upstream. + let e = e + .map_err_context(|| format!("cannot overwrite {}", targetpath.quote())); + match multi_progress { + Some(ref pb) => pb.suspend(|| show!(e)), + None => show!(e), + }; + } + _ => { + let e = e.map_err_context(|| { + format!( + "cannot move {} to {}", + sourcepath.quote(), + targetpath.quote() + ) + }); + match multi_progress { + Some(ref pb) => pb.suspend(|| show!(e)), + None => show!(e), + }; + } + } } Ok(()) => (), } - if let Some(ref pb) = count_progress { pb.inc(1); } @@ -424,29 +478,30 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, b: &Behavior) -> UR fn rename( from: &Path, to: &Path, - b: &Behavior, + opts: &Options, multi_progress: Option<&MultiProgress>, ) -> io::Result<()> { let mut backup_path = None; if to.exists() { - if b.update == UpdateMode::ReplaceIfOlder && b.overwrite == OverwriteMode::Interactive { + if opts.update == UpdateMode::ReplaceIfOlder && opts.overwrite == OverwriteMode::Interactive + { // `mv -i --update old new` when `new` exists doesn't move anything // and exit with 0 return Ok(()); } - if b.update == UpdateMode::ReplaceNone { + if opts.update == UpdateMode::ReplaceNone { return Ok(()); } - if (b.update == UpdateMode::ReplaceIfOlder) + if (opts.update == UpdateMode::ReplaceIfOlder) && fs::metadata(from)?.modified()? <= fs::metadata(to)?.modified()? { return Ok(()); } - match b.overwrite { + match opts.overwrite { OverwriteMode::NoClobber => { let err_msg = format!("not replacing {}", to.quote()); return Err(io::Error::new(io::ErrorKind::Other, err_msg)); @@ -459,7 +514,7 @@ fn rename( OverwriteMode::Force => {} }; - backup_path = backup_control::get_backup_path(b.backup, to, &b.suffix); + backup_path = backup_control::get_backup_path(opts.backup, to, &opts.suffix); if let Some(ref backup_path) = backup_path { rename_with_fallback(to, backup_path, multi_progress)?; } @@ -472,14 +527,14 @@ fn rename( if is_empty_dir(to) { fs::remove_dir(to)?; } else { - return Err(io::Error::new(io::ErrorKind::Other, "Directory not empty")); + return Err(io::Error::from_raw_os_error(ENOTEMPTY)); } } } rename_with_fallback(from, to, multi_progress)?; - if b.verbose { + if opts.verbose { let message = match backup_path { Some(path) => format!( "renamed {} -> {} (backup: {})", From 4a44a106a0442cf53f02efb2fc317a9b695125e9 Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Thu, 28 Sep 2023 15:11:48 -0400 Subject: [PATCH 266/370] feat: expose mv externals + document for nushell --- src/uu/mv/src/mv.rs | 59 +++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 37 deletions(-) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 267179bbf..9888389ae 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -19,11 +19,11 @@ use std::os::unix; #[cfg(windows)] use std::os::windows; use std::path::{Path, PathBuf}; -use uucore::backup_control::{self, source_is_target_backup, BackupMode}; +pub use uucore::backup_control::BackupMode; +use uucore::backup_control::{self, source_is_target_backup}; use uucore::display::Quotable; use uucore::error::{set_exit_code, FromIo, UError, UResult, USimpleError, UUsageError}; use uucore::fs::{are_hardlinks_or_one_way_symlink_to_same_file, are_hardlinks_to_same_file}; -use uucore::libc::ENOTEMPTY; use uucore::update_control::{self, UpdateMode}; use uucore::{format_usage, help_about, help_section, help_usage, prompt_yes, show}; @@ -33,12 +33,13 @@ use fs_extra::dir::{ }; use crate::error::MvError; + /// Options contains all the possible behaviors and flags for mv. /// /// All options are public so that the options can be programmatically -/// constructed by other crates, such as nushell. That means that this struct -/// is part of our public API. It should therefore not be changed without good -/// reason. +/// constructed by other crates, such as nushell. That means that this struct is +/// part of our public API. It should therefore not be changed without good reason. +/// /// The fields are documented with the arguments that determine their value. #[derive(Debug, Clone, Eq, PartialEq)] pub struct Options { @@ -162,7 +163,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { progress_bar: matches.get_flag(OPT_PROGRESS), }; - exec_mv(&files[..], &opts) + mv(&files[..], &opts) } pub fn uu_app() -> Command { @@ -254,7 +255,7 @@ pub fn uu_app() -> Command { ) } -pub fn determine_overwrite_mode(matches: &ArgMatches) -> OverwriteMode { +fn determine_overwrite_mode(matches: &ArgMatches) -> OverwriteMode { // This does not exactly match the GNU implementation: // The GNU mv defaults to Force, but if more than one of the // overwrite options are supplied, only the last takes effect. @@ -358,12 +359,10 @@ fn handle_multiple_paths(paths: &[PathBuf], opts: &Options) -> UResult<()> { move_files_into_dir(sources, target_dir, opts) } -/// Execute mv command, moving 'source' to 'target', where +/// Execute the mv command. This moves 'source' to 'target', where /// 'target' is a directory. If 'target' does not exist, and source is a single /// file or directory, then 'source' will be renamed to 'target'. -/// -/// returns MvError | UError -pub fn exec_mv(files: &[OsString], opts: &Options) -> UResult<()> { +pub fn mv(files: &[OsString], opts: &Options) -> UResult<()> { let paths = parse_paths(files, opts); if let Some(ref name) = opts.target_dir { @@ -440,31 +439,17 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, opts: &Options) -> match rename(sourcepath, &targetpath, opts, multi_progress.as_ref()) { Err(e) if e.to_string().is_empty() => set_exit_code(1), Err(e) => { - match e.raw_os_error() { - Some(ENOTEMPTY) => { - // The error message was changed to match GNU's decision - // when an issue was filed. These will match when merged upstream. - let e = e - .map_err_context(|| format!("cannot overwrite {}", targetpath.quote())); - match multi_progress { - Some(ref pb) => pb.suspend(|| show!(e)), - None => show!(e), - }; - } - _ => { - let e = e.map_err_context(|| { - format!( - "cannot move {} to {}", - sourcepath.quote(), - targetpath.quote() - ) - }); - match multi_progress { - Some(ref pb) => pb.suspend(|| show!(e)), - None => show!(e), - }; - } - } + let e = e.map_err_context(|| { + format!( + "cannot move {} to {}", + sourcepath.quote(), + targetpath.quote() + ) + }); + match multi_progress { + Some(ref pb) => pb.suspend(|| show!(e)), + None => show!(e), + }; } Ok(()) => (), } @@ -527,7 +512,7 @@ fn rename( if is_empty_dir(to) { fs::remove_dir(to)?; } else { - return Err(io::Error::from_raw_os_error(ENOTEMPTY)); + return Err(io::Error::new(io::ErrorKind::Other, "Directory not empty")); } } } From 2c2e01205cfbe4b6337a207102485fd2dc64e443 Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Fri, 6 Oct 2023 23:50:22 +0800 Subject: [PATCH 267/370] expr: short-circuit evaluation for | --- src/uu/expr/src/syntax_tree.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index 335405d06..ad421edb7 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -155,8 +155,24 @@ impl AstNode { } } pub fn operand_values(&self) -> Result, String> { - if let Self::Node { operands, .. } = self { + if let Self::Node { + operands, op_type, .. + } = self + { let mut out = Vec::with_capacity(operands.len()); + let mut operands = operands.iter(); + + if op_type == "|" { + if let Some(value) = operands.next() { + let value = value.evaluate()?; + out.push(value.clone()); + if value_as_bool(&value) { + out.push(String::from("dummy")); + return Ok(out); + } + } + } + for operand in operands { let value = operand.evaluate()?; out.push(value); From 5a732dd21a9aa0987f973eda4ffe919b9985be29 Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Fri, 6 Oct 2023 23:50:44 +0800 Subject: [PATCH 268/370] tests/expr: add test expr 1 \| a / 5 --- tests/by-util/test_expr.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index ea5a964d9..99445d566 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -123,6 +123,11 @@ fn test_or() { .args(&["-14", "|", "1"]) .succeeds() .stdout_only("-14\n"); + + new_ucmd!() + .args(&["1", "|", "a", "/", "5"]) + .succeeds() + .stdout_only("1\n"); } #[test] From 0df561e256905c9477bd316b68a9fb56d36a47c6 Mon Sep 17 00:00:00 2001 From: Luv_Ray Date: Sat, 7 Oct 2023 00:19:56 +0800 Subject: [PATCH 269/370] expr: add comment in syntax_tree.rs --- src/uu/expr/src/syntax_tree.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index ad421edb7..eaa6be1f5 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -161,7 +161,8 @@ impl AstNode { { let mut out = Vec::with_capacity(operands.len()); let mut operands = operands.iter(); - + // check the first value before `|`, stop evaluate and return directly if it is true. + // push dummy to pass the check of `len() == 2` if op_type == "|" { if let Some(value) = operands.next() { let value = value.evaluate()?; From 7bf4b7f6748812e29daf3fb91180e4dfceb6ce30 Mon Sep 17 00:00:00 2001 From: Luv_Ray Date: Sat, 7 Oct 2023 00:42:04 +0800 Subject: [PATCH 270/370] tests/expr: add tests in test_expr.rs --- tests/by-util/test_expr.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index 99445d566..a463f086b 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -128,6 +128,16 @@ fn test_or() { .args(&["1", "|", "a", "/", "5"]) .succeeds() .stdout_only("1\n"); + + new_ucmd!() + .args(&["foo", "|", "a", "/", "5"]) + .succeeds() + .stdout_only("foo\n"); + + new_ucmd!() + .args(&["0", "|", "10", "/", "5"]) + .succeeds() + .stdout_only("2\n"); } #[test] From 98cfb0c322b33d571647ba7c0ac6831624266eae Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 6 Oct 2023 22:08:04 +0200 Subject: [PATCH 271/370] Binary sizes: handle when 0 (relpath removal) --- .github/workflows/CICD.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index a9f04e3cf..61c12dad0 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -610,6 +610,12 @@ jobs: check() { # Warn if the size increases by more than 5% threshold='1.05' + + if [[ "$2" -eq 0 || "$3" -eq 0 ]]; then + echo "::warning file=$4::Invalid size for $1. Sizes cannot be 0." + return + fi + ratio=$(jq -n "$2 / $3") echo "$1: size=$2, previous_size=$3, ratio=$ratio, threshold=$threshold" if [[ "$(jq -n "$ratio > $threshold")" == 'true' ]]; then From e5d70d444ae7ca3a3100190ea87c22edfecab121 Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Sat, 7 Oct 2023 10:41:10 +0800 Subject: [PATCH 272/370] tests/expr: format --- tests/by-util/test_expr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index a463f086b..4637d51c7 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -128,7 +128,7 @@ fn test_or() { .args(&["1", "|", "a", "/", "5"]) .succeeds() .stdout_only("1\n"); - + new_ucmd!() .args(&["foo", "|", "a", "/", "5"]) .succeeds() From 959bfa0160165b8ed23f1db4cd9ea43264f3aadd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 7 Oct 2023 02:43:46 +0000 Subject: [PATCH 273/370] chore(deps): update rust crate libc to 0.2.149 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a2c872e2d..a3c3e7096 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1200,9 +1200,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.148" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libloading" diff --git a/Cargo.toml b/Cargo.toml index 783c84ccf..e59ed7bd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -286,7 +286,7 @@ glob = "0.3.1" half = "2.3" indicatif = "0.17" itertools = "0.11.0" -libc = "0.2.148" +libc = "0.2.149" lscolors = { version = "0.15.0", default-features = false, features = [ "nu-ansi-term", ] } From e1b7f254a63a00b1b33a8842ca6280b183df8eb6 Mon Sep 17 00:00:00 2001 From: Sanpi Date: Sat, 7 Oct 2023 10:39:19 +0200 Subject: [PATCH 274/370] ls: fix panic when file removed too quickly Fixes #5371 --- src/uu/ls/src/ls.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 301aefaf3..c80d4cbe6 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -2888,7 +2888,11 @@ fn classify_file(path: &PathData, out: &mut BufWriter) -> Option { Some('=') } else if file_type.is_fifo() { Some('|') - } else if file_type.is_file() && file_is_executable(path.md(out).as_ref().unwrap()) { + } else if file_type.is_file() + // Safe unwrapping if the file was removed between listing and display + // See https://github.com/uutils/coreutils/issues/5371 + && path.md(out).map(file_is_executable).unwrap_or_default() + { Some('*') } else { None From 3e1d3cacebe447dfa4efa8d5b722abc9ad0bca3d Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 7 Oct 2023 13:37:24 +0200 Subject: [PATCH 275/370] head: remove clippy::cognitive_complexity by moving some content in a function (#5366) * head: remove a clippy::cognitive_complexity by moving some content into a function * Remove duplicate comment --- src/uu/head/src/parse.rs | 129 +++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 60 deletions(-) diff --git a/src/uu/head/src/parse.rs b/src/uu/head/src/parse.rs index 90e1f2ce0..179435c7a 100644 --- a/src/uu/head/src/parse.rs +++ b/src/uu/head/src/parse.rs @@ -13,7 +13,6 @@ pub enum ParseError { } /// Parses obsolete syntax /// head -NUM\[kmzv\] // spell-checker:disable-line -#[allow(clippy::cognitive_complexity)] pub fn parse_obsolete(src: &str) -> Option, ParseError>> { let mut chars = src.char_indices(); if let Some((_, '-')) = chars.next() { @@ -30,65 +29,7 @@ pub fn parse_obsolete(src: &str) -> Option } } if has_num { - match src[1..=num_end].parse::() { - Ok(num) => { - let mut quiet = false; - let mut verbose = false; - let mut zero_terminated = false; - let mut multiplier = None; - let mut c = last_char; - loop { - // not that here, we only match lower case 'k', 'c', and 'm' - match c { - // we want to preserve order - // this also saves us 1 heap allocation - 'q' => { - quiet = true; - verbose = false; - } - 'v' => { - verbose = true; - quiet = false; - } - 'z' => zero_terminated = true, - 'c' => multiplier = Some(1), - 'b' => multiplier = Some(512), - 'k' => multiplier = Some(1024), - 'm' => multiplier = Some(1024 * 1024), - '\0' => {} - _ => return Some(Err(ParseError::Syntax)), - } - if let Some((_, next)) = chars.next() { - c = next; - } else { - break; - } - } - let mut options = Vec::new(); - if quiet { - options.push(OsString::from("-q")); - } - if verbose { - options.push(OsString::from("-v")); - } - if zero_terminated { - options.push(OsString::from("-z")); - } - if let Some(n) = multiplier { - options.push(OsString::from("-c")); - let num = match num.checked_mul(n) { - Some(n) => n, - None => return Some(Err(ParseError::Overflow)), - }; - options.push(OsString::from(format!("{num}"))); - } else { - options.push(OsString::from("-n")); - options.push(OsString::from(format!("{num}"))); - } - Some(Ok(options.into_iter())) - } - Err(_) => Some(Err(ParseError::Overflow)), - } + process_num_block(&src[1..=num_end], last_char, &mut chars) } else { None } @@ -96,6 +37,74 @@ pub fn parse_obsolete(src: &str) -> Option None } } + +/// Processes the numeric block of the input string to generate the appropriate options. +fn process_num_block( + src: &str, + last_char: char, + chars: &mut std::str::CharIndices, +) -> Option, ParseError>> { + match src.parse::() { + Ok(num) => { + let mut quiet = false; + let mut verbose = false; + let mut zero_terminated = false; + let mut multiplier = None; + let mut c = last_char; + loop { + // note that here, we only match lower case 'k', 'c', and 'm' + match c { + // we want to preserve order + // this also saves us 1 heap allocation + 'q' => { + quiet = true; + verbose = false; + } + 'v' => { + verbose = true; + quiet = false; + } + 'z' => zero_terminated = true, + 'c' => multiplier = Some(1), + 'b' => multiplier = Some(512), + 'k' => multiplier = Some(1024), + 'm' => multiplier = Some(1024 * 1024), + '\0' => {} + _ => return Some(Err(ParseError::Syntax)), + } + if let Some((_, next)) = chars.next() { + c = next; + } else { + break; + } + } + let mut options = Vec::new(); + if quiet { + options.push(OsString::from("-q")); + } + if verbose { + options.push(OsString::from("-v")); + } + if zero_terminated { + options.push(OsString::from("-z")); + } + if let Some(n) = multiplier { + options.push(OsString::from("-c")); + let num = match num.checked_mul(n) { + Some(n) => n, + None => return Some(Err(ParseError::Overflow)), + }; + options.push(OsString::from(format!("{num}"))); + } else { + options.push(OsString::from("-n")); + options.push(OsString::from(format!("{num}"))); + } + Some(Ok(options.into_iter())) + } + Err(_) => Some(Err(ParseError::Overflow)), + } +} + /// Parses an -c or -n argument, /// the bool specifies whether to read from the end pub fn parse_num(src: &str) -> Result<(u64, bool), ParseSizeError> { From 2ba7400d05ec32320acdd52a395546c9ee0f2327 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 7 Oct 2023 15:15:44 +0200 Subject: [PATCH 276/370] clippy: suppress cognitive_complexity lint for two functions --- src/uu/ls/src/ls.rs | 1 + src/uu/split/src/split.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 301aefaf3..9dec8749d 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1856,6 +1856,7 @@ impl PathData { } } +#[allow(clippy::cognitive_complexity)] pub fn list(locs: Vec<&Path>, config: &Config) -> UResult<()> { let mut files = Vec::::new(); let mut dirs = Vec::::new(); diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 756248539..bfd595e4f 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -1714,6 +1714,7 @@ where Ok(()) } +#[allow(clippy::cognitive_complexity)] fn split(settings: &Settings) -> UResult<()> { let mut reader = BufReader::new(if settings.input == "-" { Box::new(stdin()) as Box From f86469f6d5c6d0903162aa04cedf872fc0520d67 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 7 Oct 2023 14:11:15 +0200 Subject: [PATCH 277/370] head: add some empty lines --- src/uu/head/src/head.rs | 13 ++++++++++++- src/uu/head/src/parse.rs | 8 ++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index c60bbfe99..d6e4db5a7 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (vars) zlines BUFWRITER seekable +// spell-checker:ignore (vars) BUFWRITER seekable use clap::{crate_version, Arg, ArgAction, ArgMatches, Command}; use std::ffi::OsString; @@ -31,6 +31,7 @@ mod options { pub const FILES_NAME: &str = "FILE"; pub const PRESUME_INPUT_PIPE: &str = "-PRESUME-INPUT-PIPE"; } + mod parse; mod take; use take::take_all_but; @@ -519,6 +520,7 @@ mod tests { use std::io::Cursor; use super::*; + fn options(args: &str) -> Result { let combined = "head ".to_owned() + args; let args = combined.split_whitespace().map(OsString::from); @@ -526,6 +528,7 @@ mod tests { .get_matches_from(arg_iterate(args).map_err(|_| String::from("Arg iterate failed"))?); HeadOptions::get_from(&matches) } + #[test] fn test_args_modes() { let args = options("-n -10M -vz").unwrap(); @@ -533,6 +536,7 @@ mod tests { assert!(args.verbose); assert_eq!(args.mode, Mode::AllButLastLines(10 * 1024 * 1024)); } + #[test] fn test_gnu_compatibility() { let args = options("-n 1 -c 1 -n 5 -c kiB -vqvqv").unwrap(); // spell-checker:disable-line @@ -542,6 +546,7 @@ mod tests { assert_eq!(options("-2b").unwrap().mode, Mode::FirstBytes(1024)); assert_eq!(options("-5 -c 1").unwrap().mode, Mode::FirstBytes(1)); } + #[test] fn all_args_test() { assert!(options("--silent").unwrap().quiet); @@ -559,11 +564,13 @@ mod tests { assert_eq!(options("--bytes 15").unwrap().mode, Mode::FirstBytes(15)); assert_eq!(options("-c 15").unwrap().mode, Mode::FirstBytes(15)); } + #[test] fn test_options_errors() { assert!(options("-n IsThisTheRealLife?").is_err()); assert!(options("-c IsThisJustFantasy").is_err()); } + #[test] fn test_options_correct_defaults() { let opts = HeadOptions::default(); @@ -574,6 +581,7 @@ mod tests { assert_eq!(opts.mode, Mode::FirstLines(10)); assert!(opts.files.is_empty()); } + fn arg_outputs(src: &str) -> Result { let split = src.split_whitespace().map(OsString::from); match arg_iterate(split) { @@ -586,6 +594,7 @@ mod tests { Err(_) => Err(()), } } + #[test] fn test_arg_iterate() { // test that normal args remain unchanged @@ -610,6 +619,7 @@ mod tests { //test that empty args remain unchanged assert_eq!(arg_outputs("head"), Ok("head".to_owned())); } + #[test] #[cfg(target_os = "linux")] fn test_arg_iterate_bad_encoding() { @@ -618,6 +628,7 @@ mod tests { // this arises from a conversion from OsString to &str assert!(arg_iterate(vec![OsString::from("head"), invalid].into_iter()).is_err()); } + #[test] fn read_early_exit() { let mut empty = std::io::BufReader::new(std::io::Cursor::new(Vec::new())); diff --git a/src/uu/head/src/parse.rs b/src/uu/head/src/parse.rs index 179435c7a..7f7dd48f8 100644 --- a/src/uu/head/src/parse.rs +++ b/src/uu/head/src/parse.rs @@ -11,6 +11,7 @@ pub enum ParseError { Syntax, Overflow, } + /// Parses obsolete syntax /// head -NUM\[kmzv\] // spell-checker:disable-line pub fn parse_obsolete(src: &str) -> Option, ParseError>> { @@ -135,6 +136,7 @@ pub fn parse_num(src: &str) -> Result<(u64, bool), ParseSizeError> { #[cfg(test)] mod tests { use super::*; + fn obsolete(src: &str) -> Option, ParseError>> { let r = parse_obsolete(src); match r { @@ -145,9 +147,11 @@ mod tests { None => None, } } + fn obsolete_result(src: &[&str]) -> Option, ParseError>> { Some(Ok(src.iter().map(|s| s.to_string()).collect())) } + #[test] fn test_parse_numbers_obsolete() { assert_eq!(obsolete("-5"), obsolete_result(&["-n", "5"])); @@ -167,16 +171,19 @@ mod tests { obsolete_result(&["-z", "-c", "110100480"]) ); } + #[test] fn test_parse_errors_obsolete() { assert_eq!(obsolete("-5n"), Some(Err(ParseError::Syntax))); assert_eq!(obsolete("-5c5"), Some(Err(ParseError::Syntax))); } + #[test] fn test_parse_obsolete_no_match() { assert_eq!(obsolete("-k"), None); assert_eq!(obsolete("asd"), None); } + #[test] #[cfg(target_pointer_width = "64")] fn test_parse_obsolete_overflow_x64() { @@ -189,6 +196,7 @@ mod tests { Some(Err(ParseError::Overflow)) ); } + #[test] #[cfg(target_pointer_width = "32")] fn test_parse_obsolete_overflow_x32() { From 849051f9681b7d65b319942ae0c3bcd8fbe234b4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 7 Oct 2023 22:22:06 +0000 Subject: [PATCH 278/370] chore(deps): update rust crate num-traits to 0.2.17 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3c3e7096..197368abf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1404,9 +1404,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] diff --git a/Cargo.toml b/Cargo.toml index e59ed7bd7..8eecb2b8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -296,7 +296,7 @@ nix = { version = "0.27", default-features = false } nom = "7.1.3" notify = { version = "=6.0.1", features = ["macos_kqueue"] } num-bigint = "0.4.4" -num-traits = "0.2.16" +num-traits = "0.2.17" number_prefix = "0.4" once_cell = "1.18.0" onig = { version = "~6.4", default-features = false } From 7e08562ee6bc71fb5e6b6d0aa19a80549627f5eb Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 8 Oct 2023 15:02:01 +0200 Subject: [PATCH 279/370] expr: add some empty lines --- src/uu/expr/src/syntax_tree.rs | 8 ++++++++ src/uu/expr/src/tokens.rs | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index eaa6be1f5..4ca723a4d 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -31,10 +31,12 @@ pub enum AstNode { operands: OperandsList, }, } + impl AstNode { fn debug_dump(&self) { self.debug_dump_impl(1); } + fn debug_dump_impl(&self, depth: usize) { for _ in 0..depth { print!("\t",); @@ -71,12 +73,14 @@ impl AstNode { operands, }) } + fn new_leaf(token_idx: usize, value: &str) -> Box { Box::new(Self::Leaf { token_idx, value: value.into(), }) } + pub fn evaluate(&self) -> Result { match self { Self::Leaf { value, .. } => Ok(value.clone()), @@ -154,6 +158,7 @@ impl AstNode { }, } } + pub fn operand_values(&self) -> Result, String> { if let Self::Node { operands, op_type, .. @@ -257,6 +262,7 @@ fn ast_from_rpn(rpn: &mut TokenStack) -> Result, String> { } } } + fn maybe_ast_node( token_idx: usize, op_type: &str, @@ -520,6 +526,7 @@ fn prefix_operator_substr(values: &[String]) -> String { fn bool_as_int(b: bool) -> u8 { u8::from(b) } + fn bool_as_string(b: bool) -> String { if b { "1".to_string() @@ -527,6 +534,7 @@ fn bool_as_string(b: bool) -> String { "0".to_string() } } + fn value_as_bool(s: &str) -> bool { if s.is_empty() { return false; diff --git a/src/uu/expr/src/tokens.rs b/src/uu/expr/src/tokens.rs index b4e4c7da5..3c5cac060 100644 --- a/src/uu/expr/src/tokens.rs +++ b/src/uu/expr/src/tokens.rs @@ -38,6 +38,7 @@ pub enum Token { value: String, }, } + impl Token { fn new_infix_op(v: &str, left_assoc: bool, precedence: u8) -> Self { Self::InfixOp { @@ -46,6 +47,7 @@ impl Token { value: v.into(), } } + fn new_value(v: &str) -> Self { Self::Value { value: v.into() } } @@ -56,12 +58,14 @@ impl Token { _ => false, } } + fn is_a_number(&self) -> bool { match self { Self::Value { value, .. } => value.parse::().is_ok(), _ => false, } } + fn is_a_close_paren(&self) -> bool { matches!(*self, Self::ParClose) } From 4ed58718a8bb0b167520c538df2c1722f8fffe45 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 8 Oct 2023 17:31:50 +0200 Subject: [PATCH 280/370] github action: extract the warnings into a variable --- .github/workflows/CICD.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 61c12dad0..f7db7b8a2 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -231,10 +231,11 @@ jobs: run: | ## `cargo clippy` lint testing unset fault + CLIPPY_FLAGS="-W clippy::default_trait_access -W clippy::manual_string_new" fault_type="${{ steps.vars.outputs.FAULT_TYPE }}" fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]') # * convert any warnings to GHA UI annotations; ref: - S=$(cargo clippy --all-targets ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_UTILITY_LIST_OPTIONS }} -- -W clippy::default_trait_access -W clippy::manual_string_new -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::${fault_type} file=\2,line=\3,col=\4::${fault_prefix}: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; fault=true ; } + S=$(cargo clippy --all-targets ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_UTILITY_LIST_OPTIONS }} -- ${CLIPPY_FLAGS} -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::${fault_type} file=\2,line=\3,col=\4::${fault_prefix}: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; fault=true ; } if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi style_spellcheck: From 6d245491563d5f40c7cfece8ffcfa49695e5ddc3 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 8 Oct 2023 17:32:03 +0200 Subject: [PATCH 281/370] github action: enable clippy::cognitive_complexity --- .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 f7db7b8a2..b448b76d0 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -231,7 +231,7 @@ jobs: run: | ## `cargo clippy` lint testing unset fault - CLIPPY_FLAGS="-W clippy::default_trait_access -W clippy::manual_string_new" + CLIPPY_FLAGS="-W clippy::default_trait_access -W clippy::manual_string_new -W clippy::cognitive_complexity" fault_type="${{ steps.vars.outputs.FAULT_TYPE }}" fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]') # * convert any warnings to GHA UI annotations; ref: From 5ac1aef20ec3d639db72207e537d84750c828c87 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 8 Oct 2023 17:34:37 +0200 Subject: [PATCH 282/370] github action: move the fuzzing action into it own file/task --- .github/workflows/CICD.yml | 50 --------------------------- .github/workflows/fuzzing.yml | 64 +++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/fuzzing.yml diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 61c12dad0..39eea1593 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -125,56 +125,6 @@ jobs: S=$(cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s\n" "$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::${fault_type} file=\1,line=\2::${fault_prefix}: \`cargo fmt\`: style violation (file:'\1', line:\2; use \`cargo fmt -- \"\1\"\`)/p" ; fault=true ; } if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi - fuzz: - name: Run the fuzzers - runs-on: ubuntu-latest - env: - RUN_FOR: 60 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly - - name: Install `cargo-fuzz` - run: cargo install cargo-fuzz - - uses: Swatinem/rust-cache@v2 - - name: Run fuzz_date for XX seconds - shell: bash - run: | - ## Run it - cd fuzz - cargo +nightly fuzz run fuzz_date -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - - name: Run fuzz_test for XX seconds - continue-on-error: true - shell: bash - run: | - ## Run it - cd fuzz - cargo +nightly fuzz run fuzz_test -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - - name: Run fuzz_expr for XX seconds - continue-on-error: true - shell: bash - run: | - ## Run it - cd fuzz - cargo +nightly fuzz run fuzz_expr -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - - name: Run fuzz_parse_glob for XX seconds - shell: bash - run: | - ## Run it - cd fuzz - cargo +nightly fuzz run fuzz_parse_glob -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - - name: Run fuzz_parse_size for XX seconds - shell: bash - run: | - ## Run it - cd fuzz - cargo +nightly fuzz run fuzz_parse_size -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - - name: Run fuzz_parse_time for XX seconds - shell: bash - run: | - ## Run it - cd fuzz - cargo +nightly fuzz run fuzz_parse_time -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - style_lint: name: Style/lint runs-on: ${{ matrix.job.os }} diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml new file mode 100644 index 000000000..677df2c9f --- /dev/null +++ b/.github/workflows/fuzzing.yml @@ -0,0 +1,64 @@ +name: Fuzzing + +# spell-checker:ignore fuzzer + +on: [push, pull_request] + +permissions: + contents: read # to fetch code (actions/checkout) + +# End the current execution if there is a new changeset in the PR. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + fuzz: + name: Run the fuzzers + runs-on: ubuntu-latest + env: + RUN_FOR: 60 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + - name: Install `cargo-fuzz` + run: cargo install cargo-fuzz + - uses: Swatinem/rust-cache@v2 + - name: Run fuzz_date for XX seconds + shell: bash + run: | + ## Run it + cd fuzz + cargo +nightly fuzz run fuzz_date -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 + - name: Run fuzz_test for XX seconds + continue-on-error: true + shell: bash + run: | + ## Run it + cd fuzz + cargo +nightly fuzz run fuzz_test -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 + - name: Run fuzz_expr for XX seconds + continue-on-error: true + shell: bash + run: | + ## Run it + cd fuzz + cargo +nightly fuzz run fuzz_expr -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 + - name: Run fuzz_parse_glob for XX seconds + shell: bash + run: | + ## Run it + cd fuzz + cargo +nightly fuzz run fuzz_parse_glob -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 + - name: Run fuzz_parse_size for XX seconds + shell: bash + run: | + ## Run it + cd fuzz + cargo +nightly fuzz run fuzz_parse_size -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 + - name: Run fuzz_parse_time for XX seconds + shell: bash + run: | + ## Run it + cd fuzz + cargo +nightly fuzz run fuzz_parse_time -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 From 8e8a91be5d4d9628542e23f0c4daaaced42622e4 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 8 Oct 2023 17:46:11 +0200 Subject: [PATCH 283/370] Ignore more cognitive_complexity --- src/uu/cp/src/copydir.rs | 1 + src/uu/id/src/id.rs | 1 + src/uu/install/src/install.rs | 1 + src/uu/od/src/inputdecoder.rs | 1 + src/uu/od/src/output_info.rs | 1 + src/uu/od/src/parse_inputs.rs | 2 ++ src/uu/od/src/parse_nrofbytes.rs | 1 + src/uu/od/src/peekreader.rs | 1 + src/uu/od/src/prn_char.rs | 2 ++ src/uu/od/src/prn_float.rs | 2 ++ src/uu/od/src/prn_int.rs | 2 ++ src/uu/stat/src/stat.rs | 2 ++ 12 files changed, 17 insertions(+) diff --git a/src/uu/cp/src/copydir.rs b/src/uu/cp/src/copydir.rs index ac44ce687..a8b941364 100644 --- a/src/uu/cp/src/copydir.rs +++ b/src/uu/cp/src/copydir.rs @@ -447,6 +447,7 @@ mod tests { use super::ends_with_slash_dot; #[test] + #[allow(clippy::cognitive_complexity)] fn test_ends_with_slash_dot() { assert!(ends_with_slash_dot("/.")); assert!(ends_with_slash_dot("./.")); diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 49ad54925..8b16ba8b7 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -109,6 +109,7 @@ struct State { } #[uucore::main] +#[allow(clippy::cognitive_complexity)] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?; diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index 02cf8345d..63ba52b1c 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -526,6 +526,7 @@ fn is_potential_directory_path(path: &Path) -> bool { /// /// Returns a Result type with the Err variant containing the error message. /// +#[allow(clippy::cognitive_complexity)] fn standard(mut paths: Vec, b: &Behavior) -> UResult<()> { // first check that paths contains at least one element if paths.is_empty() { diff --git a/src/uu/od/src/inputdecoder.rs b/src/uu/od/src/inputdecoder.rs index 6f08eba12..e63eaed14 100644 --- a/src/uu/od/src/inputdecoder.rs +++ b/src/uu/od/src/inputdecoder.rs @@ -166,6 +166,7 @@ mod tests { #[test] #[allow(clippy::float_cmp)] + #[allow(clippy::cognitive_complexity)] fn smoke_test() { let data = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xff, 0xff]; let mut input = PeekReader::new(Cursor::new(&data)); diff --git a/src/uu/od/src/output_info.rs b/src/uu/od/src/output_info.rs index 96c01f906..993bba329 100644 --- a/src/uu/od/src/output_info.rs +++ b/src/uu/od/src/output_info.rs @@ -208,6 +208,7 @@ impl TypeSizeInfo for TypeInfo { } #[test] +#[allow(clippy::cognitive_complexity)] fn test_calculate_alignment() { // For this example `byte_size_block` is 8 and 'print_width_block' is 23: // 1777777777777777777777 1777777777777777777777 diff --git a/src/uu/od/src/parse_inputs.rs b/src/uu/od/src/parse_inputs.rs index 74dc5a13a..241d842af 100644 --- a/src/uu/od/src/parse_inputs.rs +++ b/src/uu/od/src/parse_inputs.rs @@ -213,6 +213,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_parse_inputs_with_offset() { // offset is found without filename, so stdin will be used. assert_eq!( @@ -355,6 +356,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_parse_offset_operand() { assert_eq!(8, parse_offset_operand_str("10").unwrap()); // default octal assert_eq!(0, parse_offset_operand_str("0").unwrap()); diff --git a/src/uu/od/src/parse_nrofbytes.rs b/src/uu/od/src/parse_nrofbytes.rs index a5c81f68b..431b2a71f 100644 --- a/src/uu/od/src/parse_nrofbytes.rs +++ b/src/uu/od/src/parse_nrofbytes.rs @@ -79,6 +79,7 @@ pub fn parse_number_of_bytes(s: &str) -> Result { } #[test] +#[allow(clippy::cognitive_complexity)] fn test_parse_number_of_bytes() { // octal input assert_eq!(8, parse_number_of_bytes("010").unwrap()); diff --git a/src/uu/od/src/peekreader.rs b/src/uu/od/src/peekreader.rs index 239faab92..82f139c72 100644 --- a/src/uu/od/src/peekreader.rs +++ b/src/uu/od/src/peekreader.rs @@ -186,6 +186,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_peek_read_with_smaller_buffer() { let mut sut = PeekReader::new(Cursor::new(&b"abcdefghij"[..])); diff --git a/src/uu/od/src/prn_char.rs b/src/uu/od/src/prn_char.rs index db12d9d4f..36a00a67b 100644 --- a/src/uu/od/src/prn_char.rs +++ b/src/uu/od/src/prn_char.rs @@ -99,6 +99,7 @@ pub fn format_ascii_dump(bytes: &[u8]) -> String { } #[test] +#[allow(clippy::cognitive_complexity)] fn test_format_item_a() { assert_eq!(" nul", format_item_a(0x00)); assert_eq!(" soh", format_item_a(0x01)); @@ -114,6 +115,7 @@ fn test_format_item_a() { } #[test] +#[allow(clippy::cognitive_complexity)] fn test_format_item_c() { assert_eq!(" \\0", format_item_c(&[0x00])); assert_eq!(" 001", format_item_c(&[0x01])); diff --git a/src/uu/od/src/prn_float.rs b/src/uu/od/src/prn_float.rs index af632d66b..f4d018bd8 100644 --- a/src/uu/od/src/prn_float.rs +++ b/src/uu/od/src/prn_float.rs @@ -91,6 +91,7 @@ fn format_float(f: f64, width: usize, precision: usize) -> String { #[test] #[allow(clippy::excessive_precision)] +#[allow(clippy::cognitive_complexity)] fn test_format_flo32() { assert_eq!(format_flo32(1.0), " 1.0000000"); assert_eq!(format_flo32(9.9999990), " 9.9999990"); @@ -167,6 +168,7 @@ fn test_format_flo32() { } #[test] +#[allow(clippy::cognitive_complexity)] fn test_format_flo64() { assert_eq!(format_flo64(1.0), " 1.0000000000000000"); assert_eq!(format_flo64(10.0), " 10.000000000000000"); diff --git a/src/uu/od/src/prn_int.rs b/src/uu/od/src/prn_int.rs index c214b7525..f843ff77c 100644 --- a/src/uu/od/src/prn_int.rs +++ b/src/uu/od/src/prn_int.rs @@ -89,6 +89,7 @@ int_writer_signed!(FORMAT_ITEM_DEC32S, 4, 12, format_item_dec_s32, DEC!()); // m int_writer_signed!(FORMAT_ITEM_DEC64S, 8, 21, format_item_dec_s64, DEC!()); // max: -9223372036854775808 #[test] +#[allow(clippy::cognitive_complexity)] fn test_sign_extend() { assert_eq!( 0xffff_ffff_ffff_ff80u64 as i64, @@ -179,6 +180,7 @@ fn test_format_item_dec_u() { } #[test] +#[allow(clippy::cognitive_complexity)] fn test_format_item_dec_s() { assert_eq!(" 0", format_item_dec_s8(0)); assert_eq!(" 127", format_item_dec_s8(0x7f)); diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index c36b45006..055393578 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -404,6 +404,7 @@ fn print_unsigned_hex( } impl Stater { + #[allow(clippy::cognitive_complexity)] fn generate_tokens(format_str: &str, use_printf: bool) -> UResult> { let mut tokens = Vec::new(); let bound = format_str.len(); @@ -609,6 +610,7 @@ impl Stater { ret } + #[allow(clippy::cognitive_complexity)] fn do_stat(&self, file: &OsStr, stdin_is_fifo: bool) -> i32 { let display_name = file.to_string_lossy(); let file = if cfg!(unix) && display_name == "-" { From 4d122d7dd0e03d2e3f30ad91576947ee06e616b8 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 8 Oct 2023 17:51:06 +0200 Subject: [PATCH 284/370] Move rustfmt + clippy + typo check into it own workflow --- .github/workflows/CICD.yml | 160 -------------------------- .github/workflows/code-quality.yml | 175 +++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+), 160 deletions(-) create mode 100644 .github/workflows/code-quality.yml diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index b448b76d0..3b78fa6e2 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -82,49 +82,6 @@ jobs: grep --ignore-case "all deps seem to have been used" udeps.log || { printf "%s\n" "::${fault_type} ::${fault_prefix}: \`cargo udeps\`: style violation (unused dependency found)" ; fault=true ; } if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi - style_format: - name: Style/format - runs-on: ${{ matrix.job.os }} - strategy: - fail-fast: false - matrix: - job: - - { os: ubuntu-latest , features: feat_os_unix } - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: stable - components: rustfmt - - uses: Swatinem/rust-cache@v2 - - name: Initialize workflow variables - id: vars - shell: bash - run: | - ## VARs setup - outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } - # failure mode - unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in - ''|0|f|false|n|no|off) FAULT_TYPE=warning ;; - *) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;; - esac; - outputs FAIL_ON_FAULT FAULT_TYPE - # target-specific options - # * CARGO_FEATURES_OPTION - CARGO_FEATURES_OPTION='' ; - if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi - outputs CARGO_FEATURES_OPTION - - name: "`cargo fmt` testing" - shell: bash - run: | - ## `cargo fmt` testing - unset fault - fault_type="${{ steps.vars.outputs.FAULT_TYPE }}" - fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]') - # * convert any errors/warnings to GHA UI annotations; ref: - S=$(cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s\n" "$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::${fault_type} file=\1,line=\2::${fault_prefix}: \`cargo fmt\`: style violation (file:'\1', line:\2; use \`cargo fmt -- \"\1\"\`)/p" ; fault=true ; } - if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi - fuzz: name: Run the fuzzers runs-on: ubuntu-latest @@ -175,114 +132,6 @@ jobs: cd fuzz cargo +nightly fuzz run fuzz_parse_time -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - style_lint: - name: Style/lint - runs-on: ${{ matrix.job.os }} - env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" - strategy: - fail-fast: false - matrix: - job: - - { os: ubuntu-latest , features: feat_os_unix } - - { os: macos-latest , features: feat_os_macos } - - { os: windows-latest , features: feat_os_windows } - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: stable - components: clippy - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 - - name: Initialize workflow variables - id: vars - shell: bash - run: | - ## VARs setup - outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } - # failure mode - unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in - ''|0|f|false|n|no|off) FAULT_TYPE=warning ;; - *) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;; - esac; - outputs FAIL_ON_FAULT FAULT_TYPE - # target-specific options - # * CARGO_FEATURES_OPTION - CARGO_FEATURES_OPTION='--all-features' ; - if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features ${{ matrix.job.features }}' ; fi - outputs CARGO_FEATURES_OPTION - # * determine sub-crate utility list - UTILITY_LIST="$(./util/show-utils.sh ${CARGO_FEATURES_OPTION})" - echo UTILITY_LIST=${UTILITY_LIST} - CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo -n "-puu_${u} "; done;)" - outputs CARGO_UTILITY_LIST_OPTIONS - - name: Install/setup prerequisites - shell: bash - run: | - ## Install/setup prerequisites - case '${{ matrix.job.os }}' in - macos-latest) brew install coreutils ;; # needed for show-utils.sh - esac - - name: "`cargo clippy` lint testing" - shell: bash - run: | - ## `cargo clippy` lint testing - unset fault - CLIPPY_FLAGS="-W clippy::default_trait_access -W clippy::manual_string_new -W clippy::cognitive_complexity" - fault_type="${{ steps.vars.outputs.FAULT_TYPE }}" - fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]') - # * convert any warnings to GHA UI annotations; ref: - S=$(cargo clippy --all-targets ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_UTILITY_LIST_OPTIONS }} -- ${CLIPPY_FLAGS} -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::${fault_type} file=\2,line=\3,col=\4::${fault_prefix}: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; fault=true ; } - if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi - - style_spellcheck: - name: Style/spelling - runs-on: ${{ matrix.job.os }} - strategy: - matrix: - job: - - { os: ubuntu-latest , features: feat_os_unix } - steps: - - uses: actions/checkout@v4 - - name: Initialize workflow variables - id: vars - shell: bash - run: | - ## VARs setup - outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } - # failure mode - unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in - ''|0|f|false|n|no|off) FAULT_TYPE=warning ;; - *) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;; - esac; - outputs FAIL_ON_FAULT FAULT_TYPE - - name: Install/setup prerequisites - shell: bash - run: | - ## Install/setup prerequisites - # * pin installed cspell to v4.2.8 (cspell v5+ is broken for NodeJS < v12) - ## maint: [2021-11-10; rivy] `cspell` version may be advanced to v5 when used with NodeJS >= v12 - sudo apt-get -y update ; sudo apt-get -y install npm ; sudo npm install cspell@4.2.8 -g ; - - name: Run `cspell` - shell: bash - run: | - ## Run `cspell` - unset fault - fault_type="${{ steps.vars.outputs.FAULT_TYPE }}" - fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]') - # * find cspell configuration ; note: avoid quotes around ${cfg_file} b/c `cspell` (v4) doesn't correctly dequote the config argument (or perhaps a subshell expansion issue?) - cfg_files=($(shopt -s nullglob ; echo {.vscode,.}/{,.}c[sS]pell{.json,.config{.js,.cjs,.json,.yaml,.yml},.yaml,.yml} ;)) - cfg_file=${cfg_files[0]} - unset CSPELL_CFG_OPTION ; if [ -n "$cfg_file" ]; then CSPELL_CFG_OPTION="--config $cfg_file" ; fi - # * `cspell` - ## maint: [2021-11-10; rivy] the `--no-progress` option for `cspell` is a `cspell` v5+ option - # S=$(cspell ${CSPELL_CFG_OPTION} --no-summary --no-progress "**/*") && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n "s/${PWD//\//\\/}\/(.*):(.*):(.*) - (.*)/::${fault_type} file=\1,line=\2,col=\3::${fault_type^^}: \4 (file:'\1', line:\2)/p" ; fault=true ; true ; } - S=$(cspell ${CSPELL_CFG_OPTION} --no-summary "**/*") && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n "s/${PWD//\//\\/}\/(.*):(.*):(.*) - (.*)/::${fault_type} file=\1,line=\2,col=\3::${fault_type^^}: \4 (file:'\1', line:\2)/p" ; fault=true ; true ; } - if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi - doc_warnings: name: Documentation/warnings runs-on: ${{ matrix.job.os }} @@ -1081,15 +930,6 @@ jobs: name: toybox-result.json path: ${{ steps.vars.outputs.TEST_SUMMARY_FILE }} - toml_format: - runs-on: ubuntu-latest - steps: - - name: Clone repository - uses: actions/checkout@v4 - - - name: Check - run: npx --yes @taplo/cli fmt --check - coverage: name: Code Coverage runs-on: ${{ matrix.job.os }} diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 000000000..c67483280 --- /dev/null +++ b/.github/workflows/code-quality.yml @@ -0,0 +1,175 @@ +name: Code Quality + +# spell-checker:ignore TERMUX reactivecircus Swatinem noaudio pkill swiftshader dtolnay juliangruber + +on: [push, pull_request] + +permissions: + contents: read # to fetch code (actions/checkout) + +# End the current execution if there is a new changeset in the PR. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + + style_format: + name: Style/format + runs-on: ${{ matrix.job.os }} + strategy: + fail-fast: false + matrix: + job: + - { os: ubuntu-latest , features: feat_os_unix } + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + components: rustfmt + - uses: Swatinem/rust-cache@v2 + - name: Initialize workflow variables + id: vars + shell: bash + run: | + ## VARs setup + outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } + # failure mode + unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in + ''|0|f|false|n|no|off) FAULT_TYPE=warning ;; + *) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;; + esac; + outputs FAIL_ON_FAULT FAULT_TYPE + # target-specific options + # * CARGO_FEATURES_OPTION + CARGO_FEATURES_OPTION='' ; + if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi + outputs CARGO_FEATURES_OPTION + - name: "`cargo fmt` testing" + shell: bash + run: | + ## `cargo fmt` testing + unset fault + fault_type="${{ steps.vars.outputs.FAULT_TYPE }}" + fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]') + # * convert any errors/warnings to GHA UI annotations; ref: + S=$(cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s\n" "$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::${fault_type} file=\1,line=\2::${fault_prefix}: \`cargo fmt\`: style violation (file:'\1', line:\2; use \`cargo fmt -- \"\1\"\`)/p" ; fault=true ; } + if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi + + style_lint: + name: Style/lint + runs-on: ${{ matrix.job.os }} + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + strategy: + fail-fast: false + matrix: + job: + - { os: ubuntu-latest , features: feat_os_unix } + - { os: macos-latest , features: feat_os_macos } + - { os: windows-latest , features: feat_os_windows } + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + components: clippy + - uses: Swatinem/rust-cache@v2 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Initialize workflow variables + id: vars + shell: bash + run: | + ## VARs setup + outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } + # failure mode + unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in + ''|0|f|false|n|no|off) FAULT_TYPE=warning ;; + *) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;; + esac; + outputs FAIL_ON_FAULT FAULT_TYPE + # target-specific options + # * CARGO_FEATURES_OPTION + CARGO_FEATURES_OPTION='--all-features' ; + if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features ${{ matrix.job.features }}' ; fi + outputs CARGO_FEATURES_OPTION + # * determine sub-crate utility list + UTILITY_LIST="$(./util/show-utils.sh ${CARGO_FEATURES_OPTION})" + echo UTILITY_LIST=${UTILITY_LIST} + CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo -n "-puu_${u} "; done;)" + outputs CARGO_UTILITY_LIST_OPTIONS + - name: Install/setup prerequisites + shell: bash + run: | + ## Install/setup prerequisites + case '${{ matrix.job.os }}' in + macos-latest) brew install coreutils ;; # needed for show-utils.sh + esac + - name: "`cargo clippy` lint testing" + shell: bash + run: | + ## `cargo clippy` lint testing + unset fault + CLIPPY_FLAGS="-W clippy::default_trait_access -W clippy::manual_string_new -W clippy::cognitive_complexity" + fault_type="${{ steps.vars.outputs.FAULT_TYPE }}" + fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]') + # * convert any warnings to GHA UI annotations; ref: + S=$(cargo clippy --all-targets ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_UTILITY_LIST_OPTIONS }} -- ${CLIPPY_FLAGS} -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::${fault_type} file=\2,line=\3,col=\4::${fault_prefix}: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; fault=true ; } + if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi + + style_spellcheck: + name: Style/spelling + runs-on: ${{ matrix.job.os }} + strategy: + matrix: + job: + - { os: ubuntu-latest , features: feat_os_unix } + steps: + - uses: actions/checkout@v4 + - name: Initialize workflow variables + id: vars + shell: bash + run: | + ## VARs setup + outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } + # failure mode + unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in + ''|0|f|false|n|no|off) FAULT_TYPE=warning ;; + *) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;; + esac; + outputs FAIL_ON_FAULT FAULT_TYPE + - name: Install/setup prerequisites + shell: bash + run: | + ## Install/setup prerequisites + # * pin installed cspell to v4.2.8 (cspell v5+ is broken for NodeJS < v12) + ## maint: [2021-11-10; rivy] `cspell` version may be advanced to v5 when used with NodeJS >= v12 + sudo apt-get -y update ; sudo apt-get -y install npm ; sudo npm install cspell@4.2.8 -g ; + - name: Run `cspell` + shell: bash + run: | + ## Run `cspell` + unset fault + fault_type="${{ steps.vars.outputs.FAULT_TYPE }}" + fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]') + # * find cspell configuration ; note: avoid quotes around ${cfg_file} b/c `cspell` (v4) doesn't correctly dequote the config argument (or perhaps a subshell expansion issue?) + cfg_files=($(shopt -s nullglob ; echo {.vscode,.}/{,.}c[sS]pell{.json,.config{.js,.cjs,.json,.yaml,.yml},.yaml,.yml} ;)) + cfg_file=${cfg_files[0]} + unset CSPELL_CFG_OPTION ; if [ -n "$cfg_file" ]; then CSPELL_CFG_OPTION="--config $cfg_file" ; fi + # * `cspell` + ## maint: [2021-11-10; rivy] the `--no-progress` option for `cspell` is a `cspell` v5+ option + # S=$(cspell ${CSPELL_CFG_OPTION} --no-summary --no-progress "**/*") && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n "s/${PWD//\//\\/}\/(.*):(.*):(.*) - (.*)/::${fault_type} file=\1,line=\2,col=\3::${fault_type^^}: \4 (file:'\1', line:\2)/p" ; fault=true ; true ; } + S=$(cspell ${CSPELL_CFG_OPTION} --no-summary "**/*") && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n "s/${PWD//\//\\/}\/(.*):(.*):(.*) - (.*)/::${fault_type} file=\1,line=\2,col=\3::${fault_type^^}: \4 (file:'\1', line:\2)/p" ; fault=true ; true ; } + if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi + + toml_format: + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Check + run: npx --yes @taplo/cli fmt --check From 02ab93c141f3b17d713276226ff1eaa555847c6c Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 8 Oct 2023 17:54:36 +0200 Subject: [PATCH 285/370] github action: name the toml task --- .github/workflows/code-quality.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index c67483280..abcfd90ab 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -166,6 +166,7 @@ jobs: if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi toml_format: + name: Style/toml runs-on: ubuntu-latest steps: - name: Clone repository From 2c9e091ebee4e9d5b85ac46015d8727ae654ffdc Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 9 Oct 2023 07:07:38 +0200 Subject: [PATCH 286/370] Bump errno from 0.3.1 to 0.3.5 --- Cargo.lock | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 197368abf..d4da11736 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -783,25 +783,14 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ - "errno-dragonfly", "libc", "windows-sys 0.48.0", ] -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "exacl" version = "0.11.0" From 2883c0a9689ead143ae4a8b38536447939d890fd Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 9 Oct 2023 15:16:50 +0200 Subject: [PATCH 287/370] uucore: remove commented out import --- src/uucore/src/lib/features/tokenize/sub.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/uucore/src/lib/features/tokenize/sub.rs b/src/uucore/src/lib/features/tokenize/sub.rs index 447616ae6..c65a37a68 100644 --- a/src/uucore/src/lib/features/tokenize/sub.rs +++ b/src/uucore/src/lib/features/tokenize/sub.rs @@ -18,7 +18,6 @@ use std::iter::Peekable; use std::process::exit; use std::slice::Iter; use std::str::Chars; -// use std::collections::HashSet; use super::num_format::format_field::{FieldType, FormatField}; use super::num_format::num_format; From b38ac2cb7488e0006c5a98f87bc36b9ce07dc150 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 9 Oct 2023 15:28:12 +0200 Subject: [PATCH 288/370] uucore: remove commented out enum FChar --- .../tokenize/num_format/format_field.rs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/uucore/src/lib/features/tokenize/num_format/format_field.rs b/src/uucore/src/lib/features/tokenize/num_format/format_field.rs index 036ee286d..bd57b0ecd 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/format_field.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/format_field.rs @@ -17,23 +17,6 @@ pub enum FieldType { Charf, } -// #[allow(non_camel_case_types)] -// pub enum FChar { -// d, -// e, -// E, -// i, -// f, -// F, -// g, -// G, -// u, -// x, -// X, -// o -// } -// - // a Sub Tokens' fields are stored // as a single object so they can be more simply // passed by ref to num_format in a Sub method From d2cacdfce27adbf9c64b1cd4d72f05daf6d48f45 Mon Sep 17 00:00:00 2001 From: Howard Su Date: Mon, 9 Oct 2023 09:38:06 +0800 Subject: [PATCH 289/370] Fix overflow error on WSL. Default to 0 when the values are non-sense. --- src/uu/df/src/table.rs | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/uu/df/src/table.rs b/src/uu/df/src/table.rs index 4c3d08f45..e1f7fd82e 100644 --- a/src/uu/df/src/table.rs +++ b/src/uu/df/src/table.rs @@ -152,8 +152,10 @@ impl From for Row { ffree, .. } = fs.usage; - let bused = blocks - bfree; - let fused = files - ffree; + + // On Windows WSL, files can be less than ffree. Protect such cases via saturating_sub. + let bused = blocks.saturating_sub(bfree); + let fused = files.saturating_sub(ffree); Self { file: fs.file, fs_device: dev_name, @@ -815,4 +817,35 @@ mod tests { assert_eq!(get_formatted_values(1000, 1000, 0), vec!("1", "1", "0")); assert_eq!(get_formatted_values(1001, 1000, 1), vec!("2", "1", "1")); } + + #[test] + fn test_row_converter_with_invalid_numbers() { + // copy from wsl linux + let d = crate::Filesystem { + file: None, + mount_info: crate::MountInfo { + dev_id: "28".to_string(), + dev_name: "none".to_string(), + fs_type: "9p".to_string(), + mount_dir: "/usr/lib/wsl/drivers".to_string(), + mount_option: "ro,nosuid,nodev,noatime".to_string(), + mount_root: "/".to_string(), + remote: false, + dummy: false, + }, + usage: crate::table::FsUsage { + blocksize: 4096, + blocks: 244029695, + bfree: 125085030, + bavail: 125085030, + bavail_top_bit_set: false, + files: 999, + ffree: 1000000, + }, + }; + + let row = Row::from(d); + + assert_eq!(row.inodes_used, 0); + } } From 536dbae90aed66f2a6261e84363342a94e4f59a7 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 10 Oct 2023 07:58:16 +0200 Subject: [PATCH 290/370] Bump bstr and regex bstr from 1.6 -> 1.7 regex from 1.9.6 -> 1.10.0 --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d4da11736..9d43cc65d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +checksum = "c79ad7fb2dd38f3dabd76b09c6a5a20c038fc0213ef1e9afd30eb777f120f019" dependencies = [ "memchr", "regex-automata", @@ -1728,9 +1728,9 @@ checksum = "f1bfbf25d7eb88ddcbb1ec3d755d0634da8f7657b2cb8b74089121409ab8228f" [[package]] name = "regex" -version = "1.9.6" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" dependencies = [ "aho-corasick", "memchr", @@ -1740,9 +1740,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.9" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" dependencies = [ "aho-corasick", "memchr", @@ -1751,9 +1751,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c3cbb081b9784b07cceb8824c8583f86db4814d172ab043f3c23f7dc600bf83d" [[package]] name = "relative-path" diff --git a/Cargo.toml b/Cargo.toml index 8eecb2b8f..df729a765 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -259,7 +259,7 @@ test = ["uu_test"] [workspace.dependencies] bigdecimal = "0.4" binary-heap-plus = "0.5.0" -bstr = "1.6" +bstr = "1.7" bytecount = "0.6.4" byteorder = "1.5.0" chrono = { version = "^0.4.31", default-features = false, features = [ @@ -309,7 +309,7 @@ rand = { version = "0.8", features = ["small_rng"] } rand_core = "0.6" rayon = "1.8" redox_syscall = "0.4" -regex = "1.9.6" +regex = "1.10.0" rstest = "0.18.2" rust-ini = "0.19.0" same-file = "1.0.6" From 95a1a08de3d44240112fc1c3e959b268cf216678 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 10 Oct 2023 09:07:32 +0200 Subject: [PATCH 291/370] Add two words to the ignore spell list --- src/uu/df/src/table.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/df/src/table.rs b/src/uu/df/src/table.rs index e1f7fd82e..f6e094204 100644 --- a/src/uu/df/src/table.rs +++ b/src/uu/df/src/table.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore tmpfs Pcent Itotal Iused Iavail Ipcent +// spell-checker:ignore tmpfs Pcent Itotal Iused Iavail Ipcent nosuid nodev //! The filesystem usage data table. //! //! A table ([`Table`]) comprises a header row ([`Header`]) and a From 6cb0d5ad7dceca1193ded89d133047d773c19c4b Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 11 Oct 2023 07:53:03 +0000 Subject: [PATCH 292/370] add comment for explicit in the Preserve enum --- src/uu/cp/src/cp.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 72431cc12..58c56138e 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -184,6 +184,8 @@ pub struct Attributes { #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Preserve { + // explicit means is the --no-preserve flag is used or not to distinguish out the default value. + // e.g. --no-preserve=mode means mode = No { explicit = true } No { explicit: bool }, Yes { required: bool }, } From 3b971e480624036b00aa5e9b5f3813dd5e6b71ba Mon Sep 17 00:00:00 2001 From: Miles Liu Date: Wed, 11 Oct 2023 16:26:36 +0800 Subject: [PATCH 293/370] ls: move to uutils-term-grid --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- src/uu/ls/Cargo.toml | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d43cc65d..a0a62d13b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2085,15 +2085,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "term_grid" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "230d3e804faaed5a39b08319efb797783df2fd9671b39b7596490cb486d702cf" -dependencies = [ - "unicode-width", -] - [[package]] name = "terminal_size" version = "0.2.6" @@ -2649,10 +2640,10 @@ dependencies = [ "number_prefix", "once_cell", "selinux", - "term_grid", "terminal_size 0.3.0", "unicode-width", "uucore", + "uutils_term_grid", ] [[package]] @@ -3276,6 +3267,15 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" +[[package]] +name = "uutils_term_grid" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b389452a568698688dda38802068378a16c15c4af9b153cdd99b65391292bbc7" +dependencies = [ + "unicode-width", +] + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index df729a765..820568e61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -318,7 +318,7 @@ selinux = "0.4" signal-hook = "0.3.17" smallvec = { version = "1.11", features = ["union"] } tempfile = "3.8.0" -term_grid = "0.1.5" +uutils_term_grid = "0.3" terminal_size = "0.3.0" textwrap = { version = "0.16.0", features = ["terminal_size"] } thiserror = "1.0" diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index e4100d07f..4394865ca 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -19,7 +19,7 @@ clap = { workspace = true, features = ["env"] } chrono = { workspace = true } unicode-width = { workspace = true } number_prefix = { workspace = true } -term_grid = { workspace = true } +uutils_term_grid = { workspace = true } terminal_size = { workspace = true } glob = { workspace = true } lscolors = { workspace = true } From 78e1eae1effe8f60bfcbc49f70acbf8a5530f993 Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 11 Oct 2023 08:29:13 +0000 Subject: [PATCH 294/370] address comment --- src/uu/cp/src/cp.rs | 91 +++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 58c56138e..034cd4b12 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1743,50 +1743,7 @@ fn copy_file( let mut permissions = source_metadata.permissions(); #[cfg(unix)] { - let mut mode = permissions.mode(); - - let (is_preserve_mode, is_explicit_no_preserve_mode) = options.preserve_mode(); - if !is_preserve_mode { - use libc::{ - S_IRGRP, S_IROTH, S_IRUSR, S_IRWXG, S_IRWXO, S_IRWXU, S_IWGRP, S_IWOTH, S_IWUSR, - }; - - #[cfg(not(any( - target_os = "android", - target_os = "macos", - target_os = "macos-12", - target_os = "freebsd", - )))] - const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; - #[cfg(not(any( - target_os = "android", - target_os = "macos", - target_os = "macos-12", - target_os = "freebsd", - )))] - const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; - - #[cfg(any( - target_os = "android", - target_os = "macos", - target_os = "macos-12", - target_os = "freebsd", - ))] - const MODE_RW_UGO: u32 = - (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; - #[cfg(any( - target_os = "android", - target_os = "macos", - target_os = "macos-12", - target_os = "freebsd", - ))] - const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; - - match is_explicit_no_preserve_mode { - true => mode = MODE_RW_UGO, - false => mode &= S_IRWXUGO, - } - } + let mut mode = handling_no_preserve_mode(options, permissions.mode()); // apply umask use uucore::mode::get_umask; @@ -1918,6 +1875,52 @@ fn copy_file( Ok(()) } +fn handling_no_preserve_mode(options: &Options, org_mode: u32) -> u32 { + let (is_preserve_mode, is_explicit_no_preserve_mode) = options.preserve_mode(); + if !is_preserve_mode { + use libc::{ + S_IRGRP, S_IROTH, S_IRUSR, S_IRWXG, S_IRWXO, S_IRWXU, S_IWGRP, S_IWOTH, S_IWUSR, + }; + + #[cfg(not(any( + target_os = "android", + target_os = "macos", + target_os = "macos-12", + target_os = "freebsd", + )))] + const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; + #[cfg(not(any( + target_os = "android", + target_os = "macos", + target_os = "macos-12", + target_os = "freebsd", + )))] + const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; + + #[cfg(any( + target_os = "android", + target_os = "macos", + target_os = "macos-12", + target_os = "freebsd", + ))] + const MODE_RW_UGO: u32 = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; + #[cfg(any( + target_os = "android", + target_os = "macos", + target_os = "macos-12", + target_os = "freebsd", + ))] + const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; + + match is_explicit_no_preserve_mode { + true => return MODE_RW_UGO, + false => return org_mode & S_IRWXUGO, + }; + } + + org_mode +} + /// Copy the file from `source` to `dest` either using the normal `fs::copy` or a /// copy-on-write scheme if --reflink is specified and the filesystem supports it. fn copy_helper( From c59b0f11fd821254863930ff51328a5bfbeee45f Mon Sep 17 00:00:00 2001 From: tommady Date: Wed, 11 Oct 2023 08:57:04 +0000 Subject: [PATCH 295/370] fix linter --- src/uu/cp/src/cp.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 034cd4b12..b1dd94dbd 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1875,6 +1875,7 @@ fn copy_file( Ok(()) } +#[cfg(unix)] fn handling_no_preserve_mode(options: &Options, org_mode: u32) -> u32 { let (is_preserve_mode, is_explicit_no_preserve_mode) = options.preserve_mode(); if !is_preserve_mode { From a920464952df36e6c1797bc5dccf29f2976edf83 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 11 Oct 2023 12:13:22 -0400 Subject: [PATCH 296/370] split: undocumented options aliases + help fix --- src/uu/split/src/split.rs | 4 +++- tests/by-util/test_split.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index bfd595e4f..020ada93b 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -311,6 +311,7 @@ pub fn uu_app() -> Command { .arg( Arg::new(OPT_NUMERIC_SUFFIXES) .long(OPT_NUMERIC_SUFFIXES) + .alias("numeric") .require_equals(true) .default_missing_value("0") .num_args(0..=1) @@ -338,6 +339,7 @@ pub fn uu_app() -> Command { .arg( Arg::new(OPT_HEX_SUFFIXES) .long(OPT_HEX_SUFFIXES) + .alias("hex") .default_missing_value("0") .require_equals(true) .num_args(0..=1) @@ -372,7 +374,7 @@ pub fn uu_app() -> Command { .allow_hyphen_values(true) .value_name("SEP") .action(ArgAction::Append) - .help("use SEP instead of newline as the record separator; '\0' (zero) specifies the NUL character"), + .help("use SEP instead of newline as the record separator; '\\0' (zero) specifies the NUL character"), ) .arg( Arg::new(OPT_IO) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index ce80844cf..113c0fb87 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -1192,6 +1192,19 @@ fn test_numeric_suffix() { assert_eq!(at.read("x12"), ""); } +#[test] +fn test_numeric_suffix_alias() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-n", "4", "--numeric=9", "threebytes.txt"]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("x09"), "a"); + assert_eq!(at.read("x10"), "b"); + assert_eq!(at.read("x11"), "c"); + assert_eq!(at.read("x12"), ""); +} + #[test] fn test_hex_suffix() { let (at, mut ucmd) = at_and_ucmd!(); @@ -1205,6 +1218,19 @@ fn test_hex_suffix() { assert_eq!(at.read("x0c"), ""); } +#[test] +fn test_hex_suffix_alias() { + let (at, mut ucmd) = at_and_ucmd!(); + ucmd.args(&["-n", "4", "--hex=9", "threebytes.txt"]) + .succeeds() + .no_stdout() + .no_stderr(); + assert_eq!(at.read("x09"), "a"); + assert_eq!(at.read("x0a"), "b"); + assert_eq!(at.read("x0b"), "c"); + assert_eq!(at.read("x0c"), ""); +} + #[test] fn test_numeric_suffix_no_equal() { new_ucmd!() From 7ea19c7c5dd2f99d8fc4db3e2337f7a9072b715b Mon Sep 17 00:00:00 2001 From: tommady Date: Thu, 12 Oct 2023 10:42:44 +0800 Subject: [PATCH 297/370] Update src/uu/cp/src/cp.rs Co-authored-by: Sylvestre Ledru --- src/uu/cp/src/cp.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index b1dd94dbd..eb14e0904 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1889,14 +1889,10 @@ fn handling_no_preserve_mode(options: &Options, org_mode: u32) -> u32 { target_os = "macos-12", target_os = "freebsd", )))] - const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; - #[cfg(not(any( - target_os = "android", - target_os = "macos", - target_os = "macos-12", - target_os = "freebsd", - )))] - const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; + { + const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; + const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; + } #[cfg(any( target_os = "android", From 9be5583d363972b05c07d6cae95c549665edb519 Mon Sep 17 00:00:00 2001 From: tommady Date: Thu, 12 Oct 2023 10:42:52 +0800 Subject: [PATCH 298/370] Update src/uu/cp/src/cp.rs Co-authored-by: Sylvestre Ledru --- src/uu/cp/src/cp.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index eb14e0904..5df5eaf20 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1900,14 +1900,10 @@ fn handling_no_preserve_mode(options: &Options, org_mode: u32) -> u32 { target_os = "macos-12", target_os = "freebsd", ))] - const MODE_RW_UGO: u32 = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; - #[cfg(any( - target_os = "android", - target_os = "macos", - target_os = "macos-12", - target_os = "freebsd", - ))] - const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; + { + const MODE_RW_UGO: u32 = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; + const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; + } match is_explicit_no_preserve_mode { true => return MODE_RW_UGO, From c9fa07035b1846fedd3883bdf04dddd7ea8c5e6f Mon Sep 17 00:00:00 2001 From: tommady Date: Thu, 12 Oct 2023 02:52:02 +0000 Subject: [PATCH 299/370] fix linter errors --- src/uu/cp/src/cp.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 5df5eaf20..40b485c5c 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1890,8 +1890,12 @@ fn handling_no_preserve_mode(options: &Options, org_mode: u32) -> u32 { target_os = "freebsd", )))] { - const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; + const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO; + match is_explicit_no_preserve_mode { + true => return MODE_RW_UGO, + false => return org_mode & S_IRWXUGO, + }; } #[cfg(any( @@ -1901,14 +1905,14 @@ fn handling_no_preserve_mode(options: &Options, org_mode: u32) -> u32 { target_os = "freebsd", ))] { - const MODE_RW_UGO: u32 = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; + const MODE_RW_UGO: u32 = + (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; - } - - match is_explicit_no_preserve_mode { - true => return MODE_RW_UGO, - false => return org_mode & S_IRWXUGO, - }; + match is_explicit_no_preserve_mode { + true => return MODE_RW_UGO, + false => return org_mode & S_IRWXUGO, + }; + } } org_mode From 2bd5e263172772b595412fb978668709d2033230 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 12 Oct 2023 17:20:00 +0200 Subject: [PATCH 300/370] DEVELOPMENT.md: improve doc on how to run some tests --- DEVELOPMENT.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 24a1bdeb5..308daba98 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -142,6 +142,8 @@ If you also want to test the core utilities: ```shell cargo test -p uucore -p coreutils +# or +cargo test --all-features -p uucore ``` Running the complete test suite might take a while. We use [nextest](https://nexte.st/index.html) in From 29a5a13ce6a153b15d6eba742dd7747b0abce824 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 12 Oct 2023 14:29:26 +0200 Subject: [PATCH 301/370] fs: split get_file_display into its function --- src/uucore/src/lib/features/fs.rs | 54 ++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index 719efc7a6..97238b10d 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -465,6 +465,35 @@ pub fn display_permissions(metadata: &fs::Metadata, display_file_type: bool) -> display_permissions_unix(mode, display_file_type) } +/// Returns a character representation of the file type based on its mode. +/// This function is specific to Unix-like systems. +/// +/// - `mode`: The mode of the file, typically obtained from file metadata. +/// +/// # Returns +/// - 'd' for directories +/// - 'c' for character devices +/// - 'b' for block devices +/// - '-' for regular files +/// - 'p' for FIFOs (named pipes) +/// - 'l' for symbolic links +/// - 's' for sockets +/// - '?' for any other unrecognized file types +#[cfg(unix)] +fn get_file_display(mode: mode_t) -> char { + match mode & S_IFMT { + S_IFDIR => 'd', + S_IFCHR => 'c', + S_IFBLK => 'b', + S_IFREG => '-', + S_IFIFO => 'p', + S_IFLNK => 'l', + S_IFSOCK => 's', + // TODO: Other file types + _ => '?', + } +} + // The logic below is more readable written this way. #[allow(clippy::if_not_else)] #[allow(clippy::cognitive_complexity)] @@ -474,17 +503,7 @@ pub fn display_permissions_unix(mode: mode_t, display_file_type: bool) -> String let mut result; if display_file_type { result = String::with_capacity(10); - result.push(match mode & S_IFMT { - S_IFDIR => 'd', - S_IFCHR => 'c', - S_IFBLK => 'b', - S_IFREG => '-', - S_IFIFO => 'p', - S_IFLNK => 'l', - S_IFSOCK => 's', - // TODO: Other file types - _ => '?', - }); + result.push(get_file_display(mode)); } else { result = String::with_capacity(9); } @@ -881,4 +900,17 @@ mod tests { assert!(are_hardlinks_to_same_file(&path1, &path2)); } + + #[cfg(unix)] + #[test] + fn test_get_file_display() { + assert_eq!(get_file_display(S_IFDIR | 0o755), 'd'); + assert_eq!(get_file_display(S_IFCHR | 0o644), 'c'); + assert_eq!(get_file_display(S_IFBLK | 0o600), 'b'); + assert_eq!(get_file_display(S_IFREG | 0o777), '-'); + assert_eq!(get_file_display(S_IFIFO | 0o666), 'p'); + assert_eq!(get_file_display(S_IFLNK | 0o777), 'l'); + assert_eq!(get_file_display(S_IFSOCK | 0o600), 's'); + assert_eq!(get_file_display(0o777), '?'); + } } From 94972d45c7aa0532c3b44d2c131b4028b63f5555 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 12 Oct 2023 23:07:27 +0200 Subject: [PATCH 302/370] ls: Document a bit tests/ls/stat-dtype.sh --- src/uu/ls/src/ls.rs | 8 ++++---- tests/by-util/test_ls.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 39bab7982..8a05e81f8 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -2395,10 +2395,10 @@ fn display_grid( writeln!(out)?; } } else { - let mut grid = Grid::new(GridOptions { - filling: Filling::Spaces(2), - direction, - }); + // To match gnu/tests/ls/stat-dtype.sh + // we might want to have Text("\t".to_string()); + let filling = Filling::Spaces(2); + let mut grid = Grid::new(GridOptions { filling, direction }); for name in names { grid.add(name); diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 7d0f86298..d9c1c8740 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -3678,3 +3678,17 @@ fn test_ls_dired_complex() { println!("Extracted filenames: {:?}", filenames); assert_eq!(filenames, vec!["a1", "a22", "a333", "a4444", "d"]); } + +#[ignore = "issue #5396"] +#[test] +fn test_ls_tabsize_cf() { + let (at, mut ucmd) = at_and_ucmd!(); + + at.mkdir("e"); + at.mkdir("e/a2345"); + at.mkdir("e/b"); + + ucmd.args(&["-CF", "e"]) + .succeeds() + .stdout_is("a2345/\tb/\n"); +} From cd51eb8eb58ca8c893ba775707537bc475e54e4a Mon Sep 17 00:00:00 2001 From: Miles Liu Date: Fri, 13 Oct 2023 14:13:10 +0800 Subject: [PATCH 303/370] ci: code-quality workflow doesn't fail on clippy errors --- .github/workflows/code-quality.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index abcfd90ab..0a619e097 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -4,6 +4,10 @@ name: Code Quality on: [push, pull_request] +env: + # * style job configuration + STYLE_FAIL_ON_FAULT: true ## (bool) fail the build if a style job contains a fault (error or warning); may be overridden on a per-job basis + permissions: contents: read # to fetch code (actions/checkout) From f1f4823feb91dd3a8644287a1995e5f5433b8ef7 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 13 Oct 2023 08:26:06 +0200 Subject: [PATCH 304/370] who: suppress cognitive_complexity lint --- src/uu/who/src/who.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uu/who/src/who.rs b/src/uu/who/src/who.rs index 29929b138..5d952efff 100644 --- a/src/uu/who/src/who.rs +++ b/src/uu/who/src/who.rs @@ -326,6 +326,7 @@ fn current_tty() -> String { } impl Who { + #[allow(clippy::cognitive_complexity)] fn exec(&mut self) -> UResult<()> { let run_level_chk = |_record: i16| { #[cfg(not(target_os = "linux"))] From 8826e47d36086737370cb11d647b1399ab6d0b01 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 13 Oct 2023 10:30:31 +0200 Subject: [PATCH 305/370] ignore dtype in the spell --- src/uu/ls/src/ls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 8a05e81f8..bff7c4460 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) cpio svgz webm somegroup nlink rmvb xspf tabsize dired subdired +// spell-checker:ignore (ToDO) cpio svgz webm somegroup nlink rmvb xspf tabsize dired subdired dtype use clap::{ builder::{NonEmptyStringValueParser, ValueParser}, From 8931cfa93df1cd003ce081b413524fabbe8537f1 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 13 Oct 2023 11:18:00 +0200 Subject: [PATCH 306/370] improve the wordin Co-authored-by: Daniel Hofstetter --- src/uu/ls/src/ls.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index bff7c4460..dfa637d23 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -2395,8 +2395,8 @@ fn display_grid( writeln!(out)?; } } else { - // To match gnu/tests/ls/stat-dtype.sh - // we might want to have Text("\t".to_string()); + // TODO: To match gnu/tests/ls/stat-dtype.sh + // we might want to have Filling::Text("\t".to_string()); let filling = Filling::Spaces(2); let mut grid = Grid::new(GridOptions { filling, direction }); From 41188a915ee33195f45ff86ac253cc0ef11c240c Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 13 Oct 2023 11:35:45 +0200 Subject: [PATCH 307/370] rename the test Co-authored-by: Daniel Hofstetter --- tests/by-util/test_ls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index d9c1c8740..8b0032065 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -3681,7 +3681,7 @@ fn test_ls_dired_complex() { #[ignore = "issue #5396"] #[test] -fn test_ls_tabsize_cf() { +fn test_ls_cf_output_should_be_delimited_by_tab() { let (at, mut ucmd) = at_and_ucmd!(); at.mkdir("e"); From a69d48fb8c1d5b907a5943c99156352c13858316 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 13 Oct 2023 14:34:54 +0200 Subject: [PATCH 308/370] clippy: suppress cognitive_complexity lint --- src/uu/csplit/src/csplit.rs | 2 ++ src/uu/csplit/src/patterns.rs | 2 ++ src/uu/dd/src/numbers.rs | 1 + src/uu/dd/src/parseargs/unit_tests.rs | 1 + src/uu/df/src/blocks.rs | 1 + src/uu/head/src/head.rs | 1 + src/uu/head/src/parse.rs | 1 + src/uu/nl/src/nl.rs | 1 + src/uu/numfmt/src/format.rs | 1 + src/uu/numfmt/src/options.rs | 1 + src/uu/od/src/prn_float.rs | 1 + src/uu/seq/src/numberparse.rs | 2 ++ src/uu/split/src/number.rs | 4 ++++ src/uu/split/src/split.rs | 1 + src/uu/stat/src/stat.rs | 1 + 15 files changed, 21 insertions(+) diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs index 6c9a776c3..6e03c2e5c 100644 --- a/src/uu/csplit/src/csplit.rs +++ b/src/uu/csplit/src/csplit.rs @@ -664,6 +664,7 @@ mod tests { use super::*; #[test] + #[allow(clippy::cognitive_complexity)] fn input_splitter() { let input = vec![ Ok(String::from("aaa")), @@ -736,6 +737,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn input_splitter_interrupt_rewind() { let input = vec![ Ok(String::from("aaa")), diff --git a/src/uu/csplit/src/patterns.rs b/src/uu/csplit/src/patterns.rs index fd96fd9fb..8e7b76e6b 100644 --- a/src/uu/csplit/src/patterns.rs +++ b/src/uu/csplit/src/patterns.rs @@ -211,6 +211,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn up_to_match_pattern() { let input: Vec = vec![ "/test1.*end$/", @@ -264,6 +265,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn skip_to_match_pattern() { let input: Vec = vec![ "%test1.*end$%", diff --git a/src/uu/dd/src/numbers.rs b/src/uu/dd/src/numbers.rs index 2911f7e58..8a6fa5a7a 100644 --- a/src/uu/dd/src/numbers.rs +++ b/src/uu/dd/src/numbers.rs @@ -115,6 +115,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_to_magnitude_and_suffix_not_powers_of_1024() { assert_eq!(to_magnitude_and_suffix(1, SuffixType::Si), "1.0 B"); assert_eq!(to_magnitude_and_suffix(999, SuffixType::Si), "999 B"); diff --git a/src/uu/dd/src/parseargs/unit_tests.rs b/src/uu/dd/src/parseargs/unit_tests.rs index a190fd75b..142e49fd0 100644 --- a/src/uu/dd/src/parseargs/unit_tests.rs +++ b/src/uu/dd/src/parseargs/unit_tests.rs @@ -103,6 +103,7 @@ fn test_status_level_none() { } #[test] +#[allow(clippy::cognitive_complexity)] fn test_all_top_level_args_no_leading_dashes() { let args = &[ "if=foo.file", diff --git a/src/uu/df/src/blocks.rs b/src/uu/df/src/blocks.rs index 9bc16b782..fad8f7ac0 100644 --- a/src/uu/df/src/blocks.rs +++ b/src/uu/df/src/blocks.rs @@ -239,6 +239,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_to_magnitude_and_suffix_not_powers_of_1024() { assert_eq!(to_magnitude_and_suffix(1, SuffixType::Si), "1B"); assert_eq!(to_magnitude_and_suffix(999, SuffixType::Si), "999B"); diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index d6e4db5a7..c533f5a5d 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -548,6 +548,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn all_args_test() { assert!(options("--silent").unwrap().quiet); assert!(options("--quiet").unwrap().quiet); diff --git a/src/uu/head/src/parse.rs b/src/uu/head/src/parse.rs index 7f7dd48f8..062a1844c 100644 --- a/src/uu/head/src/parse.rs +++ b/src/uu/head/src/parse.rs @@ -153,6 +153,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_parse_numbers_obsolete() { assert_eq!(obsolete("-5"), obsolete_result(&["-n", "5"])); assert_eq!(obsolete("-100"), obsolete_result(&["-n", "100"])); diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 71b4aac28..61ca8406f 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -394,6 +394,7 @@ mod test { use super::*; #[test] + #[allow(clippy::cognitive_complexity)] fn test_format() { assert_eq!(NumberFormat::Left.format(12, 1), "12"); assert_eq!(NumberFormat::Left.format(-12, 1), "-12"); diff --git a/src/uu/numfmt/src/format.rs b/src/uu/numfmt/src/format.rs index 08bb0c2e7..034d900e9 100644 --- a/src/uu/numfmt/src/format.rs +++ b/src/uu/numfmt/src/format.rs @@ -430,6 +430,7 @@ mod tests { use super::*; #[test] + #[allow(clippy::cognitive_complexity)] fn test_round_with_precision() { let rm = RoundMethod::FromZero; assert_eq!(1.0, round_with_precision(0.12345, rm, 0)); diff --git a/src/uu/numfmt/src/options.rs b/src/uu/numfmt/src/options.rs index 07b364f18..88e64e963 100644 --- a/src/uu/numfmt/src/options.rs +++ b/src/uu/numfmt/src/options.rs @@ -266,6 +266,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_parse_format_with_invalid_formats() { assert!("".parse::().is_err()); assert!("hello".parse::().is_err()); diff --git a/src/uu/od/src/prn_float.rs b/src/uu/od/src/prn_float.rs index f4d018bd8..f44abf7c4 100644 --- a/src/uu/od/src/prn_float.rs +++ b/src/uu/od/src/prn_float.rs @@ -198,6 +198,7 @@ fn test_format_flo64() { } #[test] +#[allow(clippy::cognitive_complexity)] fn test_format_flo16() { assert_eq!(format_flo16(f16::from_bits(0x8400u16)), "-6.104e-5"); assert_eq!(format_flo16(f16::from_bits(0x8401u16)), "-6.109e-5"); diff --git a/src/uu/seq/src/numberparse.rs b/src/uu/seq/src/numberparse.rs index 469917255..3f4b21395 100644 --- a/src/uu/seq/src/numberparse.rs +++ b/src/uu/seq/src/numberparse.rs @@ -538,6 +538,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_num_integral_digits() { // no decimal, no exponent assert_eq!(num_integral_digits("123"), 3); @@ -578,6 +579,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_num_fractional_digits() { // no decimal, no exponent assert_eq!(num_fractional_digits("123"), 0); diff --git a/src/uu/split/src/number.rs b/src/uu/split/src/number.rs index 39d64f927..a01701c80 100644 --- a/src/uu/split/src/number.rs +++ b/src/uu/split/src/number.rs @@ -398,6 +398,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_dynamic_width_number_display_alphabetic() { fn num(n: usize) -> Number { let mut number = Number::DynamicWidth(DynamicWidthNumber::new(26, 0)); @@ -443,6 +444,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_dynamic_width_number_display_numeric_hexadecimal() { fn num(n: usize) -> Number { let mut number = Number::DynamicWidth(DynamicWidthNumber::new(16, 0)); @@ -467,6 +469,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_fixed_width_number_increment() { let mut n = Number::FixedWidth(FixedWidthNumber::new(3, 2, 0).unwrap()); assert_eq!(n.digits(), vec![0, 0]); @@ -490,6 +493,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_fixed_width_number_display_alphabetic() { fn num(n: usize) -> Result { let mut number = Number::FixedWidth(FixedWidthNumber::new(26, 2, 0).unwrap()); diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 020ada93b..84b5900cc 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -1846,6 +1846,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_number_type_from_error() { assert_eq!( NumberType::from("xyz").unwrap_err(), diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 055393578..7d1fd574c 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -947,6 +947,7 @@ mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_group_num() { assert_eq!("12,379,821,234", group_num("12379821234")); assert_eq!("21,234", group_num("21234")); From ae1c4ccfd21e5b1c8541462c8afeac5c0f5fde05 Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Sat, 14 Oct 2023 01:56:38 +0800 Subject: [PATCH 309/370] expr: short-circuit evaluation for `&` --- src/uu/expr/src/syntax_tree.rs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index 4ca723a4d..e0e786b3a 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -166,16 +166,26 @@ impl AstNode { { let mut out = Vec::with_capacity(operands.len()); let mut operands = operands.iter(); - // check the first value before `|`, stop evaluate and return directly if it is true. - // push dummy to pass the check of `len() == 2` - if op_type == "|" { - if let Some(value) = operands.next() { - let value = value.evaluate()?; - out.push(value.clone()); - if value_as_bool(&value) { - out.push(String::from("dummy")); - return Ok(out); + + if let Some(value) = operands.next() { + let value = value.evaluate()?; + out.push(value.clone()); + // short-circuit evaluation for `|` and `&` + // push dummy to pass `assert!(values.len() == 2);` + match op_type.as_ref() { + "|" => { + if value_as_bool(&value) { + out.push(String::from("dummy")); + return Ok(out); + } } + "&" => { + if !value_as_bool(&value) { + out.push(String::from("dummy")); + return Ok(out); + } + } + _ => {} } } From 40f05a331e26a6f27a86dfd13cd1eb8095b7b549 Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Sat, 14 Oct 2023 01:58:53 +0800 Subject: [PATCH 310/370] tests/expr: add tests for test_and --- tests/by-util/test_expr.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index 4637d51c7..1064ef525 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -155,6 +155,21 @@ fn test_and() { .args(&["-14", "&", "1"]) .run() .stdout_is("-14\n"); + + new_ucmd!() + .args(&["0", "&", "a", "/", "5"]) + .run() + .stdout_only("0\n"); + + new_ucmd!() + .args(&["", "&", "a", "/", "5"]) + .run() + .stdout_only("0\n"); + + new_ucmd!() + .args(&["-1", "&", "10", "/", "5"]) + .succeeds() + .stdout_only("-1\n"); } #[test] From f979f148c11780a28fc23aafc2c68feab20b340a Mon Sep 17 00:00:00 2001 From: tommady Date: Sat, 14 Oct 2023 13:33:43 +0800 Subject: [PATCH 311/370] fuzz: store the corpus using GitHub Cache (#5363) --- .github/workflows/CICD.yml | 1 - .github/workflows/fuzzing.yml | 32 ++++++++++++++++---------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index b971b0e00..6583a0094 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -1012,4 +1012,3 @@ jobs: flags: ${{ steps.vars.outputs.CODECOV_FLAGS }} name: codecov-umbrella fail_ci_if_error: false - diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml index 677df2c9f..311d6a0d7 100644 --- a/.github/workflows/fuzzing.yml +++ b/.github/workflows/fuzzing.yml @@ -24,41 +24,41 @@ jobs: - name: Install `cargo-fuzz` run: cargo install cargo-fuzz - uses: Swatinem/rust-cache@v2 + - name: Restore Cached Corpus + uses: actions/cache/restore@v3 + with: + key: corpus-cache + path: | + fuzz/corpus - name: Run fuzz_date for XX seconds - shell: bash - run: | - ## Run it - cd fuzz - cargo +nightly fuzz run fuzz_date -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - - name: Run fuzz_test for XX seconds continue-on-error: true shell: bash run: | - ## Run it - cd fuzz + cargo +nightly fuzz run fuzz_date -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 + - name: Run fuzz_test for XX seconds + shell: bash + run: | cargo +nightly fuzz run fuzz_test -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - name: Run fuzz_expr for XX seconds continue-on-error: true shell: bash run: | - ## Run it - cd fuzz cargo +nightly fuzz run fuzz_expr -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - name: Run fuzz_parse_glob for XX seconds shell: bash run: | - ## Run it - cd fuzz cargo +nightly fuzz run fuzz_parse_glob -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - name: Run fuzz_parse_size for XX seconds shell: bash run: | - ## Run it - cd fuzz cargo +nightly fuzz run fuzz_parse_size -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 - name: Run fuzz_parse_time for XX seconds shell: bash run: | - ## Run it - cd fuzz cargo +nightly fuzz run fuzz_parse_time -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 + - name: Save Corpus Cache + uses: actions/cache/save@v3 + with: + key: corpus-cache + path: | + fuzz/corpus From 505ef714b9980707f118ec29c185a47e6c99360b Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 14 Oct 2023 11:41:48 +0200 Subject: [PATCH 312/370] rm: In some cases, remove_dir is doing a better job than remove_dir_all use it when remove_dir_all failed GNU compatibility (rm/empty-inacc.sh) --- src/uu/rm/src/rm.rs | 22 ++++++++++++++-------- tests/by-util/test_rm.rs | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 87767b904..29ebd4758 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -330,14 +330,20 @@ fn handle_dir(path: &Path, options: &Options) -> bool { if options.recursive && (!is_root || !options.preserve_root) { if options.interactive != InteractiveMode::Always && !options.verbose { if let Err(e) = fs::remove_dir_all(path) { - had_err = true; - if e.kind() == std::io::ErrorKind::PermissionDenied { - // GNU compatibility (rm/fail-eacces.sh) - // here, GNU doesn't use some kind of remove_dir_all - // It will show directory+file - show_error!("cannot remove {}: {}", path.quote(), "Permission denied"); - } else { - show_error!("cannot remove {}: {}", path.quote(), e); + // GNU compatibility (rm/empty-inacc.sh) + // remove_dir_all failed. maybe it is because of the permissions + // but if the directory is empty, remove_dir might work. + // So, let's try that before failing for real + if let Err(_e) = fs::remove_dir(path) { + had_err = true; + if e.kind() == std::io::ErrorKind::PermissionDenied { + // GNU compatibility (rm/fail-eacces.sh) + // here, GNU doesn't use some kind of remove_dir_all + // It will show directory+file + show_error!("cannot remove {}: {}", path.quote(), "Permission denied"); + } else { + show_error!("cannot remove {}: {}", path.quote(), e); + } } } } else { diff --git a/tests/by-util/test_rm.rs b/tests/by-util/test_rm.rs index 73f99566c..5125c746d 100644 --- a/tests/by-util/test_rm.rs +++ b/tests/by-util/test_rm.rs @@ -647,6 +647,21 @@ fn test_prompt_write_protected_no() { assert!(at.file_exists(file_2)); } +#[cfg(feature = "chmod")] +#[test] +fn test_remove_inaccessible_dir() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + let dir_1 = "test_rm_protected"; + + at.mkdir(dir_1); + + scene.ccmd("chmod").arg("0").arg(dir_1).succeeds(); + + scene.ucmd().arg("-rf").arg(dir_1).succeeds(); + assert!(!at.dir_exists(dir_1)); +} + #[test] #[cfg(not(windows))] fn test_fifo_removal() { From f557c5936430de6b864e8b1f120a41b160d65f74 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 14 Oct 2023 11:43:07 +0200 Subject: [PATCH 313/370] doc: recommend the rust-gdb helper --- DEVELOPMENT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 308daba98..9cb81a88c 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -157,7 +157,7 @@ cargo nextest run --features unix --no-fail-fast To debug: ```shell -gdb --args target/debug/coreutils ls +rust-gdb --args target/debug/coreutils ls (gdb) b ls.rs:79 (gdb) run ``` From 226680aa001457140985412adbdd5778d3dddc6e Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 14 Oct 2023 13:45:29 +0200 Subject: [PATCH 314/370] Ignore inacc spell --- src/uu/rm/src/rm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 29ebd4758..cb88b6a2b 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (path) eacces +// spell-checker:ignore (path) eacces inacc use clap::{builder::ValueParser, crate_version, parser::ValueSource, Arg, ArgAction, Command}; use std::collections::VecDeque; From f6880bff8f5faca21a2e420261d0aac258ac9eb7 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 14 Oct 2023 14:58:41 +0200 Subject: [PATCH 315/370] expr: test some invalid syntaxes --- tests/by-util/test_expr.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index 1064ef525..3f403c7ea 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -275,3 +275,16 @@ fn test_invalid_substr() { .code_is(1) .stdout_only("\n"); } + +#[test] +fn test_invalid_syntax() { + let invalid_syntaxes = [["12", "12"], ["12", "|"], ["|", "12"]]; + + for invalid_syntax in invalid_syntaxes { + new_ucmd!() + .args(&invalid_syntax) + .fails() + .code_is(2) + .stderr_contains("syntax error"); + } +} From 5b1755387f85217680831e582b97fb62d002db0c Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Sat, 14 Oct 2023 23:18:15 +0800 Subject: [PATCH 316/370] tests/expr: test escape --- tests/by-util/test_expr.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index 1064ef525..b70c60fb3 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -138,6 +138,11 @@ fn test_or() { .args(&["0", "|", "10", "/", "5"]) .succeeds() .stdout_only("2\n"); + + new_ucmd!() + .args(&["12", "|", "9a", "+", "1"]) + .succeeds() + .stdout_only("12\n"); } #[test] @@ -275,3 +280,23 @@ fn test_invalid_substr() { .code_is(1) .stdout_only("\n"); } + +#[test] +fn test_escape() { + new_ucmd!().args(&["+", "1"]).succeeds().stdout_only("1\n"); + + new_ucmd!() + .args(&["1", "+", "+", "1"]) + .succeeds() + .stdout_only("2\n"); + + new_ucmd!() + .args(&["2", "*", "+", "3"]) + .succeeds() + .stdout_only("6\n"); + + new_ucmd!() + .args(&["(", "1", ")", "+", "1"]) + .succeeds() + .stdout_only("2\n"); +} From 4f20773b4f78dcd1d8648bb93c11c5141b6f9095 Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Sat, 14 Oct 2023 23:20:45 +0800 Subject: [PATCH 317/370] expr: fix escape --- src/uu/expr/src/tokens.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/uu/expr/src/tokens.rs b/src/uu/expr/src/tokens.rs index 3c5cac060..896193515 100644 --- a/src/uu/expr/src/tokens.rs +++ b/src/uu/expr/src/tokens.rs @@ -16,8 +16,6 @@ // spell-checker:ignore (ToDO) paren -use num_bigint::BigInt; - #[derive(Debug, Clone)] pub enum Token { Value { @@ -59,11 +57,8 @@ impl Token { } } - fn is_a_number(&self) -> bool { - match self { - Self::Value { value, .. } => value.parse::().is_ok(), - _ => false, - } + fn is_a_value(&self) -> bool { + matches!(*self, Self::Value { .. }) } fn is_a_close_paren(&self) -> bool { @@ -131,14 +126,14 @@ fn maybe_dump_tokens_acc(tokens_acc: &[(usize, Token)]) { } fn push_token_if_not_escaped(acc: &mut Vec<(usize, Token)>, tok_idx: usize, token: Token, s: &str) { - // Smells heuristics... :( + // `+` may escaped such as `expr + 1` and `expr 1 + + 1` let prev_is_plus = match acc.last() { None => false, Some(t) => t.1.is_infix_plus(), }; let should_use_as_escaped = if prev_is_plus && acc.len() >= 2 { let pre_prev = &acc[acc.len() - 2]; - !(pre_prev.1.is_a_number() || pre_prev.1.is_a_close_paren()) + !(pre_prev.1.is_a_value() || pre_prev.1.is_a_close_paren()) } else { prev_is_plus }; From f89e6943b7ad7b00b4b0843cf756d3274b48357b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 14 Oct 2023 15:34:14 +0000 Subject: [PATCH 318/370] chore(deps): update rust crate regex to 1.10.1 --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a0a62d13b..f9be5346f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1728,9 +1728,9 @@ checksum = "f1bfbf25d7eb88ddcbb1ec3d755d0634da8f7657b2cb8b74089121409ab8228f" [[package]] name = "regex" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" +checksum = "aaac441002f822bc9705a681810a4dd2963094b9ca0ddc41cb963a4c189189ea" dependencies = [ "aho-corasick", "memchr", @@ -1740,9 +1740,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" +checksum = "5011c7e263a695dc8ca064cddb722af1be54e517a280b12a5356f98366899e5d" dependencies = [ "aho-corasick", "memchr", @@ -1751,9 +1751,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3cbb081b9784b07cceb8824c8583f86db4814d172ab043f3c23f7dc600bf83d" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "relative-path" diff --git a/Cargo.toml b/Cargo.toml index 820568e61..975cced35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -309,7 +309,7 @@ rand = { version = "0.8", features = ["small_rng"] } rand_core = "0.6" rayon = "1.8" redox_syscall = "0.4" -regex = "1.10.0" +regex = "1.10.1" rstest = "0.18.2" rust-ini = "0.19.0" same-file = "1.0.6" From 6ef5b272da37e44c65ea69369f6b187fe871a177 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 15 Oct 2023 14:30:17 +0200 Subject: [PATCH 319/370] expr: add missing word to comment --- src/uu/expr/src/tokens.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/expr/src/tokens.rs b/src/uu/expr/src/tokens.rs index 896193515..f499881c1 100644 --- a/src/uu/expr/src/tokens.rs +++ b/src/uu/expr/src/tokens.rs @@ -126,7 +126,7 @@ fn maybe_dump_tokens_acc(tokens_acc: &[(usize, Token)]) { } fn push_token_if_not_escaped(acc: &mut Vec<(usize, Token)>, tok_idx: usize, token: Token, s: &str) { - // `+` may escaped such as `expr + 1` and `expr 1 + + 1` + // `+` may be escaped such as `expr + 1` and `expr 1 + + 1` let prev_is_plus = match acc.last() { None => false, Some(t) => t.1.is_infix_plus(), From e1bd47d5496b468607dfec1643b29fa2fbc8e0ee Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 15 Oct 2023 14:20:18 +0200 Subject: [PATCH 320/370] 0.0.21 => 0.0.22 --- Cargo.lock | 214 ++++++++++++------------- Cargo.toml | 206 ++++++++++++------------ 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/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/dir/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/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 | 4 +- src/uu/stdbuf/src/libstdbuf/Cargo.toml | 2 +- src/uu/stty/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/vdir/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 | 2 +- src/uucore_procs/Cargo.toml | 4 +- src/uuhelp_parser/Cargo.toml | 2 +- util/update-version.sh | 4 +- 109 files changed, 320 insertions(+), 320 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f9be5346f..a54656d7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -376,7 +376,7 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "coreutils" -version = "0.0.21" +version = "0.0.22" dependencies = [ "chrono", "clap", @@ -2225,7 +2225,7 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uu_arch" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "platform-info", @@ -2234,7 +2234,7 @@ dependencies = [ [[package]] name = "uu_base32" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2242,7 +2242,7 @@ dependencies = [ [[package]] name = "uu_base64" -version = "0.0.21" +version = "0.0.22" dependencies = [ "uu_base32", "uucore", @@ -2250,7 +2250,7 @@ dependencies = [ [[package]] name = "uu_basename" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2258,7 +2258,7 @@ dependencies = [ [[package]] name = "uu_basenc" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uu_base32", @@ -2267,7 +2267,7 @@ dependencies = [ [[package]] name = "uu_cat" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "nix", @@ -2277,7 +2277,7 @@ dependencies = [ [[package]] name = "uu_chcon" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "fts-sys", @@ -2289,7 +2289,7 @@ dependencies = [ [[package]] name = "uu_chgrp" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2297,7 +2297,7 @@ dependencies = [ [[package]] name = "uu_chmod" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2306,7 +2306,7 @@ dependencies = [ [[package]] name = "uu_chown" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2314,7 +2314,7 @@ dependencies = [ [[package]] name = "uu_chroot" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2322,7 +2322,7 @@ dependencies = [ [[package]] name = "uu_cksum" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "hex", @@ -2331,7 +2331,7 @@ dependencies = [ [[package]] name = "uu_comm" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2339,7 +2339,7 @@ dependencies = [ [[package]] name = "uu_cp" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "exacl", @@ -2355,7 +2355,7 @@ dependencies = [ [[package]] name = "uu_csplit" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "regex", @@ -2365,7 +2365,7 @@ dependencies = [ [[package]] name = "uu_cut" -version = "0.0.21" +version = "0.0.22" dependencies = [ "bstr", "clap", @@ -2375,7 +2375,7 @@ dependencies = [ [[package]] name = "uu_date" -version = "0.0.21" +version = "0.0.22" dependencies = [ "chrono", "clap", @@ -2387,7 +2387,7 @@ dependencies = [ [[package]] name = "uu_dd" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "gcd", @@ -2399,7 +2399,7 @@ dependencies = [ [[package]] name = "uu_df" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "tempfile", @@ -2409,7 +2409,7 @@ dependencies = [ [[package]] name = "uu_dir" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uu_ls", @@ -2418,7 +2418,7 @@ dependencies = [ [[package]] name = "uu_dircolors" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2426,7 +2426,7 @@ dependencies = [ [[package]] name = "uu_dirname" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2434,7 +2434,7 @@ dependencies = [ [[package]] name = "uu_du" -version = "0.0.21" +version = "0.0.22" dependencies = [ "chrono", "clap", @@ -2445,7 +2445,7 @@ dependencies = [ [[package]] name = "uu_echo" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2453,7 +2453,7 @@ dependencies = [ [[package]] name = "uu_env" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "nix", @@ -2463,7 +2463,7 @@ dependencies = [ [[package]] name = "uu_expand" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "unicode-width", @@ -2472,7 +2472,7 @@ dependencies = [ [[package]] name = "uu_expr" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "num-bigint", @@ -2483,7 +2483,7 @@ dependencies = [ [[package]] name = "uu_factor" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "coz", @@ -2496,7 +2496,7 @@ dependencies = [ [[package]] name = "uu_false" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2504,7 +2504,7 @@ dependencies = [ [[package]] name = "uu_fmt" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "unicode-width", @@ -2513,7 +2513,7 @@ dependencies = [ [[package]] name = "uu_fold" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2521,7 +2521,7 @@ dependencies = [ [[package]] name = "uu_groups" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2529,7 +2529,7 @@ dependencies = [ [[package]] name = "uu_hashsum" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "hex", @@ -2540,7 +2540,7 @@ dependencies = [ [[package]] name = "uu_head" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "memchr", @@ -2549,7 +2549,7 @@ dependencies = [ [[package]] name = "uu_hostid" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2558,7 +2558,7 @@ dependencies = [ [[package]] name = "uu_hostname" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "hostname", @@ -2568,7 +2568,7 @@ dependencies = [ [[package]] name = "uu_id" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "selinux", @@ -2577,7 +2577,7 @@ dependencies = [ [[package]] name = "uu_install" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "file_diff", @@ -2588,7 +2588,7 @@ dependencies = [ [[package]] name = "uu_join" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "memchr", @@ -2597,7 +2597,7 @@ dependencies = [ [[package]] name = "uu_kill" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "nix", @@ -2606,7 +2606,7 @@ dependencies = [ [[package]] name = "uu_link" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2614,7 +2614,7 @@ dependencies = [ [[package]] name = "uu_ln" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2622,7 +2622,7 @@ dependencies = [ [[package]] name = "uu_logname" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2631,7 +2631,7 @@ dependencies = [ [[package]] name = "uu_ls" -version = "0.0.21" +version = "0.0.22" dependencies = [ "chrono", "clap", @@ -2648,7 +2648,7 @@ dependencies = [ [[package]] name = "uu_mkdir" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2656,7 +2656,7 @@ dependencies = [ [[package]] name = "uu_mkfifo" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2665,7 +2665,7 @@ dependencies = [ [[package]] name = "uu_mknod" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2674,7 +2674,7 @@ dependencies = [ [[package]] name = "uu_mktemp" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "rand", @@ -2684,7 +2684,7 @@ dependencies = [ [[package]] name = "uu_more" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "crossterm", @@ -2696,7 +2696,7 @@ dependencies = [ [[package]] name = "uu_mv" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "fs_extra", @@ -2706,7 +2706,7 @@ dependencies = [ [[package]] name = "uu_nice" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2716,7 +2716,7 @@ dependencies = [ [[package]] name = "uu_nl" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "regex", @@ -2725,7 +2725,7 @@ dependencies = [ [[package]] name = "uu_nohup" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2734,7 +2734,7 @@ dependencies = [ [[package]] name = "uu_nproc" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2743,7 +2743,7 @@ dependencies = [ [[package]] name = "uu_numfmt" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2751,7 +2751,7 @@ dependencies = [ [[package]] name = "uu_od" -version = "0.0.21" +version = "0.0.22" dependencies = [ "byteorder", "clap", @@ -2761,7 +2761,7 @@ dependencies = [ [[package]] name = "uu_paste" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2769,7 +2769,7 @@ dependencies = [ [[package]] name = "uu_pathchk" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2778,7 +2778,7 @@ dependencies = [ [[package]] name = "uu_pinky" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2786,7 +2786,7 @@ dependencies = [ [[package]] name = "uu_pr" -version = "0.0.21" +version = "0.0.22" dependencies = [ "chrono", "clap", @@ -2798,7 +2798,7 @@ dependencies = [ [[package]] name = "uu_printenv" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2806,7 +2806,7 @@ dependencies = [ [[package]] name = "uu_printf" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2814,7 +2814,7 @@ dependencies = [ [[package]] name = "uu_ptx" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "regex", @@ -2823,7 +2823,7 @@ dependencies = [ [[package]] name = "uu_pwd" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2831,7 +2831,7 @@ dependencies = [ [[package]] name = "uu_readlink" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2839,7 +2839,7 @@ dependencies = [ [[package]] name = "uu_realpath" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2847,7 +2847,7 @@ dependencies = [ [[package]] name = "uu_rm" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2858,7 +2858,7 @@ dependencies = [ [[package]] name = "uu_rmdir" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2867,7 +2867,7 @@ dependencies = [ [[package]] name = "uu_runcon" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2878,7 +2878,7 @@ dependencies = [ [[package]] name = "uu_seq" -version = "0.0.21" +version = "0.0.22" dependencies = [ "bigdecimal", "clap", @@ -2889,7 +2889,7 @@ dependencies = [ [[package]] name = "uu_shred" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -2899,7 +2899,7 @@ dependencies = [ [[package]] name = "uu_shuf" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "memchr", @@ -2910,7 +2910,7 @@ dependencies = [ [[package]] name = "uu_sleep" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "fundu", @@ -2919,7 +2919,7 @@ dependencies = [ [[package]] name = "uu_sort" -version = "0.0.21" +version = "0.0.22" dependencies = [ "binary-heap-plus", "clap", @@ -2938,7 +2938,7 @@ dependencies = [ [[package]] name = "uu_split" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "memchr", @@ -2947,7 +2947,7 @@ dependencies = [ [[package]] name = "uu_stat" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2955,7 +2955,7 @@ dependencies = [ [[package]] name = "uu_stdbuf" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "tempfile", @@ -2965,7 +2965,7 @@ dependencies = [ [[package]] name = "uu_stdbuf_libstdbuf" -version = "0.0.21" +version = "0.0.22" dependencies = [ "cpp", "cpp_build", @@ -2975,7 +2975,7 @@ dependencies = [ [[package]] name = "uu_stty" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "nix", @@ -2984,7 +2984,7 @@ dependencies = [ [[package]] name = "uu_sum" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -2992,7 +2992,7 @@ dependencies = [ [[package]] name = "uu_sync" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -3003,7 +3003,7 @@ dependencies = [ [[package]] name = "uu_tac" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "memchr", @@ -3014,7 +3014,7 @@ dependencies = [ [[package]] name = "uu_tail" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "fundu", @@ -3030,7 +3030,7 @@ dependencies = [ [[package]] name = "uu_tee" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -3039,7 +3039,7 @@ dependencies = [ [[package]] name = "uu_test" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -3049,7 +3049,7 @@ dependencies = [ [[package]] name = "uu_timeout" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -3059,7 +3059,7 @@ dependencies = [ [[package]] name = "uu_touch" -version = "0.0.21" +version = "0.0.22" dependencies = [ "chrono", "clap", @@ -3071,7 +3071,7 @@ dependencies = [ [[package]] name = "uu_tr" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "nom", @@ -3080,7 +3080,7 @@ dependencies = [ [[package]] name = "uu_true" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -3088,7 +3088,7 @@ dependencies = [ [[package]] name = "uu_truncate" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -3096,7 +3096,7 @@ dependencies = [ [[package]] name = "uu_tsort" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -3104,7 +3104,7 @@ dependencies = [ [[package]] name = "uu_tty" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "nix", @@ -3113,7 +3113,7 @@ dependencies = [ [[package]] name = "uu_uname" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "platform-info", @@ -3122,7 +3122,7 @@ dependencies = [ [[package]] name = "uu_unexpand" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "unicode-width", @@ -3131,7 +3131,7 @@ dependencies = [ [[package]] name = "uu_uniq" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -3139,7 +3139,7 @@ dependencies = [ [[package]] name = "uu_unlink" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -3147,7 +3147,7 @@ dependencies = [ [[package]] name = "uu_uptime" -version = "0.0.21" +version = "0.0.22" dependencies = [ "chrono", "clap", @@ -3156,7 +3156,7 @@ dependencies = [ [[package]] name = "uu_users" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -3164,7 +3164,7 @@ dependencies = [ [[package]] name = "uu_vdir" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uu_ls", @@ -3173,7 +3173,7 @@ dependencies = [ [[package]] name = "uu_wc" -version = "0.0.21" +version = "0.0.22" dependencies = [ "bytecount", "clap", @@ -3186,7 +3186,7 @@ dependencies = [ [[package]] name = "uu_who" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "uucore", @@ -3194,7 +3194,7 @@ dependencies = [ [[package]] name = "uu_whoami" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "libc", @@ -3204,7 +3204,7 @@ dependencies = [ [[package]] name = "uu_yes" -version = "0.0.21" +version = "0.0.22" dependencies = [ "clap", "itertools", @@ -3214,7 +3214,7 @@ dependencies = [ [[package]] name = "uucore" -version = "0.0.21" +version = "0.0.22" dependencies = [ "blake2b_simd", "blake3", @@ -3250,7 +3250,7 @@ dependencies = [ [[package]] name = "uucore_procs" -version = "0.0.21" +version = "0.0.22" dependencies = [ "proc-macro2", "quote", @@ -3259,7 +3259,7 @@ dependencies = [ [[package]] name = "uuhelp_parser" -version = "0.0.21" +version = "0.0.22" [[package]] name = "uuid" diff --git a/Cargo.toml b/Cargo.toml index 975cced35..39232b50d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ [package] name = "coreutils" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "coreutils ~ GNU coreutils (updated); implemented as universal (cross-platform) utils, written in Rust" @@ -361,109 +361,109 @@ zip = { workspace = true, optional = true } uuhelp_parser = { optional = true, version = ">=0.0.19", path = "src/uuhelp_parser" } # * uutils -uu_test = { optional = true, version = "0.0.21", package = "uu_test", path = "src/uu/test" } +uu_test = { optional = true, version = "0.0.22", package = "uu_test", path = "src/uu/test" } # -arch = { optional = true, version = "0.0.21", package = "uu_arch", path = "src/uu/arch" } -base32 = { optional = true, version = "0.0.21", package = "uu_base32", path = "src/uu/base32" } -base64 = { optional = true, version = "0.0.21", package = "uu_base64", path = "src/uu/base64" } -basename = { optional = true, version = "0.0.21", package = "uu_basename", path = "src/uu/basename" } -basenc = { optional = true, version = "0.0.21", package = "uu_basenc", path = "src/uu/basenc" } -cat = { optional = true, version = "0.0.21", package = "uu_cat", path = "src/uu/cat" } -chcon = { optional = true, version = "0.0.21", package = "uu_chcon", path = "src/uu/chcon" } -chgrp = { optional = true, version = "0.0.21", package = "uu_chgrp", path = "src/uu/chgrp" } -chmod = { optional = true, version = "0.0.21", package = "uu_chmod", path = "src/uu/chmod" } -chown = { optional = true, version = "0.0.21", package = "uu_chown", path = "src/uu/chown" } -chroot = { optional = true, version = "0.0.21", package = "uu_chroot", path = "src/uu/chroot" } -cksum = { optional = true, version = "0.0.21", package = "uu_cksum", path = "src/uu/cksum" } -comm = { optional = true, version = "0.0.21", package = "uu_comm", path = "src/uu/comm" } -cp = { optional = true, version = "0.0.21", package = "uu_cp", path = "src/uu/cp" } -csplit = { optional = true, version = "0.0.21", package = "uu_csplit", path = "src/uu/csplit" } -cut = { optional = true, version = "0.0.21", package = "uu_cut", path = "src/uu/cut" } -date = { optional = true, version = "0.0.21", package = "uu_date", path = "src/uu/date" } -dd = { optional = true, version = "0.0.21", package = "uu_dd", path = "src/uu/dd" } -df = { optional = true, version = "0.0.21", package = "uu_df", path = "src/uu/df" } -dir = { optional = true, version = "0.0.21", package = "uu_dir", path = "src/uu/dir" } -dircolors = { optional = true, version = "0.0.21", package = "uu_dircolors", path = "src/uu/dircolors" } -dirname = { optional = true, version = "0.0.21", package = "uu_dirname", path = "src/uu/dirname" } -du = { optional = true, version = "0.0.21", package = "uu_du", path = "src/uu/du" } -echo = { optional = true, version = "0.0.21", package = "uu_echo", path = "src/uu/echo" } -env = { optional = true, version = "0.0.21", package = "uu_env", path = "src/uu/env" } -expand = { optional = true, version = "0.0.21", package = "uu_expand", path = "src/uu/expand" } -expr = { optional = true, version = "0.0.21", package = "uu_expr", path = "src/uu/expr" } -factor = { optional = true, version = "0.0.21", package = "uu_factor", path = "src/uu/factor" } -false = { optional = true, version = "0.0.21", package = "uu_false", path = "src/uu/false" } -fmt = { optional = true, version = "0.0.21", package = "uu_fmt", path = "src/uu/fmt" } -fold = { optional = true, version = "0.0.21", package = "uu_fold", path = "src/uu/fold" } -groups = { optional = true, version = "0.0.21", package = "uu_groups", path = "src/uu/groups" } -hashsum = { optional = true, version = "0.0.21", package = "uu_hashsum", path = "src/uu/hashsum" } -head = { optional = true, version = "0.0.21", package = "uu_head", path = "src/uu/head" } -hostid = { optional = true, version = "0.0.21", package = "uu_hostid", path = "src/uu/hostid" } -hostname = { optional = true, version = "0.0.21", package = "uu_hostname", path = "src/uu/hostname" } -id = { optional = true, version = "0.0.21", package = "uu_id", path = "src/uu/id" } -install = { optional = true, version = "0.0.21", package = "uu_install", path = "src/uu/install" } -join = { optional = true, version = "0.0.21", package = "uu_join", path = "src/uu/join" } -kill = { optional = true, version = "0.0.21", package = "uu_kill", path = "src/uu/kill" } -link = { optional = true, version = "0.0.21", package = "uu_link", path = "src/uu/link" } -ln = { optional = true, version = "0.0.21", package = "uu_ln", path = "src/uu/ln" } -ls = { optional = true, version = "0.0.21", package = "uu_ls", path = "src/uu/ls" } -logname = { optional = true, version = "0.0.21", package = "uu_logname", path = "src/uu/logname" } -mkdir = { optional = true, version = "0.0.21", package = "uu_mkdir", path = "src/uu/mkdir" } -mkfifo = { optional = true, version = "0.0.21", package = "uu_mkfifo", path = "src/uu/mkfifo" } -mknod = { optional = true, version = "0.0.21", package = "uu_mknod", path = "src/uu/mknod" } -mktemp = { optional = true, version = "0.0.21", package = "uu_mktemp", path = "src/uu/mktemp" } -more = { optional = true, version = "0.0.21", package = "uu_more", path = "src/uu/more" } -mv = { optional = true, version = "0.0.21", package = "uu_mv", path = "src/uu/mv" } -nice = { optional = true, version = "0.0.21", package = "uu_nice", path = "src/uu/nice" } -nl = { optional = true, version = "0.0.21", package = "uu_nl", path = "src/uu/nl" } -nohup = { optional = true, version = "0.0.21", package = "uu_nohup", path = "src/uu/nohup" } -nproc = { optional = true, version = "0.0.21", package = "uu_nproc", path = "src/uu/nproc" } -numfmt = { optional = true, version = "0.0.21", package = "uu_numfmt", path = "src/uu/numfmt" } -od = { optional = true, version = "0.0.21", package = "uu_od", path = "src/uu/od" } -paste = { optional = true, version = "0.0.21", package = "uu_paste", path = "src/uu/paste" } -pathchk = { optional = true, version = "0.0.21", package = "uu_pathchk", path = "src/uu/pathchk" } -pinky = { optional = true, version = "0.0.21", package = "uu_pinky", path = "src/uu/pinky" } -pr = { optional = true, version = "0.0.21", package = "uu_pr", path = "src/uu/pr" } -printenv = { optional = true, version = "0.0.21", package = "uu_printenv", path = "src/uu/printenv" } -printf = { optional = true, version = "0.0.21", package = "uu_printf", path = "src/uu/printf" } -ptx = { optional = true, version = "0.0.21", package = "uu_ptx", path = "src/uu/ptx" } -pwd = { optional = true, version = "0.0.21", package = "uu_pwd", path = "src/uu/pwd" } -readlink = { optional = true, version = "0.0.21", package = "uu_readlink", path = "src/uu/readlink" } -realpath = { optional = true, version = "0.0.21", package = "uu_realpath", path = "src/uu/realpath" } -rm = { optional = true, version = "0.0.21", package = "uu_rm", path = "src/uu/rm" } -rmdir = { optional = true, version = "0.0.21", package = "uu_rmdir", path = "src/uu/rmdir" } -runcon = { optional = true, version = "0.0.21", package = "uu_runcon", path = "src/uu/runcon" } -seq = { optional = true, version = "0.0.21", package = "uu_seq", path = "src/uu/seq" } -shred = { optional = true, version = "0.0.21", package = "uu_shred", path = "src/uu/shred" } -shuf = { optional = true, version = "0.0.21", package = "uu_shuf", path = "src/uu/shuf" } -sleep = { optional = true, version = "0.0.21", package = "uu_sleep", path = "src/uu/sleep" } -sort = { optional = true, version = "0.0.21", package = "uu_sort", path = "src/uu/sort" } -split = { optional = true, version = "0.0.21", package = "uu_split", path = "src/uu/split" } -stat = { optional = true, version = "0.0.21", package = "uu_stat", path = "src/uu/stat" } -stdbuf = { optional = true, version = "0.0.21", package = "uu_stdbuf", path = "src/uu/stdbuf" } -stty = { optional = true, version = "0.0.21", package = "uu_stty", path = "src/uu/stty" } -sum = { optional = true, version = "0.0.21", package = "uu_sum", path = "src/uu/sum" } -sync = { optional = true, version = "0.0.21", package = "uu_sync", path = "src/uu/sync" } -tac = { optional = true, version = "0.0.21", package = "uu_tac", path = "src/uu/tac" } -tail = { optional = true, version = "0.0.21", package = "uu_tail", path = "src/uu/tail" } -tee = { optional = true, version = "0.0.21", package = "uu_tee", path = "src/uu/tee" } -timeout = { optional = true, version = "0.0.21", package = "uu_timeout", path = "src/uu/timeout" } -touch = { optional = true, version = "0.0.21", package = "uu_touch", path = "src/uu/touch" } -tr = { optional = true, version = "0.0.21", package = "uu_tr", path = "src/uu/tr" } -true = { optional = true, version = "0.0.21", package = "uu_true", path = "src/uu/true" } -truncate = { optional = true, version = "0.0.21", package = "uu_truncate", path = "src/uu/truncate" } -tsort = { optional = true, version = "0.0.21", package = "uu_tsort", path = "src/uu/tsort" } -tty = { optional = true, version = "0.0.21", package = "uu_tty", path = "src/uu/tty" } -uname = { optional = true, version = "0.0.21", package = "uu_uname", path = "src/uu/uname" } -unexpand = { optional = true, version = "0.0.21", package = "uu_unexpand", path = "src/uu/unexpand" } -uniq = { optional = true, version = "0.0.21", package = "uu_uniq", path = "src/uu/uniq" } -unlink = { optional = true, version = "0.0.21", package = "uu_unlink", path = "src/uu/unlink" } -uptime = { optional = true, version = "0.0.21", package = "uu_uptime", path = "src/uu/uptime" } -users = { optional = true, version = "0.0.21", package = "uu_users", path = "src/uu/users" } -vdir = { optional = true, version = "0.0.21", package = "uu_vdir", path = "src/uu/vdir" } -wc = { optional = true, version = "0.0.21", package = "uu_wc", path = "src/uu/wc" } -who = { optional = true, version = "0.0.21", package = "uu_who", path = "src/uu/who" } -whoami = { optional = true, version = "0.0.21", package = "uu_whoami", path = "src/uu/whoami" } -yes = { optional = true, version = "0.0.21", package = "uu_yes", path = "src/uu/yes" } +arch = { optional = true, version = "0.0.22", package = "uu_arch", path = "src/uu/arch" } +base32 = { optional = true, version = "0.0.22", package = "uu_base32", path = "src/uu/base32" } +base64 = { optional = true, version = "0.0.22", package = "uu_base64", path = "src/uu/base64" } +basename = { optional = true, version = "0.0.22", package = "uu_basename", path = "src/uu/basename" } +basenc = { optional = true, version = "0.0.22", package = "uu_basenc", path = "src/uu/basenc" } +cat = { optional = true, version = "0.0.22", package = "uu_cat", path = "src/uu/cat" } +chcon = { optional = true, version = "0.0.22", package = "uu_chcon", path = "src/uu/chcon" } +chgrp = { optional = true, version = "0.0.22", package = "uu_chgrp", path = "src/uu/chgrp" } +chmod = { optional = true, version = "0.0.22", package = "uu_chmod", path = "src/uu/chmod" } +chown = { optional = true, version = "0.0.22", package = "uu_chown", path = "src/uu/chown" } +chroot = { optional = true, version = "0.0.22", package = "uu_chroot", path = "src/uu/chroot" } +cksum = { optional = true, version = "0.0.22", package = "uu_cksum", path = "src/uu/cksum" } +comm = { optional = true, version = "0.0.22", package = "uu_comm", path = "src/uu/comm" } +cp = { optional = true, version = "0.0.22", package = "uu_cp", path = "src/uu/cp" } +csplit = { optional = true, version = "0.0.22", package = "uu_csplit", path = "src/uu/csplit" } +cut = { optional = true, version = "0.0.22", package = "uu_cut", path = "src/uu/cut" } +date = { optional = true, version = "0.0.22", package = "uu_date", path = "src/uu/date" } +dd = { optional = true, version = "0.0.22", package = "uu_dd", path = "src/uu/dd" } +df = { optional = true, version = "0.0.22", package = "uu_df", path = "src/uu/df" } +dir = { optional = true, version = "0.0.22", package = "uu_dir", path = "src/uu/dir" } +dircolors = { optional = true, version = "0.0.22", package = "uu_dircolors", path = "src/uu/dircolors" } +dirname = { optional = true, version = "0.0.22", package = "uu_dirname", path = "src/uu/dirname" } +du = { optional = true, version = "0.0.22", package = "uu_du", path = "src/uu/du" } +echo = { optional = true, version = "0.0.22", package = "uu_echo", path = "src/uu/echo" } +env = { optional = true, version = "0.0.22", package = "uu_env", path = "src/uu/env" } +expand = { optional = true, version = "0.0.22", package = "uu_expand", path = "src/uu/expand" } +expr = { optional = true, version = "0.0.22", package = "uu_expr", path = "src/uu/expr" } +factor = { optional = true, version = "0.0.22", package = "uu_factor", path = "src/uu/factor" } +false = { optional = true, version = "0.0.22", package = "uu_false", path = "src/uu/false" } +fmt = { optional = true, version = "0.0.22", package = "uu_fmt", path = "src/uu/fmt" } +fold = { optional = true, version = "0.0.22", package = "uu_fold", path = "src/uu/fold" } +groups = { optional = true, version = "0.0.22", package = "uu_groups", path = "src/uu/groups" } +hashsum = { optional = true, version = "0.0.22", package = "uu_hashsum", path = "src/uu/hashsum" } +head = { optional = true, version = "0.0.22", package = "uu_head", path = "src/uu/head" } +hostid = { optional = true, version = "0.0.22", package = "uu_hostid", path = "src/uu/hostid" } +hostname = { optional = true, version = "0.0.22", package = "uu_hostname", path = "src/uu/hostname" } +id = { optional = true, version = "0.0.22", package = "uu_id", path = "src/uu/id" } +install = { optional = true, version = "0.0.22", package = "uu_install", path = "src/uu/install" } +join = { optional = true, version = "0.0.22", package = "uu_join", path = "src/uu/join" } +kill = { optional = true, version = "0.0.22", package = "uu_kill", path = "src/uu/kill" } +link = { optional = true, version = "0.0.22", package = "uu_link", path = "src/uu/link" } +ln = { optional = true, version = "0.0.22", package = "uu_ln", path = "src/uu/ln" } +ls = { optional = true, version = "0.0.22", package = "uu_ls", path = "src/uu/ls" } +logname = { optional = true, version = "0.0.22", package = "uu_logname", path = "src/uu/logname" } +mkdir = { optional = true, version = "0.0.22", package = "uu_mkdir", path = "src/uu/mkdir" } +mkfifo = { optional = true, version = "0.0.22", package = "uu_mkfifo", path = "src/uu/mkfifo" } +mknod = { optional = true, version = "0.0.22", package = "uu_mknod", path = "src/uu/mknod" } +mktemp = { optional = true, version = "0.0.22", package = "uu_mktemp", path = "src/uu/mktemp" } +more = { optional = true, version = "0.0.22", package = "uu_more", path = "src/uu/more" } +mv = { optional = true, version = "0.0.22", package = "uu_mv", path = "src/uu/mv" } +nice = { optional = true, version = "0.0.22", package = "uu_nice", path = "src/uu/nice" } +nl = { optional = true, version = "0.0.22", package = "uu_nl", path = "src/uu/nl" } +nohup = { optional = true, version = "0.0.22", package = "uu_nohup", path = "src/uu/nohup" } +nproc = { optional = true, version = "0.0.22", package = "uu_nproc", path = "src/uu/nproc" } +numfmt = { optional = true, version = "0.0.22", package = "uu_numfmt", path = "src/uu/numfmt" } +od = { optional = true, version = "0.0.22", package = "uu_od", path = "src/uu/od" } +paste = { optional = true, version = "0.0.22", package = "uu_paste", path = "src/uu/paste" } +pathchk = { optional = true, version = "0.0.22", package = "uu_pathchk", path = "src/uu/pathchk" } +pinky = { optional = true, version = "0.0.22", package = "uu_pinky", path = "src/uu/pinky" } +pr = { optional = true, version = "0.0.22", package = "uu_pr", path = "src/uu/pr" } +printenv = { optional = true, version = "0.0.22", package = "uu_printenv", path = "src/uu/printenv" } +printf = { optional = true, version = "0.0.22", package = "uu_printf", path = "src/uu/printf" } +ptx = { optional = true, version = "0.0.22", package = "uu_ptx", path = "src/uu/ptx" } +pwd = { optional = true, version = "0.0.22", package = "uu_pwd", path = "src/uu/pwd" } +readlink = { optional = true, version = "0.0.22", package = "uu_readlink", path = "src/uu/readlink" } +realpath = { optional = true, version = "0.0.22", package = "uu_realpath", path = "src/uu/realpath" } +rm = { optional = true, version = "0.0.22", package = "uu_rm", path = "src/uu/rm" } +rmdir = { optional = true, version = "0.0.22", package = "uu_rmdir", path = "src/uu/rmdir" } +runcon = { optional = true, version = "0.0.22", package = "uu_runcon", path = "src/uu/runcon" } +seq = { optional = true, version = "0.0.22", package = "uu_seq", path = "src/uu/seq" } +shred = { optional = true, version = "0.0.22", package = "uu_shred", path = "src/uu/shred" } +shuf = { optional = true, version = "0.0.22", package = "uu_shuf", path = "src/uu/shuf" } +sleep = { optional = true, version = "0.0.22", package = "uu_sleep", path = "src/uu/sleep" } +sort = { optional = true, version = "0.0.22", package = "uu_sort", path = "src/uu/sort" } +split = { optional = true, version = "0.0.22", package = "uu_split", path = "src/uu/split" } +stat = { optional = true, version = "0.0.22", package = "uu_stat", path = "src/uu/stat" } +stdbuf = { optional = true, version = "0.0.22", package = "uu_stdbuf", path = "src/uu/stdbuf" } +stty = { optional = true, version = "0.0.22", package = "uu_stty", path = "src/uu/stty" } +sum = { optional = true, version = "0.0.22", package = "uu_sum", path = "src/uu/sum" } +sync = { optional = true, version = "0.0.22", package = "uu_sync", path = "src/uu/sync" } +tac = { optional = true, version = "0.0.22", package = "uu_tac", path = "src/uu/tac" } +tail = { optional = true, version = "0.0.22", package = "uu_tail", path = "src/uu/tail" } +tee = { optional = true, version = "0.0.22", package = "uu_tee", path = "src/uu/tee" } +timeout = { optional = true, version = "0.0.22", package = "uu_timeout", path = "src/uu/timeout" } +touch = { optional = true, version = "0.0.22", package = "uu_touch", path = "src/uu/touch" } +tr = { optional = true, version = "0.0.22", package = "uu_tr", path = "src/uu/tr" } +true = { optional = true, version = "0.0.22", package = "uu_true", path = "src/uu/true" } +truncate = { optional = true, version = "0.0.22", package = "uu_truncate", path = "src/uu/truncate" } +tsort = { optional = true, version = "0.0.22", package = "uu_tsort", path = "src/uu/tsort" } +tty = { optional = true, version = "0.0.22", package = "uu_tty", path = "src/uu/tty" } +uname = { optional = true, version = "0.0.22", package = "uu_uname", path = "src/uu/uname" } +unexpand = { optional = true, version = "0.0.22", package = "uu_unexpand", path = "src/uu/unexpand" } +uniq = { optional = true, version = "0.0.22", package = "uu_uniq", path = "src/uu/uniq" } +unlink = { optional = true, version = "0.0.22", package = "uu_unlink", path = "src/uu/unlink" } +uptime = { optional = true, version = "0.0.22", package = "uu_uptime", path = "src/uu/uptime" } +users = { optional = true, version = "0.0.22", package = "uu_users", path = "src/uu/users" } +vdir = { optional = true, version = "0.0.22", package = "uu_vdir", path = "src/uu/vdir" } +wc = { optional = true, version = "0.0.22", package = "uu_wc", path = "src/uu/wc" } +who = { optional = true, version = "0.0.22", package = "uu_who", path = "src/uu/who" } +whoami = { optional = true, version = "0.0.22", package = "uu_whoami", path = "src/uu/whoami" } +yes = { optional = true, version = "0.0.22", package = "uu_yes", path = "src/uu/yes" } # this breaks clippy linting with: "tests/by-util/test_factor_benches.rs: No such file or directory (os error 2)" # factor_benches = { optional = true, version = "0.0.0", package = "uu_factor_benches", path = "tests/benches/factor" } diff --git a/src/uu/arch/Cargo.toml b/src/uu/arch/Cargo.toml index cd12cb4d4..9686c3f0a 100644 --- a/src/uu/arch/Cargo.toml +++ b/src/uu/arch/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_arch" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "arch ~ (uutils) display machine architecture" diff --git a/src/uu/base32/Cargo.toml b/src/uu/base32/Cargo.toml index 044b92d23..f3bca4a19 100644 --- a/src/uu/base32/Cargo.toml +++ b/src/uu/base32/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_base32" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "base32 ~ (uutils) decode/encode input (base32-encoding)" diff --git a/src/uu/base64/Cargo.toml b/src/uu/base64/Cargo.toml index 3bc045152..ddd669b89 100644 --- a/src/uu/base64/Cargo.toml +++ b/src/uu/base64/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_base64" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "base64 ~ (uutils) decode/encode input (base64-encoding)" diff --git a/src/uu/basename/Cargo.toml b/src/uu/basename/Cargo.toml index 878a5d9e1..e74ad7616 100644 --- a/src/uu/basename/Cargo.toml +++ b/src/uu/basename/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_basename" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "basename ~ (uutils) display PATHNAME with leading directory components removed" diff --git a/src/uu/basenc/Cargo.toml b/src/uu/basenc/Cargo.toml index 92912e5df..7f4188440 100644 --- a/src/uu/basenc/Cargo.toml +++ b/src/uu/basenc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_basenc" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "basenc ~ (uutils) decode/encode input" diff --git a/src/uu/cat/Cargo.toml b/src/uu/cat/Cargo.toml index 166e1823b..33488cd07 100644 --- a/src/uu/cat/Cargo.toml +++ b/src/uu/cat/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cat" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "cat ~ (uutils) concatenate and display input" diff --git a/src/uu/chcon/Cargo.toml b/src/uu/chcon/Cargo.toml index c83c8abfc..07bd73f4b 100644 --- a/src/uu/chcon/Cargo.toml +++ b/src/uu/chcon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chcon" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "chcon ~ (uutils) change file security context" diff --git a/src/uu/chgrp/Cargo.toml b/src/uu/chgrp/Cargo.toml index 7f43e8466..9591e1365 100644 --- a/src/uu/chgrp/Cargo.toml +++ b/src/uu/chgrp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chgrp" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "chgrp ~ (uutils) change the group ownership of FILE" diff --git a/src/uu/chmod/Cargo.toml b/src/uu/chmod/Cargo.toml index 2a9c73d9d..d10d0e08d 100644 --- a/src/uu/chmod/Cargo.toml +++ b/src/uu/chmod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chmod" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "chmod ~ (uutils) change mode of FILE" diff --git a/src/uu/chown/Cargo.toml b/src/uu/chown/Cargo.toml index 82b32875d..bbd75db03 100644 --- a/src/uu/chown/Cargo.toml +++ b/src/uu/chown/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chown" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "chown ~ (uutils) change the ownership of FILE" diff --git a/src/uu/chroot/Cargo.toml b/src/uu/chroot/Cargo.toml index 3c836add8..847b18ef5 100644 --- a/src/uu/chroot/Cargo.toml +++ b/src/uu/chroot/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_chroot" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "chroot ~ (uutils) run COMMAND under a new root directory" diff --git a/src/uu/cksum/Cargo.toml b/src/uu/cksum/Cargo.toml index 49a881f70..e0d54edb9 100644 --- a/src/uu/cksum/Cargo.toml +++ b/src/uu/cksum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cksum" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "cksum ~ (uutils) display CRC and size of input" diff --git a/src/uu/comm/Cargo.toml b/src/uu/comm/Cargo.toml index e4a1dac82..07430f9d9 100644 --- a/src/uu/comm/Cargo.toml +++ b/src/uu/comm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_comm" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "comm ~ (uutils) compare sorted inputs" diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index 177525ff5..49ba75ca0 100644 --- a/src/uu/cp/Cargo.toml +++ b/src/uu/cp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cp" -version = "0.0.21" +version = "0.0.22" authors = [ "Jordy Dickinson ", "Joshua S. Miller ", diff --git a/src/uu/csplit/Cargo.toml b/src/uu/csplit/Cargo.toml index ba051ff8a..a30ebc4f6 100644 --- a/src/uu/csplit/Cargo.toml +++ b/src/uu/csplit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_csplit" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "csplit ~ (uutils) Output pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output" diff --git a/src/uu/cut/Cargo.toml b/src/uu/cut/Cargo.toml index a55ce7d58..695777a72 100644 --- a/src/uu/cut/Cargo.toml +++ b/src/uu/cut/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_cut" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "cut ~ (uutils) display byte/field columns of input lines" diff --git a/src/uu/date/Cargo.toml b/src/uu/date/Cargo.toml index 7590b0b74..cd860ce58 100644 --- a/src/uu/date/Cargo.toml +++ b/src/uu/date/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore datetime [package] name = "uu_date" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "date ~ (uutils) display or set the current time" diff --git a/src/uu/dd/Cargo.toml b/src/uu/dd/Cargo.toml index 482128e1d..f56e46eaa 100644 --- a/src/uu/dd/Cargo.toml +++ b/src/uu/dd/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dd" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "dd ~ (uutils) copy and convert files" diff --git a/src/uu/df/Cargo.toml b/src/uu/df/Cargo.toml index b547a35d5..2aae7bd55 100644 --- a/src/uu/df/Cargo.toml +++ b/src/uu/df/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_df" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "df ~ (uutils) display file system information" diff --git a/src/uu/dir/Cargo.toml b/src/uu/dir/Cargo.toml index 2a709a804..0bca7bb9d 100644 --- a/src/uu/dir/Cargo.toml +++ b/src/uu/dir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dir" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "shortcut to ls -C -b" diff --git a/src/uu/dircolors/Cargo.toml b/src/uu/dircolors/Cargo.toml index 9248f5ea1..a4a101326 100644 --- a/src/uu/dircolors/Cargo.toml +++ b/src/uu/dircolors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dircolors" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "dircolors ~ (uutils) display commands to set LS_COLORS" diff --git a/src/uu/dirname/Cargo.toml b/src/uu/dirname/Cargo.toml index 6de444499..67806986c 100644 --- a/src/uu/dirname/Cargo.toml +++ b/src/uu/dirname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_dirname" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "dirname ~ (uutils) display parent directory of PATHNAME" diff --git a/src/uu/du/Cargo.toml b/src/uu/du/Cargo.toml index c87595db6..158fa9786 100644 --- a/src/uu/du/Cargo.toml +++ b/src/uu/du/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_du" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "du ~ (uutils) display disk usage" diff --git a/src/uu/echo/Cargo.toml b/src/uu/echo/Cargo.toml index 5d27bae1b..92d5d4924 100644 --- a/src/uu/echo/Cargo.toml +++ b/src/uu/echo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_echo" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "echo ~ (uutils) display TEXT" diff --git a/src/uu/env/Cargo.toml b/src/uu/env/Cargo.toml index b2854edbf..78b133733 100644 --- a/src/uu/env/Cargo.toml +++ b/src/uu/env/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_env" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "env ~ (uutils) set each NAME to VALUE in the environment and run COMMAND" diff --git a/src/uu/expand/Cargo.toml b/src/uu/expand/Cargo.toml index 58647d8e9..c329e61b6 100644 --- a/src/uu/expand/Cargo.toml +++ b/src/uu/expand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_expand" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "expand ~ (uutils) convert input tabs to spaces" diff --git a/src/uu/expr/Cargo.toml b/src/uu/expr/Cargo.toml index ae31c6690..3f0b5ca76 100644 --- a/src/uu/expr/Cargo.toml +++ b/src/uu/expr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_expr" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "expr ~ (uutils) display the value of EXPRESSION" diff --git a/src/uu/factor/Cargo.toml b/src/uu/factor/Cargo.toml index 57b5e9d54..8ecee86c5 100644 --- a/src/uu/factor/Cargo.toml +++ b/src/uu/factor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_factor" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "factor ~ (uutils) display the prime factors of each NUMBER" diff --git a/src/uu/false/Cargo.toml b/src/uu/false/Cargo.toml index 80f3553c0..3b1ca97f9 100644 --- a/src/uu/false/Cargo.toml +++ b/src/uu/false/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_false" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "false ~ (uutils) do nothing and fail" diff --git a/src/uu/fmt/Cargo.toml b/src/uu/fmt/Cargo.toml index 5b181937b..c49f52741 100644 --- a/src/uu/fmt/Cargo.toml +++ b/src/uu/fmt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_fmt" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "fmt ~ (uutils) reformat each paragraph of input" diff --git a/src/uu/fold/Cargo.toml b/src/uu/fold/Cargo.toml index ff2f2f6d5..af36f0466 100644 --- a/src/uu/fold/Cargo.toml +++ b/src/uu/fold/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_fold" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "fold ~ (uutils) wrap each line of input" diff --git a/src/uu/groups/Cargo.toml b/src/uu/groups/Cargo.toml index d503d3e83..5f786acfd 100644 --- a/src/uu/groups/Cargo.toml +++ b/src/uu/groups/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_groups" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "groups ~ (uutils) display group memberships for USERNAME" diff --git a/src/uu/hashsum/Cargo.toml b/src/uu/hashsum/Cargo.toml index 1b075fb48..23b60a701 100644 --- a/src/uu/hashsum/Cargo.toml +++ b/src/uu/hashsum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hashsum" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "hashsum ~ (uutils) display or check input digests" diff --git a/src/uu/head/Cargo.toml b/src/uu/head/Cargo.toml index bdbe45dc1..7c73f3941 100644 --- a/src/uu/head/Cargo.toml +++ b/src/uu/head/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_head" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "head ~ (uutils) display the first lines of input" diff --git a/src/uu/hostid/Cargo.toml b/src/uu/hostid/Cargo.toml index f34fee820..2e6dcc339 100644 --- a/src/uu/hostid/Cargo.toml +++ b/src/uu/hostid/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hostid" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "hostid ~ (uutils) display the numeric identifier of the current host" diff --git a/src/uu/hostname/Cargo.toml b/src/uu/hostname/Cargo.toml index 8e36e672a..49cb14bf2 100644 --- a/src/uu/hostname/Cargo.toml +++ b/src/uu/hostname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_hostname" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "hostname ~ (uutils) display or set the host name of the current host" diff --git a/src/uu/id/Cargo.toml b/src/uu/id/Cargo.toml index 77cda20be..bf1eaf44c 100644 --- a/src/uu/id/Cargo.toml +++ b/src/uu/id/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_id" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "id ~ (uutils) display user and group information for USER" diff --git a/src/uu/install/Cargo.toml b/src/uu/install/Cargo.toml index e66cbeb72..b5353eace 100644 --- a/src/uu/install/Cargo.toml +++ b/src/uu/install/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_install" -version = "0.0.21" +version = "0.0.22" authors = ["Ben Eills ", "uutils developers"] license = "MIT" description = "install ~ (uutils) copy files from SOURCE to DESTINATION (with specified attributes)" diff --git a/src/uu/join/Cargo.toml b/src/uu/join/Cargo.toml index 971f8e455..c52f66de4 100644 --- a/src/uu/join/Cargo.toml +++ b/src/uu/join/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_join" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "join ~ (uutils) merge lines from inputs with matching join fields" diff --git a/src/uu/kill/Cargo.toml b/src/uu/kill/Cargo.toml index a675f00ed..a606c81e7 100644 --- a/src/uu/kill/Cargo.toml +++ b/src/uu/kill/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_kill" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "kill ~ (uutils) send a signal to a process" diff --git a/src/uu/link/Cargo.toml b/src/uu/link/Cargo.toml index 2406476ca..c79ca6041 100644 --- a/src/uu/link/Cargo.toml +++ b/src/uu/link/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_link" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "link ~ (uutils) create a hard (file system) link to FILE" diff --git a/src/uu/ln/Cargo.toml b/src/uu/ln/Cargo.toml index 6488963cc..e9f0e6eb7 100644 --- a/src/uu/ln/Cargo.toml +++ b/src/uu/ln/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ln" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "ln ~ (uutils) create a (file system) link to TARGET" diff --git a/src/uu/logname/Cargo.toml b/src/uu/logname/Cargo.toml index 29116455b..41cbcf73b 100644 --- a/src/uu/logname/Cargo.toml +++ b/src/uu/logname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_logname" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "logname ~ (uutils) display the login name of the current user" diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index 4394865ca..64d1cf136 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ls" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "ls ~ (uutils) display directory contents" diff --git a/src/uu/mkdir/Cargo.toml b/src/uu/mkdir/Cargo.toml index c1a6ce2a8..c0d60dc9d 100644 --- a/src/uu/mkdir/Cargo.toml +++ b/src/uu/mkdir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mkdir" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "mkdir ~ (uutils) create DIRECTORY" diff --git a/src/uu/mkfifo/Cargo.toml b/src/uu/mkfifo/Cargo.toml index 0c28f52de..285fc2b34 100644 --- a/src/uu/mkfifo/Cargo.toml +++ b/src/uu/mkfifo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mkfifo" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "mkfifo ~ (uutils) create FIFOs (named pipes)" diff --git a/src/uu/mknod/Cargo.toml b/src/uu/mknod/Cargo.toml index a230bec74..2e6601714 100644 --- a/src/uu/mknod/Cargo.toml +++ b/src/uu/mknod/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mknod" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "mknod ~ (uutils) create special file NAME of TYPE" diff --git a/src/uu/mktemp/Cargo.toml b/src/uu/mktemp/Cargo.toml index 5dbc8492a..8d8a885b1 100644 --- a/src/uu/mktemp/Cargo.toml +++ b/src/uu/mktemp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mktemp" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "mktemp ~ (uutils) create and display a temporary file or directory from TEMPLATE" diff --git a/src/uu/more/Cargo.toml b/src/uu/more/Cargo.toml index bc0f25217..5614a0495 100644 --- a/src/uu/more/Cargo.toml +++ b/src/uu/more/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_more" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "more ~ (uutils) input perusal filter" diff --git a/src/uu/mv/Cargo.toml b/src/uu/mv/Cargo.toml index b7fcf2d10..0be31ad72 100644 --- a/src/uu/mv/Cargo.toml +++ b/src/uu/mv/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_mv" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "mv ~ (uutils) move (rename) SOURCE to DESTINATION" diff --git a/src/uu/nice/Cargo.toml b/src/uu/nice/Cargo.toml index 65e1520d1..465b7b765 100644 --- a/src/uu/nice/Cargo.toml +++ b/src/uu/nice/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nice" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "nice ~ (uutils) run PROGRAM with modified scheduling priority" diff --git a/src/uu/nl/Cargo.toml b/src/uu/nl/Cargo.toml index db2bfacbd..003e17913 100644 --- a/src/uu/nl/Cargo.toml +++ b/src/uu/nl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nl" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "nl ~ (uutils) display input with added line numbers" diff --git a/src/uu/nohup/Cargo.toml b/src/uu/nohup/Cargo.toml index 9fbf125bf..41c98982a 100644 --- a/src/uu/nohup/Cargo.toml +++ b/src/uu/nohup/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nohup" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "nohup ~ (uutils) run COMMAND, ignoring hangup signals" diff --git a/src/uu/nproc/Cargo.toml b/src/uu/nproc/Cargo.toml index b6052de2e..0acc0e951 100644 --- a/src/uu/nproc/Cargo.toml +++ b/src/uu/nproc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_nproc" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "nproc ~ (uutils) display the number of processing units available" diff --git a/src/uu/numfmt/Cargo.toml b/src/uu/numfmt/Cargo.toml index 8fbf886a2..cf2f08646 100644 --- a/src/uu/numfmt/Cargo.toml +++ b/src/uu/numfmt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_numfmt" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "numfmt ~ (uutils) reformat NUMBER" diff --git a/src/uu/od/Cargo.toml b/src/uu/od/Cargo.toml index d369456f3..b7799e052 100644 --- a/src/uu/od/Cargo.toml +++ b/src/uu/od/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_od" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "od ~ (uutils) display formatted representation of input" diff --git a/src/uu/paste/Cargo.toml b/src/uu/paste/Cargo.toml index d93d4cbb6..dd030478c 100644 --- a/src/uu/paste/Cargo.toml +++ b/src/uu/paste/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_paste" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "paste ~ (uutils) merge lines from inputs" diff --git a/src/uu/pathchk/Cargo.toml b/src/uu/pathchk/Cargo.toml index f62c027c4..708ae2afb 100644 --- a/src/uu/pathchk/Cargo.toml +++ b/src/uu/pathchk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pathchk" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "pathchk ~ (uutils) diagnose invalid or non-portable PATHNAME" diff --git a/src/uu/pinky/Cargo.toml b/src/uu/pinky/Cargo.toml index f6d291e26..c4739e7fc 100644 --- a/src/uu/pinky/Cargo.toml +++ b/src/uu/pinky/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pinky" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "pinky ~ (uutils) display user information" diff --git a/src/uu/pr/Cargo.toml b/src/uu/pr/Cargo.toml index 4453d1cba..9a12e10f5 100644 --- a/src/uu/pr/Cargo.toml +++ b/src/uu/pr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pr" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "pr ~ (uutils) convert text files for printing" diff --git a/src/uu/printenv/Cargo.toml b/src/uu/printenv/Cargo.toml index 729658110..64435127f 100644 --- a/src/uu/printenv/Cargo.toml +++ b/src/uu/printenv/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_printenv" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "printenv ~ (uutils) display value of environment VAR" diff --git a/src/uu/printf/Cargo.toml b/src/uu/printf/Cargo.toml index d55d3732a..a4fd773da 100644 --- a/src/uu/printf/Cargo.toml +++ b/src/uu/printf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_printf" -version = "0.0.21" +version = "0.0.22" authors = ["Nathan Ross", "uutils developers"] license = "MIT" description = "printf ~ (uutils) FORMAT and display ARGUMENTS" diff --git a/src/uu/ptx/Cargo.toml b/src/uu/ptx/Cargo.toml index 96d635caf..ea241600b 100644 --- a/src/uu/ptx/Cargo.toml +++ b/src/uu/ptx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_ptx" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "ptx ~ (uutils) display a permuted index of input" diff --git a/src/uu/pwd/Cargo.toml b/src/uu/pwd/Cargo.toml index 1567a935f..5f15245b5 100644 --- a/src/uu/pwd/Cargo.toml +++ b/src/uu/pwd/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_pwd" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "pwd ~ (uutils) display current working directory" diff --git a/src/uu/readlink/Cargo.toml b/src/uu/readlink/Cargo.toml index 309d40794..a696abdfa 100644 --- a/src/uu/readlink/Cargo.toml +++ b/src/uu/readlink/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_readlink" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "readlink ~ (uutils) display resolved path of PATHNAME" diff --git a/src/uu/realpath/Cargo.toml b/src/uu/realpath/Cargo.toml index e458bf89d..6d2072753 100644 --- a/src/uu/realpath/Cargo.toml +++ b/src/uu/realpath/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_realpath" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "realpath ~ (uutils) display resolved absolute path of PATHNAME" diff --git a/src/uu/rm/Cargo.toml b/src/uu/rm/Cargo.toml index 87fccbfa8..a1b3999d4 100644 --- a/src/uu/rm/Cargo.toml +++ b/src/uu/rm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_rm" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "rm ~ (uutils) remove PATHNAME" diff --git a/src/uu/rmdir/Cargo.toml b/src/uu/rmdir/Cargo.toml index 41d2f7432..8288309f2 100644 --- a/src/uu/rmdir/Cargo.toml +++ b/src/uu/rmdir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_rmdir" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "rmdir ~ (uutils) remove empty DIRECTORY" diff --git a/src/uu/runcon/Cargo.toml b/src/uu/runcon/Cargo.toml index ac4ec54d5..04d3aae71 100644 --- a/src/uu/runcon/Cargo.toml +++ b/src/uu/runcon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_runcon" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "runcon ~ (uutils) run command with specified security context" diff --git a/src/uu/seq/Cargo.toml b/src/uu/seq/Cargo.toml index f25d995a2..b8a5c084c 100644 --- a/src/uu/seq/Cargo.toml +++ b/src/uu/seq/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore bigdecimal [package] name = "uu_seq" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "seq ~ (uutils) display a sequence of numbers" diff --git a/src/uu/shred/Cargo.toml b/src/uu/shred/Cargo.toml index 70045eaf0..0e7ad2ad3 100644 --- a/src/uu/shred/Cargo.toml +++ b/src/uu/shred/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_shred" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "shred ~ (uutils) hide former FILE contents with repeated overwrites" diff --git a/src/uu/shuf/Cargo.toml b/src/uu/shuf/Cargo.toml index 2f0466b86..6a86c6d98 100644 --- a/src/uu/shuf/Cargo.toml +++ b/src/uu/shuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_shuf" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "shuf ~ (uutils) display random permutations of input lines" diff --git a/src/uu/sleep/Cargo.toml b/src/uu/sleep/Cargo.toml index 454f2297e..6ca686c78 100644 --- a/src/uu/sleep/Cargo.toml +++ b/src/uu/sleep/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sleep" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "sleep ~ (uutils) pause for DURATION" diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index 981e71641..0cbafc5cf 100644 --- a/src/uu/sort/Cargo.toml +++ b/src/uu/sort/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sort" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "sort ~ (uutils) sort input lines" diff --git a/src/uu/split/Cargo.toml b/src/uu/split/Cargo.toml index fb53914e2..c5a348473 100644 --- a/src/uu/split/Cargo.toml +++ b/src/uu/split/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_split" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "split ~ (uutils) split input into output files" diff --git a/src/uu/stat/Cargo.toml b/src/uu/stat/Cargo.toml index f258aca11..2974562f3 100644 --- a/src/uu/stat/Cargo.toml +++ b/src/uu/stat/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stat" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "stat ~ (uutils) display FILE status" diff --git a/src/uu/stdbuf/Cargo.toml b/src/uu/stdbuf/Cargo.toml index f61014907..8168733af 100644 --- a/src/uu/stdbuf/Cargo.toml +++ b/src/uu/stdbuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stdbuf" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "stdbuf ~ (uutils) run COMMAND with modified standard stream buffering" @@ -20,7 +20,7 @@ tempfile = { workspace = true } uucore = { workspace = true } [build-dependencies] -libstdbuf = { version = "0.0.21", package = "uu_stdbuf_libstdbuf", path = "src/libstdbuf" } +libstdbuf = { version = "0.0.22", package = "uu_stdbuf_libstdbuf", path = "src/libstdbuf" } [[bin]] name = "stdbuf" diff --git a/src/uu/stdbuf/src/libstdbuf/Cargo.toml b/src/uu/stdbuf/src/libstdbuf/Cargo.toml index 8061c61a6..5fdfa27e0 100644 --- a/src/uu/stdbuf/src/libstdbuf/Cargo.toml +++ b/src/uu/stdbuf/src/libstdbuf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stdbuf_libstdbuf" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "stdbuf/libstdbuf ~ (uutils); dynamic library required for stdbuf" diff --git a/src/uu/stty/Cargo.toml b/src/uu/stty/Cargo.toml index eb86ae681..965de5cd8 100644 --- a/src/uu/stty/Cargo.toml +++ b/src/uu/stty/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_stty" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "stty ~ (uutils) print or change terminal characteristics" diff --git a/src/uu/sum/Cargo.toml b/src/uu/sum/Cargo.toml index aa722c694..58fa7a08d 100644 --- a/src/uu/sum/Cargo.toml +++ b/src/uu/sum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sum" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "sum ~ (uutils) display checksum and block counts for input" diff --git a/src/uu/sync/Cargo.toml b/src/uu/sync/Cargo.toml index b74e076e5..2367561f8 100644 --- a/src/uu/sync/Cargo.toml +++ b/src/uu/sync/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_sync" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "sync ~ (uutils) synchronize cache writes to storage" diff --git a/src/uu/tac/Cargo.toml b/src/uu/tac/Cargo.toml index 385ef37c8..1716a6d03 100644 --- a/src/uu/tac/Cargo.toml +++ b/src/uu/tac/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "uu_tac" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "tac ~ (uutils) concatenate and display input lines in reverse order" diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index 5ff532e60..66775c8d9 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore (libs) kqueue fundu [package] name = "uu_tail" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "tail ~ (uutils) display the last lines of input" diff --git a/src/uu/tee/Cargo.toml b/src/uu/tee/Cargo.toml index 597299fc7..787c0cb32 100644 --- a/src/uu/tee/Cargo.toml +++ b/src/uu/tee/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tee" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "tee ~ (uutils) display input and copy to FILE" diff --git a/src/uu/test/Cargo.toml b/src/uu/test/Cargo.toml index fc70677a6..696fa3662 100644 --- a/src/uu/test/Cargo.toml +++ b/src/uu/test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_test" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "test ~ (uutils) evaluate comparison and file type expressions" diff --git a/src/uu/timeout/Cargo.toml b/src/uu/timeout/Cargo.toml index 949ac9da5..b6cb700a4 100644 --- a/src/uu/timeout/Cargo.toml +++ b/src/uu/timeout/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_timeout" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "timeout ~ (uutils) run COMMAND with a DURATION time limit" diff --git a/src/uu/touch/Cargo.toml b/src/uu/touch/Cargo.toml index 54682e1dd..b44e8cf69 100644 --- a/src/uu/touch/Cargo.toml +++ b/src/uu/touch/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore datetime [package] name = "uu_touch" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "touch ~ (uutils) change FILE timestamps" diff --git a/src/uu/tr/Cargo.toml b/src/uu/tr/Cargo.toml index 065fdab52..c7e7bd606 100644 --- a/src/uu/tr/Cargo.toml +++ b/src/uu/tr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tr" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "tr ~ (uutils) translate characters within input and display" diff --git a/src/uu/true/Cargo.toml b/src/uu/true/Cargo.toml index 432dfa54e..ec6c5d2f9 100644 --- a/src/uu/true/Cargo.toml +++ b/src/uu/true/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_true" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "true ~ (uutils) do nothing and succeed" diff --git a/src/uu/truncate/Cargo.toml b/src/uu/truncate/Cargo.toml index fbabe1fcd..a9cc179a6 100644 --- a/src/uu/truncate/Cargo.toml +++ b/src/uu/truncate/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_truncate" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "truncate ~ (uutils) truncate (or extend) FILE to SIZE" diff --git a/src/uu/tsort/Cargo.toml b/src/uu/tsort/Cargo.toml index 2f276f98e..f72aeeda0 100644 --- a/src/uu/tsort/Cargo.toml +++ b/src/uu/tsort/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tsort" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "tsort ~ (uutils) topologically sort input (partially ordered) pairs" diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index 917d04c10..66d4b42c7 100644 --- a/src/uu/tty/Cargo.toml +++ b/src/uu/tty/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_tty" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "tty ~ (uutils) display the name of the terminal connected to standard input" diff --git a/src/uu/uname/Cargo.toml b/src/uu/uname/Cargo.toml index ccb3651ec..10363b63c 100644 --- a/src/uu/uname/Cargo.toml +++ b/src/uu/uname/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uname" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "uname ~ (uutils) display system information" diff --git a/src/uu/unexpand/Cargo.toml b/src/uu/unexpand/Cargo.toml index 6a12d48ab..bab5b4e91 100644 --- a/src/uu/unexpand/Cargo.toml +++ b/src/uu/unexpand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_unexpand" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "unexpand ~ (uutils) convert input spaces to tabs" diff --git a/src/uu/uniq/Cargo.toml b/src/uu/uniq/Cargo.toml index 0afcffc11..2fb0552ce 100644 --- a/src/uu/uniq/Cargo.toml +++ b/src/uu/uniq/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uniq" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "uniq ~ (uutils) filter identical adjacent lines from input" diff --git a/src/uu/unlink/Cargo.toml b/src/uu/unlink/Cargo.toml index ce86b81d8..aae56bf0b 100644 --- a/src/uu/unlink/Cargo.toml +++ b/src/uu/unlink/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_unlink" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "unlink ~ (uutils) remove a (file system) link to FILE" diff --git a/src/uu/uptime/Cargo.toml b/src/uu/uptime/Cargo.toml index 7bef7cc05..f5fa083f9 100644 --- a/src/uu/uptime/Cargo.toml +++ b/src/uu/uptime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_uptime" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "uptime ~ (uutils) display dynamic system information" diff --git a/src/uu/users/Cargo.toml b/src/uu/users/Cargo.toml index 4701c694f..d894ff4ba 100644 --- a/src/uu/users/Cargo.toml +++ b/src/uu/users/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_users" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "users ~ (uutils) display names of currently logged-in users" diff --git a/src/uu/vdir/Cargo.toml b/src/uu/vdir/Cargo.toml index 99bcf383b..b63f8c9ea 100644 --- a/src/uu/vdir/Cargo.toml +++ b/src/uu/vdir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_vdir" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "shortcut to ls -l -b" diff --git a/src/uu/wc/Cargo.toml b/src/uu/wc/Cargo.toml index 5712fbd83..6a233c1ad 100644 --- a/src/uu/wc/Cargo.toml +++ b/src/uu/wc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_wc" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "wc ~ (uutils) display newline, word, and byte counts for input" diff --git a/src/uu/who/Cargo.toml b/src/uu/who/Cargo.toml index b8b90b2ef..fdfc05897 100644 --- a/src/uu/who/Cargo.toml +++ b/src/uu/who/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_who" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "who ~ (uutils) display information about currently logged-in users" diff --git a/src/uu/whoami/Cargo.toml b/src/uu/whoami/Cargo.toml index 331755a96..59d011209 100644 --- a/src/uu/whoami/Cargo.toml +++ b/src/uu/whoami/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_whoami" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "whoami ~ (uutils) display user name of current effective user ID" diff --git a/src/uu/yes/Cargo.toml b/src/uu/yes/Cargo.toml index eff091551..c36c2b189 100644 --- a/src/uu/yes/Cargo.toml +++ b/src/uu/yes/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu_yes" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "yes ~ (uutils) repeatedly display a line with STRING (or 'y')" diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 5e555da4d..8ce252dc5 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "uucore" -version = "0.0.21" +version = "0.0.22" authors = ["uutils developers"] license = "MIT" description = "uutils ~ 'core' uutils code library (cross-platform)" diff --git a/src/uucore_procs/Cargo.toml b/src/uucore_procs/Cargo.toml index 1ad4023f9..55d880961 100644 --- a/src/uucore_procs/Cargo.toml +++ b/src/uucore_procs/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore uuhelp [package] name = "uucore_procs" -version = "0.0.21" +version = "0.0.22" authors = ["Roy Ivy III "] license = "MIT" description = "uutils ~ 'uucore' proc-macros" @@ -19,4 +19,4 @@ proc-macro = true [dependencies] proc-macro2 = "1.0" quote = "1.0" -uuhelp_parser = { path = "../uuhelp_parser", version = "0.0.21" } +uuhelp_parser = { path = "../uuhelp_parser", version = "0.0.22" } diff --git a/src/uuhelp_parser/Cargo.toml b/src/uuhelp_parser/Cargo.toml index fdff271b0..007f1ebb2 100644 --- a/src/uuhelp_parser/Cargo.toml +++ b/src/uuhelp_parser/Cargo.toml @@ -1,7 +1,7 @@ # spell-checker:ignore uuhelp [package] name = "uuhelp_parser" -version = "0.0.21" +version = "0.0.22" edition = "2021" license = "MIT" description = "A collection of functions to parse the markdown code of help files" diff --git a/util/update-version.sh b/util/update-version.sh index 6738f19b6..59bdb4d75 100755 --- a/util/update-version.sh +++ b/util/update-version.sh @@ -14,8 +14,8 @@ # 7) Run util/publish.sh --do-it # 8) In some cases, you might have to fix dependencies and run import -FROM="0.0.20" -TO="0.0.21" +FROM="0.0.21" +TO="0.0.22" PROGS=$(ls -1d src/uu/*/Cargo.toml src/uu/stdbuf/src/libstdbuf/Cargo.toml src/uucore/Cargo.toml Cargo.toml) From fcd0817b3b4a2fd6e831c23aef400c7c018f84a3 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 15 Oct 2023 14:24:05 +0200 Subject: [PATCH 321/370] update of the release doc --- util/update-version.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/update-version.sh b/util/update-version.sh index 6738f19b6..86e7f329b 100755 --- a/util/update-version.sh +++ b/util/update-version.sh @@ -9,10 +9,13 @@ # 2) run it: sh util/update-version.sh # 3) Do a spot check with "git diff" # 4) cargo test --release --features unix -# 5) git commit -m "New release" +# 5) git commit -m "New release" (make sure it includes Cargo.lock) # 6) Run util/publish.sh in dry mode (it will fail as packages needs more recent version of uucore) # 7) Run util/publish.sh --do-it # 8) In some cases, you might have to fix dependencies and run import +# 9) Tag the release - "git tag 0.0.X && git push --tags" +# 10) Create the release on github https://github.com/uutils/coreutils/releases/new +# 11) Make sure we have good release notes FROM="0.0.20" TO="0.0.21" From c892c9346f945a8572a6b24bd7cb80625ec8a23f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 17:59:54 +0000 Subject: [PATCH 322/370] fix(deps): update rust crate dns-lookup to 2.0.4 --- Cargo.lock | 4 ++-- src/uucore/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a54656d7c..4481d08d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -743,9 +743,9 @@ dependencies = [ [[package]] name = "dns-lookup" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d0fa3cd8dc96ada974e126a940d37d4079bbbe6a24aca15b1113c2f362441c5" +checksum = "e5766087c2235fec47fafa4cfecc81e494ee679d0fd4a59887ea0919bfb0e4fc" dependencies = [ "cfg-if", "libc", diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 8ce252dc5..fb0b20338 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -20,7 +20,7 @@ path = "src/lib/lib.rs" [dependencies] clap = { workspace = true } uucore_procs = { workspace = true } -dns-lookup = { version = "2.0.3", optional = true } +dns-lookup = { version = "2.0.4", optional = true } dunce = { version = "1.0.4", optional = true } wild = "2.2" glob = { workspace = true } From 3a780453a9cc23b928baeaac3dc9588f067a6d5a Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 6 Oct 2023 21:25:24 +0200 Subject: [PATCH 323/370] join: remove a clippy::cognitive_complexity by moving some content into functions --- src/uu/join/src/join.rs | 102 +++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 37 deletions(-) diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index 71720f2cc..7f6d1038f 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -591,20 +591,38 @@ impl<'a> State<'a> { } } -#[uucore::main] -#[allow(clippy::cognitive_complexity)] -pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let matches = uu_app().try_get_matches_from(args)?; +fn parse_separator(value_os: &OsString) -> UResult { + #[cfg(unix)] + let value = value_os.as_bytes(); + #[cfg(not(unix))] + let value = match value_os.to_str() { + Some(value) => value.as_bytes(), + None => { + return Err(USimpleError::new( + 1, + "unprintable field separators are only supported on unix-like platforms", + )); + } + }; + match value.len() { + 0 => Ok(Sep::Line), + 1 => Ok(Sep::Char(value[0])), + 2 if value[0] == b'\\' && value[1] == b'0' => Ok(Sep::Char(0)), + _ => Err(USimpleError::new( + 1, + format!("multi-character tab {}", value_os.to_string_lossy()), + )), + } +} - let keys = parse_field_number_option(matches.get_one::("j").map(|s| s.as_str()))?; - let key1 = parse_field_number_option(matches.get_one::("1").map(|s| s.as_str()))?; - let key2 = parse_field_number_option(matches.get_one::("2").map(|s| s.as_str()))?; - - let mut settings = Settings::default(); +fn parse_print_settings(matches: &clap::ArgMatches) -> UResult<(bool, bool, bool)> { + let mut print_joined = true; + let mut print_unpaired1 = false; + let mut print_unpaired2 = false; let v_values = matches.get_many::("v"); if v_values.is_some() { - settings.print_joined = false; + print_joined = false; } let unpaired = v_values @@ -612,41 +630,42 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .chain(matches.get_many("a").unwrap_or_default()); for file_num in unpaired { match parse_file_number(file_num)? { - FileNum::File1 => settings.print_unpaired1 = true, - FileNum::File2 => settings.print_unpaired2 = true, + FileNum::File1 => print_unpaired1 = true, + FileNum::File2 => print_unpaired2 = true, } } + Ok((print_joined, print_unpaired1, print_unpaired2)) +} + +fn get_and_parse_field_number(matches: &clap::ArgMatches, key: &str) -> UResult> { + let value = matches.get_one::(key).map(|s| s.as_str()); + parse_field_number_option(value) +} + +/// Parses the command-line arguments and constructs a `Settings` struct. +/// +/// This function takes the matches from the command-line arguments, processes them, +/// and returns a `Settings` struct that encapsulates the configuration for the program. +fn parse_settings(matches: &clap::ArgMatches) -> UResult { + let keys = get_and_parse_field_number(matches, "j")?; + let key1 = get_and_parse_field_number(matches, "1")?; + let key2 = get_and_parse_field_number(matches, "2")?; + + let (print_joined, print_unpaired1, print_unpaired2) = parse_print_settings(matches)?; + + let mut settings = Settings::default(); + + settings.print_joined = print_joined; + settings.print_unpaired1 = print_unpaired1; + settings.print_unpaired2 = print_unpaired2; + settings.ignore_case = matches.get_flag("i"); settings.key1 = get_field_number(keys, key1)?; settings.key2 = get_field_number(keys, key2)?; - if let Some(value_os) = matches.get_one::("t") { - #[cfg(unix)] - let value = value_os.as_bytes(); - #[cfg(not(unix))] - let value = match value_os.to_str() { - Some(value) => value.as_bytes(), - None => { - return Err(USimpleError::new( - 1, - "unprintable field separators are only supported on unix-like platforms", - )) - } - }; - settings.separator = match value.len() { - 0 => Sep::Line, - 1 => Sep::Char(value[0]), - 2 if value[0] == b'\\' && value[1] == b'0' => Sep::Char(0), - _ => { - return Err(USimpleError::new( - 1, - format!("multi-character tab {}", value_os.to_string_lossy()), - )) - } - }; + settings.separator = parse_separator(value_os)?; } - if let Some(format) = matches.get_one::("o") { if format == "auto" { settings.autoformat = true; @@ -677,6 +696,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { settings.line_ending = LineEnding::from_zero_flag(matches.get_flag("z")); + Ok(settings) +} + +#[uucore::main] +pub fn uumain(args: impl uucore::Args) -> UResult<()> { + let matches = uu_app().try_get_matches_from(args)?; + + let settings = parse_settings(&matches)?; + let file1 = matches.get_one::("file1").unwrap(); let file2 = matches.get_one::("file2").unwrap(); From 21aca7abd750b283eebe8928d35e407402f86fad Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 16 Oct 2023 09:48:20 +0200 Subject: [PATCH 324/370] doc: add a missing "a" --- DEVELOPMENT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 9cb81a88c..67b201e9c 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -6,7 +6,7 @@ For contributing rules and best practices please refer to [CONTRIBUTING.md](CONT ## Before you start -For this guide we assume that you already have GitHub account and have `git` and your favorite code editor or IDE installed and configured. +For this guide we assume that you already have a GitHub account and have `git` and your favorite code editor or IDE installed and configured. Before you start working on coreutils, please follow these steps: 1. Fork the [coreutils repository](https://github.com/uutils/coreutils) to your GitHub account. From f8436728dc1a5df064c21bba8cbe422bd74d2e06 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 16 Oct 2023 10:47:38 +0200 Subject: [PATCH 325/370] add field_reassign_with_default ignore Co-authored-by: Daniel Hofstetter --- src/uu/join/src/join.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index 7f6d1038f..a48ba3657 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -647,6 +647,7 @@ fn get_and_parse_field_number(matches: &clap::ArgMatches, key: &str) -> UResult< /// /// This function takes the matches from the command-line arguments, processes them, /// and returns a `Settings` struct that encapsulates the configuration for the program. +#[allow(clippy::field_reassign_with_default)] fn parse_settings(matches: &clap::ArgMatches) -> UResult { let keys = get_and_parse_field_number(matches, "j")?; let key1 = get_and_parse_field_number(matches, "1")?; From 3288c64b00703ac39accb4abec94a7bf45ef978d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 16:33:17 +0000 Subject: [PATCH 326/370] chore(deps): update rust crate regex to 1.10.2 --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4481d08d3..dfa22ad27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1728,9 +1728,9 @@ checksum = "f1bfbf25d7eb88ddcbb1ec3d755d0634da8f7657b2cb8b74089121409ab8228f" [[package]] name = "regex" -version = "1.10.1" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaac441002f822bc9705a681810a4dd2963094b9ca0ddc41cb963a4c189189ea" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", @@ -1740,9 +1740,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5011c7e263a695dc8ca064cddb722af1be54e517a280b12a5356f98366899e5d" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 39232b50d..6b412488c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -309,7 +309,7 @@ rand = { version = "0.8", features = ["small_rng"] } rand_core = "0.6" rayon = "1.8" redox_syscall = "0.4" -regex = "1.10.1" +regex = "1.10.2" rstest = "0.18.2" rust-ini = "0.19.0" same-file = "1.0.6" From 7421c81a22cebd5ea80d2614766c195431b2089e Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Tue, 17 Oct 2023 22:21:44 +0800 Subject: [PATCH 327/370] tests/expr: sort test cases --- tests/by-util/test_expr.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index d4cca43a2..840e1f325 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -152,14 +152,20 @@ fn test_and() { .succeeds() .stdout_only("foo\n"); - new_ucmd!().args(&["", "&", "1"]).run().stdout_is("0\n"); - - new_ucmd!().args(&["14", "&", "1"]).run().stdout_is("14\n"); + new_ucmd!() + .args(&["14", "&", "1"]) + .succeeds() + .stdout_only("14\n"); new_ucmd!() .args(&["-14", "&", "1"]) - .run() - .stdout_is("-14\n"); + .succeeds() + .stdout_only("-14\n"); + + new_ucmd!() + .args(&["-1", "&", "10", "/", "5"]) + .succeeds() + .stdout_only("-1\n"); new_ucmd!() .args(&["0", "&", "a", "/", "5"]) @@ -171,10 +177,7 @@ fn test_and() { .run() .stdout_only("0\n"); - new_ucmd!() - .args(&["-1", "&", "10", "/", "5"]) - .succeeds() - .stdout_only("-1\n"); + new_ucmd!().args(&["", "&", "1"]).run().stdout_only("0\n"); } #[test] From 04ab5b010860e290fa0b23b7a4cca47ce934e996 Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Tue, 17 Oct 2023 22:26:19 +0800 Subject: [PATCH 328/370] tests/expr: add tests for "" --- tests/by-util/test_expr.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index 840e1f325..28cfcf0ec 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -143,6 +143,14 @@ fn test_or() { .args(&["12", "|", "9a", "+", "1"]) .succeeds() .stdout_only("12\n"); + + new_ucmd!().args(&["", "|", ""]).run().stdout_only("0\n"); + + new_ucmd!().args(&["", "|", "0"]).run().stdout_only("0\n"); + + new_ucmd!().args(&["", "|", "00"]).run().stdout_only("0\n"); + + new_ucmd!().args(&["", "|", "-0"]).run().stdout_only("0\n"); } #[test] @@ -178,6 +186,8 @@ fn test_and() { .stdout_only("0\n"); new_ucmd!().args(&["", "&", "1"]).run().stdout_only("0\n"); + + new_ucmd!().args(&["", "&", ""]).run().stdout_only("0\n"); } #[test] From 8a6722491746ff7ec805ea058a30de1236836754 Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Tue, 17 Oct 2023 22:27:10 +0800 Subject: [PATCH 329/370] expr: add assert for `&` --- src/uu/expr/src/syntax_tree.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index e0e786b3a..2cd2af0b1 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -470,6 +470,7 @@ fn infix_operator_or(values: &[String]) -> String { } fn infix_operator_and(values: &[String]) -> String { + assert!(values.len() == 2); if value_as_bool(&values[0]) && value_as_bool(&values[1]) { values[0].clone() } else { From d325a952ee1133eaa76cc3d1196a9364c2a539dc Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Tue, 17 Oct 2023 22:27:47 +0800 Subject: [PATCH 330/370] expr: return "0" for `|` --- src/uu/expr/src/syntax_tree.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index 2cd2af0b1..c55fb0bdc 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -464,8 +464,10 @@ fn infix_operator_or(values: &[String]) -> String { assert!(values.len() == 2); if value_as_bool(&values[0]) { values[0].clone() - } else { + } else if value_as_bool(&values[1]) { values[1].clone() + } else { + 0.to_string() } } From cb7479e823cf14329a93f6d93eed8acff8c5ac7f Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 4 Oct 2023 21:26:29 -0400 Subject: [PATCH 331/370] uucore: implement SI suffixes R and Q --- src/uu/dd/src/parseargs.rs | 2 +- src/uu/df/src/blocks.rs | 6 +- src/uu/du/src/du.rs | 8 +- src/uu/head/src/parse.rs | 4 +- src/uu/ls/src/ls.rs | 4 +- src/uu/od/src/parse_nrofbytes.rs | 4 +- src/uu/shred/src/shred.rs | 4 +- src/uu/split/src/split.rs | 24 +- src/uu/stdbuf/src/stdbuf.rs | 4 +- src/uu/tail/src/args.rs | 4 +- src/uu/truncate/src/truncate.rs | 6 +- src/uucore/src/lib/parser/parse_size.rs | 307 +++++++++++++++--------- tests/by-util/test_head.rs | 8 +- tests/by-util/test_split.rs | 4 +- tests/by-util/test_truncate.rs | 2 +- 15 files changed, 244 insertions(+), 147 deletions(-) diff --git a/src/uu/dd/src/parseargs.rs b/src/uu/dd/src/parseargs.rs index 53fae1b4b..0ff6e752c 100644 --- a/src/uu/dd/src/parseargs.rs +++ b/src/uu/dd/src/parseargs.rs @@ -504,7 +504,7 @@ fn parse_bytes_no_x(full: &str, s: &str) -> Result { ..Default::default() }; let (num, multiplier) = match (s.find('c'), s.rfind('w'), s.rfind('b')) { - (None, None, None) => match parser.parse(s) { + (None, None, None) => match parser.parse_u64(s) { Ok(n) => (n, 1), Err(ParseSizeError::InvalidSuffix(_) | ParseSizeError::ParseFailure(_)) => { return Err(ParseError::InvalidNumber(full.to_string())) diff --git a/src/uu/df/src/blocks.rs b/src/uu/df/src/blocks.rs index fad8f7ac0..d7a689d8c 100644 --- a/src/uu/df/src/blocks.rs +++ b/src/uu/df/src/blocks.rs @@ -9,7 +9,7 @@ use std::{env, fmt}; use uucore::{ display::Quotable, - parse_size::{parse_size, ParseSizeError}, + parse_size::{parse_size_u64, ParseSizeError}, }; /// The first ten powers of 1024. @@ -165,7 +165,7 @@ impl Default for BlockSize { pub(crate) fn read_block_size(matches: &ArgMatches) -> Result { if matches.contains_id(OPT_BLOCKSIZE) { let s = matches.get_one::(OPT_BLOCKSIZE).unwrap(); - let bytes = parse_size(s)?; + let bytes = parse_size_u64(s)?; if bytes > 0 { Ok(BlockSize::Bytes(bytes)) @@ -184,7 +184,7 @@ pub(crate) fn read_block_size(matches: &ArgMatches) -> Result Option { for env_var in ["DF_BLOCK_SIZE", "BLOCK_SIZE", "BLOCKSIZE"] { if let Ok(env_size) = env::var(env_var) { - if let Ok(size) = parse_size(&env_size) { + if let Ok(size) = parse_size_u64(&env_size) { return Some(size); } else { return None; diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 5be2a8a2b..ad5e87833 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -34,7 +34,7 @@ use uucore::error::FromIo; use uucore::error::{set_exit_code, UError, UResult}; use uucore::line_ending::LineEnding; use uucore::parse_glob; -use uucore::parse_size::{parse_size, ParseSizeError}; +use uucore::parse_size::{parse_size_u64, ParseSizeError}; use uucore::{ crash, format_usage, help_about, help_section, help_usage, show, show_error, show_warning, }; @@ -256,12 +256,12 @@ fn get_file_info(path: &Path) -> Option { fn read_block_size(s: Option<&str>) -> u64 { if let Some(s) = s { - parse_size(s) + parse_size_u64(s) .unwrap_or_else(|e| crash!(1, "{}", format_error_message(&e, s, options::BLOCK_SIZE))) } else { for env_var in ["DU_BLOCK_SIZE", "BLOCK_SIZE", "BLOCKSIZE"] { if let Ok(env_size) = env::var(env_var) { - if let Ok(v) = parse_size(&env_size) { + if let Ok(v) = parse_size_u64(&env_size) { return v; } } @@ -946,7 +946,7 @@ impl FromStr for Threshold { fn from_str(s: &str) -> std::result::Result { let offset = usize::from(s.starts_with(&['-', '+'][..])); - let size = parse_size(&s[offset..])?; + let size = parse_size_u64(&s[offset..])?; if s.starts_with('-') { // Threshold of '-0' excludes everything besides 0 sized entries diff --git a/src/uu/head/src/parse.rs b/src/uu/head/src/parse.rs index 062a1844c..dce60bae0 100644 --- a/src/uu/head/src/parse.rs +++ b/src/uu/head/src/parse.rs @@ -4,7 +4,7 @@ // file that was distributed with this source code. use std::ffi::OsString; -use uucore::parse_size::{parse_size, ParseSizeError}; +use uucore::parse_size::{parse_size_u64, ParseSizeError}; #[derive(PartialEq, Eq, Debug)] pub enum ParseError { @@ -129,7 +129,7 @@ pub fn parse_num(src: &str) -> Result<(u64, bool), ParseSizeError> { if trimmed_string.is_empty() { Ok((0, all_but_last)) } else { - parse_size(trimmed_string).map(|n| (n, all_but_last)) + parse_size_u64(trimmed_string).map(|n| (n, all_but_last)) } } diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index dfa637d23..50fbe0c7c 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -57,7 +57,7 @@ use uucore::{ error::{set_exit_code, UError, UResult}, format_usage, fs::display_permissions, - parse_size::parse_size, + parse_size::parse_size_u64, version_cmp::version_cmp, }; use uucore::{help_about, help_section, help_usage, parse_glob, show, show_error, show_warning}; @@ -781,7 +781,7 @@ impl Config { }; let block_size: Option = if !opt_si && !opt_hr && !raw_bs.is_empty() { - match parse_size(&raw_bs.to_string_lossy()) { + match parse_size_u64(&raw_bs.to_string_lossy()) { Ok(size) => Some(size), Err(_) => { show!(LsError::BlockSizeParseError( diff --git a/src/uu/od/src/parse_nrofbytes.rs b/src/uu/od/src/parse_nrofbytes.rs index 431b2a71f..1aa69909f 100644 --- a/src/uu/od/src/parse_nrofbytes.rs +++ b/src/uu/od/src/parse_nrofbytes.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use uucore::parse_size::{parse_size, ParseSizeError}; +use uucore::parse_size::{parse_size_u64, ParseSizeError}; pub fn parse_number_of_bytes(s: &str) -> Result { let mut start = 0; @@ -15,7 +15,7 @@ pub fn parse_number_of_bytes(s: &str) -> Result { } else if s.starts_with('0') { radix = 8; } else { - return parse_size(&s[start..]); + return parse_size_u64(&s[start..]); } let mut ends_with = s.chars().rev(); diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 9b1f7fc98..eb63f0e5f 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -16,7 +16,7 @@ use std::os::unix::prelude::PermissionsExt; use std::path::{Path, PathBuf}; use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; -use uucore::parse_size::parse_size; +use uucore::parse_size::parse_size_u64; use uucore::{format_usage, help_about, help_section, help_usage, show, show_error, show_if_err}; const ABOUT: &str = help_about!("shred.md"); @@ -319,7 +319,7 @@ pub fn uu_app() -> Command { fn get_size(size_str_opt: Option) -> Option { size_str_opt .as_ref() - .and_then(|size| parse_size(size.as_str()).ok()) + .and_then(|size| parse_size_u64(size.as_str()).ok()) .or_else(|| { if let Some(size) = size_str_opt { show_error!("invalid file size: {}", size.quote()); diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 84b5900cc..cff8a4a4c 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -22,7 +22,7 @@ use std::path::Path; use std::u64; use uucore::display::Quotable; use uucore::error::{FromIo, UIoError, UResult, USimpleError, UUsageError}; -use uucore::parse_size::{parse_size, parse_size_max, ParseSizeError}; +use uucore::parse_size::{parse_size_u64, parse_size_u64_max, ParseSizeError}; use uucore::uio_error; use uucore::{format_usage, help_about, help_section, help_usage}; @@ -503,7 +503,7 @@ impl NumberType { let parts: Vec<&str> = s.split('/').collect(); match &parts[..] { [n_str] => { - let num_chunks = parse_size(n_str) + let num_chunks = parse_size_u64(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; if num_chunks > 0 { Ok(Self::Bytes(num_chunks)) @@ -512,9 +512,9 @@ impl NumberType { } } [k_str, n_str] if !k_str.starts_with('l') && !k_str.starts_with('r') => { - let num_chunks = parse_size(n_str) + let num_chunks = parse_size_u64(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; - let chunk_number = parse_size(k_str) + let chunk_number = parse_size_u64(k_str) .map_err(|_| NumberTypeError::ChunkNumber(k_str.to_string()))?; if is_invalid_chunk(chunk_number, num_chunks) { return Err(NumberTypeError::ChunkNumber(k_str.to_string())); @@ -522,14 +522,14 @@ impl NumberType { Ok(Self::KthBytes(chunk_number, num_chunks)) } ["l", n_str] => { - let num_chunks = parse_size(n_str) + let num_chunks = parse_size_u64(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; Ok(Self::Lines(num_chunks)) } ["l", k_str, n_str] => { - let num_chunks = parse_size(n_str) + let num_chunks = parse_size_u64(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; - let chunk_number = parse_size(k_str) + let chunk_number = parse_size_u64(k_str) .map_err(|_| NumberTypeError::ChunkNumber(k_str.to_string()))?; if is_invalid_chunk(chunk_number, num_chunks) { return Err(NumberTypeError::ChunkNumber(k_str.to_string())); @@ -537,14 +537,14 @@ impl NumberType { Ok(Self::KthLines(chunk_number, num_chunks)) } ["r", n_str] => { - let num_chunks = parse_size(n_str) + let num_chunks = parse_size_u64(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; Ok(Self::RoundRobin(num_chunks)) } ["r", k_str, n_str] => { - let num_chunks = parse_size(n_str) + let num_chunks = parse_size_u64(n_str) .map_err(|_| NumberTypeError::NumberOfChunks(n_str.to_string()))?; - let chunk_number = parse_size(k_str) + let chunk_number = parse_size_u64(k_str) .map_err(|_| NumberTypeError::ChunkNumber(k_str.to_string()))?; if is_invalid_chunk(chunk_number, num_chunks) { return Err(NumberTypeError::ChunkNumber(k_str.to_string())); @@ -616,7 +616,7 @@ impl Strategy { error: fn(ParseSizeError) -> StrategyError, ) -> Result { let s = matches.get_one::(option).unwrap(); - let n = parse_size_max(s).map_err(error)?; + let n = parse_size_u64_max(s).map_err(error)?; if n > 0 { Ok(strategy(n)) } else { @@ -635,7 +635,7 @@ impl Strategy { matches.value_source(OPT_NUMBER) == Some(ValueSource::CommandLine), ) { (Some(v), false, false, false, false) => { - let v = parse_size_max(v).map_err(|_| { + let v = parse_size_u64_max(v).map_err(|_| { StrategyError::Lines(ParseSizeError::ParseFailure(v.to_string())) })?; if v > 0 { diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index 6e522aa3d..857828275 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -14,7 +14,7 @@ use std::process; use tempfile::tempdir; use tempfile::TempDir; use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; -use uucore::parse_size::parse_size; +use uucore::parse_size::parse_size_u64; use uucore::{crash, format_usage, help_about, help_section, help_usage}; const ABOUT: &str = help_about!("stdbuf.md"); @@ -101,7 +101,7 @@ fn check_option(matches: &ArgMatches, name: &str) -> Result parse_size(x).map_or_else( + x => parse_size_u64(x).map_or_else( |e| crash!(125, "invalid mode {}", e), |m| { Ok(BufferType::Size(m.try_into().map_err(|_| { diff --git a/src/uu/tail/src/args.rs b/src/uu/tail/src/args.rs index 388842a14..9b1729872 100644 --- a/src/uu/tail/src/args.rs +++ b/src/uu/tail/src/args.rs @@ -15,7 +15,7 @@ use std::ffi::OsString; use std::io::IsTerminal; use std::time::Duration; use uucore::error::{UResult, USimpleError, UUsageError}; -use uucore::parse_size::{parse_size, ParseSizeError}; +use uucore::parse_size::{parse_size_u64, ParseSizeError}; use uucore::{format_usage, help_about, help_usage, show_warning}; const ABOUT: &str = help_about!("tail.md"); @@ -414,7 +414,7 @@ fn parse_num(src: &str) -> Result { } } - match parse_size(size_string) { + match parse_size_u64(size_string) { Ok(n) => match (n, starting_with) { (0, true) => Ok(Signum::PlusZero), (0, false) => Ok(Signum::MinusZero), diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index 6e1c19fde..9368ce9b1 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -12,7 +12,7 @@ use std::os::unix::fs::FileTypeExt; use std::path::Path; use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; -use uucore::parse_size::{parse_size, ParseSizeError}; +use uucore::parse_size::{parse_size_u64, ParseSizeError}; use uucore::{format_usage, help_about, help_section, help_usage}; #[derive(Debug, Eq, PartialEq)] @@ -380,7 +380,7 @@ fn is_modifier(c: char) -> bool { /// Parse a size string with optional modifier symbol as its first character. /// -/// A size string is as described in [`parse_size`]. The first character +/// A size string is as described in [`parse_size_u64`]. The first character /// of `size_string` might be a modifier symbol, like `'+'` or /// `'<'`. The first element of the pair returned by this function /// indicates which modifier symbol was present, or @@ -406,7 +406,7 @@ fn parse_mode_and_size(size_string: &str) -> Result TruncateMode::Extend, '-' => TruncateMode::Reduce, '<' => TruncateMode::AtMost, diff --git a/src/uucore/src/lib/parser/parse_size.rs b/src/uucore/src/lib/parser/parse_size.rs index 4d9968bb7..83917dd25 100644 --- a/src/uucore/src/lib/parser/parse_size.rs +++ b/src/uucore/src/lib/parser/parse_size.rs @@ -51,7 +51,7 @@ impl<'parser> Parser<'parser> { /// Parse a size string into a number of bytes. /// /// A size string comprises an integer and an optional unit. The unit - /// may be K, M, G, T, P, E, Z or Y (powers of 1024), or KB, MB, + /// may be K, M, G, T, P, E, Z, Y, R or Q (powers of 1024), or KB, MB, /// etc. (powers of 1000), or b which is 512. /// Binary prefixes can be used, too: KiB=K, MiB=M, and so on. /// @@ -65,13 +65,18 @@ impl<'parser> Parser<'parser> { /// # Examples /// /// ```rust - /// use uucore::parse_size::parse_size; - /// assert_eq!(Ok(123), parse_size("123")); - /// assert_eq!(Ok(9 * 1000), parse_size("9kB")); // kB is 1000 - /// assert_eq!(Ok(2 * 1024), parse_size("2K")); // K is 1024 - /// assert_eq!(Ok(44251 * 1024), parse_size("0xACDBK")); + /// use uucore::parse_size::Parser; + /// let parser = Parser { + /// default_unit: Some("M"), + /// ..Default::default() + /// }; + /// assert_eq!(Ok(123 * 1024 * 1024), parser.parse("123M")); // M is 1024^2 + /// assert_eq!(Ok(123 * 1024 * 1024), parser.parse("123")); // default unit set to "M" on parser instance + /// assert_eq!(Ok(9 * 1000), parser.parse("9kB")); // kB is 1000 + /// assert_eq!(Ok(2 * 1024), parser.parse("2K")); // K is 1024 + /// assert_eq!(Ok(44251 * 1024), parser.parse("0xACDBK")); // 0xACDB is 44251 in decimal /// ``` - pub fn parse(&self, size: &str) -> Result { + pub fn parse(&self, size: &str) -> Result { if size.is_empty() { return Err(ParseSizeError::parse_failure(size)); } @@ -135,6 +140,8 @@ impl<'parser> Parser<'parser> { "EiB" | "eiB" | "E" | "e" => (1024, 6), "ZiB" | "ziB" | "Z" | "z" => (1024, 7), "YiB" | "yiB" | "Y" | "y" => (1024, 8), + "RiB" | "riB" | "R" | "r" => (1024, 9), + "QiB" | "qiB" | "Q" | "q" => (1024, 10), "KB" | "kB" => (1000, 1), "MB" | "mB" => (1000, 2), "GB" | "gB" => (1000, 3), @@ -143,16 +150,15 @@ impl<'parser> Parser<'parser> { "EB" | "eB" => (1000, 6), "ZB" | "zB" => (1000, 7), "YB" | "yB" => (1000, 8), + "RB" | "rB" => (1000, 9), + "QB" | "qB" => (1000, 10), _ if numeric_string.is_empty() => return Err(ParseSizeError::parse_failure(size)), _ => return Err(ParseSizeError::invalid_suffix(size)), }; - let factor = match u64::try_from(base.pow(exponent)) { - Ok(n) => n, - Err(_) => return Err(ParseSizeError::size_too_big(size)), - }; + let factor = base.pow(exponent); - // parse string into u64 - let number: u64 = match number_system { + // parse string into u128 + let number: u128 = match number_system { NumberSystem::Decimal => { if numeric_string.is_empty() { 1 @@ -175,6 +181,59 @@ impl<'parser> Parser<'parser> { .ok_or_else(|| ParseSizeError::size_too_big(size)) } + /// Explicit u128 alias for `parse()` + pub fn parse_u128(&self, size: &str) -> Result { + self.parse(size) + } + + /// Same as `parse()` but tries to return u64 + pub fn parse_u64(&self, size: &str) -> Result { + match self.parse(size) { + Ok(num_u128) => { + let num_u64 = match u64::try_from(num_u128) { + Ok(n) => n, + Err(_) => return Err(ParseSizeError::size_too_big(size)), + }; + Ok(num_u64) + } + Err(e) => Err(e), + } + } + + /// Same as `parse_u64()`, except returns `u64::MAX` on overflow + /// GNU lib/coreutils include similar functionality + /// and GNU test suite checks this behavior for some utils + pub fn parse_u64_max(&self, size: &str) -> Result { + let result = self.parse_u64(size); + match result { + Ok(_) => result, + Err(error) => { + if let ParseSizeError::SizeTooBig(_) = error { + Ok(u64::MAX) + } else { + Err(error) + } + } + } + } + + /// Same as `parse_u128()`, except returns `u128::MAX` on overflow + /// /// GNU lib/coreutils include similar functionality + /// and GNU test suite checks this behavior for some utils + pub fn parse_u128_max(&self, size: &str) -> Result { + let result = self.parse_u128(size); + match result { + Ok(_) => result, + Err(error) => { + if let ParseSizeError::SizeTooBig(_) = error { + Ok(u128::MAX) + } else { + Err(error) + } + } + } + } + fn determine_number_system(size: &str) -> NumberSystem { if size.len() <= 1 { return NumberSystem::Decimal; @@ -201,55 +260,50 @@ impl<'parser> Parser<'parser> { numeric_string: &str, radix: u32, original_size: &str, - ) -> Result { - u64::from_str_radix(numeric_string, radix).map_err(|e| match e.kind() { + ) -> Result { + u128::from_str_radix(numeric_string, radix).map_err(|e| match e.kind() { IntErrorKind::PosOverflow => ParseSizeError::size_too_big(original_size), _ => ParseSizeError::ParseFailure(original_size.to_string()), }) } } -/// Parse a size string into a number of bytes. -/// -/// A size string comprises an integer and an optional unit. The unit -/// may be K, M, G, T, P, E, Z or Y (powers of 1024), or KB, MB, -/// etc. (powers of 1000), or b which is 512. -/// Binary prefixes can be used, too: KiB=K, MiB=M, and so on. -/// -/// # Errors -/// -/// Will return `ParseSizeError` if it's not possible to parse this -/// string into a number, e.g. if the string does not begin with a -/// numeral, or if the unit is not one of the supported units described -/// in the preceding section. +/// Parse a size string into a number of bytes +/// using Default Parser (no custom settings) /// /// # Examples /// /// ```rust -/// use uucore::parse_size::parse_size; -/// assert_eq!(Ok(123), parse_size("123")); -/// assert_eq!(Ok(9 * 1000), parse_size("9kB")); // kB is 1000 -/// assert_eq!(Ok(2 * 1024), parse_size("2K")); // K is 1024 +/// use uucore::parse_size::parse_size_u128; +/// assert_eq!(Ok(123), parse_size_u128("123")); +/// assert_eq!(Ok(9 * 1000), parse_size_u128("9kB")); // kB is 1000 +/// assert_eq!(Ok(2 * 1024), parse_size_u128("2K")); // K is 1024 +/// assert_eq!(Ok(44251 * 1024), parse_size_u128("0xACDBK")); /// ``` -pub fn parse_size(size: &str) -> Result { +pub fn parse_size_u128(size: &str) -> Result { Parser::default().parse(size) } -/// Same as `parse_size()`, except returns `u64::MAX` on overflow +/// Same as `parse_size_u128()`, but for u64 +pub fn parse_size_u64(size: &str) -> Result { + Parser::default().parse_u64(size) +} + +#[deprecated = "Please use parse_size_u64(size: &str) -> Result OR parse_size_u128(size: &str) -> Result instead."] +pub fn parse_size(size: &str) -> Result { + parse_size_u64(size) +} + +/// Same as `parse_size_u64()`, except returns `u64::MAX` on overflow /// GNU lib/coreutils include similar functionality /// and GNU test suite checks this behavior for some utils -pub fn parse_size_max(size: &str) -> Result { - let result = Parser::default().parse(size); - match result { - Ok(_) => result, - Err(error) => { - if let ParseSizeError::SizeTooBig(_) = error { - Ok(u64::MAX) - } else { - Err(error) - } - } - } +pub fn parse_size_u64_max(size: &str) -> Result { + Parser::default().parse_u64_max(size) +} + +/// Same as `parse_size_u128()`, except returns `u128::MAX` on overflow +pub fn parse_size_u128_max(size: &str) -> Result { + Parser::default().parse_u128_max(size) } #[derive(Debug, PartialEq, Eq)] @@ -355,7 +409,7 @@ mod tests { #[test] fn all_suffixes() { - // Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). + // Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024) or KB,MB,... (powers of 1000). // Binary prefixes can be used, too: KiB=K, MiB=M, and so on. let suffixes = [ ('K', 1u32), @@ -364,60 +418,73 @@ mod tests { ('T', 4u32), ('P', 5u32), ('E', 6u32), - // The following will always result ParseSizeError::SizeTooBig as they cannot fit in u64 - // ('Z', 7u32), - // ('Y', 8u32), + ('Z', 7u32), + ('Y', 8u32), + ('R', 9u32), + ('Q', 10u32), ]; for &(c, exp) in &suffixes { let s = format!("2{c}B"); // KB - assert_eq!(Ok((2 * (1000_u128).pow(exp)) as u64), parse_size(&s)); + assert_eq!(Ok((2 * (1000_u128).pow(exp)) as u128), parse_size_u128(&s)); let s = format!("2{c}"); // K - assert_eq!(Ok((2 * (1024_u128).pow(exp)) as u64), parse_size(&s)); + assert_eq!(Ok((2 * (1024_u128).pow(exp)) as u128), parse_size_u128(&s)); let s = format!("2{c}iB"); // KiB - assert_eq!(Ok((2 * (1024_u128).pow(exp)) as u64), parse_size(&s)); + assert_eq!(Ok((2 * (1024_u128).pow(exp)) as u128), parse_size_u128(&s)); let s = format!("2{}iB", c.to_lowercase()); // kiB - assert_eq!(Ok((2 * (1024_u128).pow(exp)) as u64), parse_size(&s)); + assert_eq!(Ok((2 * (1024_u128).pow(exp)) as u128), parse_size_u128(&s)); // suffix only let s = format!("{c}B"); // KB - assert_eq!(Ok(((1000_u128).pow(exp)) as u64), parse_size(&s)); + assert_eq!(Ok(((1000_u128).pow(exp)) as u128), parse_size_u128(&s)); let s = format!("{c}"); // K - assert_eq!(Ok(((1024_u128).pow(exp)) as u64), parse_size(&s)); + assert_eq!(Ok(((1024_u128).pow(exp)) as u128), parse_size_u128(&s)); let s = format!("{c}iB"); // KiB - assert_eq!(Ok(((1024_u128).pow(exp)) as u64), parse_size(&s)); + assert_eq!(Ok(((1024_u128).pow(exp)) as u128), parse_size_u128(&s)); let s = format!("{}iB", c.to_lowercase()); // kiB - assert_eq!(Ok(((1024_u128).pow(exp)) as u64), parse_size(&s)); + assert_eq!(Ok(((1024_u128).pow(exp)) as u128), parse_size_u128(&s)); } } #[test] #[cfg(not(target_pointer_width = "128"))] fn overflow_x64() { - assert!(parse_size("10000000000000000000000").is_err()); - assert!(parse_size("1000000000T").is_err()); - assert!(parse_size("100000P").is_err()); - assert!(parse_size("100E").is_err()); - assert!(parse_size("1Z").is_err()); - assert!(parse_size("1Y").is_err()); + assert!(parse_size_u64("10000000000000000000000").is_err()); + assert!(parse_size_u64("1000000000T").is_err()); + assert!(parse_size_u64("100000P").is_err()); + assert!(parse_size_u64("100E").is_err()); + assert!(parse_size_u64("1Z").is_err()); + assert!(parse_size_u64("1Y").is_err()); + assert!(parse_size_u64("1R").is_err()); + assert!(parse_size_u64("1Q").is_err()); assert!(variant_eq( - &parse_size("1Z").unwrap_err(), + &parse_size_u64("1Z").unwrap_err(), &ParseSizeError::SizeTooBig(String::new()) )); assert_eq!( ParseSizeError::SizeTooBig("'1Y': Value too large for defined data type".to_string()), - parse_size("1Y").unwrap_err() + parse_size_u64("1Y").unwrap_err() + ); + assert_eq!( + ParseSizeError::SizeTooBig("'1R': Value too large for defined data type".to_string()), + parse_size_u64("1R").unwrap_err() + ); + assert_eq!( + ParseSizeError::SizeTooBig("'1Q': Value too large for defined data type".to_string()), + parse_size_u64("1Q").unwrap_err() ); } #[test] #[cfg(not(target_pointer_width = "128"))] fn overflow_to_max_x64() { - assert_eq!(Ok(u64::MAX), parse_size_max("18446744073709551616")); - assert_eq!(Ok(u64::MAX), parse_size_max("10000000000000000000000")); - assert_eq!(Ok(u64::MAX), parse_size_max("1Y")); + assert_eq!(Ok(u64::MAX), parse_size_u64_max("18446744073709551616")); + assert_eq!(Ok(u64::MAX), parse_size_u64_max("10000000000000000000000")); + assert_eq!(Ok(u64::MAX), parse_size_u64_max("1Y")); + assert_eq!(Ok(u64::MAX), parse_size_u64_max("1R")); + assert_eq!(Ok(u64::MAX), parse_size_u64_max("1Q")); } #[test] @@ -425,7 +492,7 @@ mod tests { let test_strings = ["5mib", "1eb", "1H"]; for &test_string in &test_strings { assert_eq!( - parse_size(test_string).unwrap_err(), + parse_size_u64(test_string).unwrap_err(), ParseSizeError::InvalidSuffix(format!("{}", test_string.quote())) ); } @@ -436,7 +503,7 @@ mod tests { let test_strings = ["biB", "-", "+", "", "-1", "∞"]; for &test_string in &test_strings { assert_eq!( - parse_size(test_string).unwrap_err(), + parse_size_u64(test_string).unwrap_err(), ParseSizeError::ParseFailure(format!("{}", test_string.quote())) ); } @@ -444,57 +511,83 @@ mod tests { #[test] fn b_suffix() { - assert_eq!(Ok(3 * 512), parse_size("3b")); // b is 512 + assert_eq!(Ok(3 * 512), parse_size_u64("3b")); // b is 512 } #[test] fn no_suffix() { - assert_eq!(Ok(1234), parse_size("1234")); - assert_eq!(Ok(0), parse_size("0")); - assert_eq!(Ok(5), parse_size("5")); - assert_eq!(Ok(999), parse_size("999")); + assert_eq!(Ok(1234), parse_size_u64("1234")); + assert_eq!(Ok(0), parse_size_u64("0")); + assert_eq!(Ok(5), parse_size_u64("5")); + assert_eq!(Ok(999), parse_size_u64("999")); } #[test] fn kilobytes_suffix() { - assert_eq!(Ok(123 * 1000), parse_size("123KB")); // KB is 1000 - assert_eq!(Ok(9 * 1000), parse_size("9kB")); // kB is 1000 - assert_eq!(Ok(2 * 1024), parse_size("2K")); // K is 1024 - assert_eq!(Ok(0), parse_size("0K")); - assert_eq!(Ok(0), parse_size("0KB")); - assert_eq!(Ok(1000), parse_size("KB")); - assert_eq!(Ok(1024), parse_size("K")); - assert_eq!(Ok(2000), parse_size("2kB")); - assert_eq!(Ok(4000), parse_size("4KB")); + assert_eq!(Ok(123 * 1000), parse_size_u64("123KB")); // KB is 1000 + assert_eq!(Ok(9 * 1000), parse_size_u64("9kB")); // kB is 1000 + assert_eq!(Ok(2 * 1024), parse_size_u64("2K")); // K is 1024 + assert_eq!(Ok(0), parse_size_u64("0K")); + assert_eq!(Ok(0), parse_size_u64("0KB")); + assert_eq!(Ok(1000), parse_size_u64("KB")); + assert_eq!(Ok(1024), parse_size_u64("K")); + assert_eq!(Ok(2000), parse_size_u64("2kB")); + assert_eq!(Ok(4000), parse_size_u64("4KB")); } #[test] fn megabytes_suffix() { - assert_eq!(Ok(123 * 1024 * 1024), parse_size("123M")); - assert_eq!(Ok(123 * 1000 * 1000), parse_size("123MB")); - assert_eq!(Ok(1024 * 1024), parse_size("M")); - assert_eq!(Ok(1000 * 1000), parse_size("MB")); - assert_eq!(Ok(2 * 1_048_576), parse_size("2m")); - assert_eq!(Ok(4 * 1_048_576), parse_size("4M")); - assert_eq!(Ok(2_000_000), parse_size("2mB")); - assert_eq!(Ok(4_000_000), parse_size("4MB")); + assert_eq!(Ok(123 * 1024 * 1024), parse_size_u64("123M")); + assert_eq!(Ok(123 * 1000 * 1000), parse_size_u64("123MB")); + assert_eq!(Ok(1024 * 1024), parse_size_u64("M")); + assert_eq!(Ok(1000 * 1000), parse_size_u64("MB")); + assert_eq!(Ok(2 * 1_048_576), parse_size_u64("2m")); + assert_eq!(Ok(4 * 1_048_576), parse_size_u64("4M")); + assert_eq!(Ok(2_000_000), parse_size_u64("2mB")); + assert_eq!(Ok(4_000_000), parse_size_u64("4MB")); } #[test] fn gigabytes_suffix() { - assert_eq!(Ok(1_073_741_824), parse_size("1G")); - assert_eq!(Ok(2_000_000_000), parse_size("2GB")); + assert_eq!(Ok(1_073_741_824), parse_size_u64("1G")); + assert_eq!(Ok(2_000_000_000), parse_size_u64("2GB")); } #[test] #[cfg(target_pointer_width = "64")] fn x64() { - assert_eq!(Ok(1_099_511_627_776), parse_size("1T")); - assert_eq!(Ok(1_125_899_906_842_624), parse_size("1P")); - assert_eq!(Ok(1_152_921_504_606_846_976), parse_size("1E")); - assert_eq!(Ok(2_000_000_000_000), parse_size("2TB")); - assert_eq!(Ok(2_000_000_000_000_000), parse_size("2PB")); - assert_eq!(Ok(2_000_000_000_000_000_000), parse_size("2EB")); + assert_eq!(Ok(1_099_511_627_776), parse_size_u64("1T")); + assert_eq!(Ok(1_125_899_906_842_624), parse_size_u64("1P")); + assert_eq!(Ok(1_152_921_504_606_846_976), parse_size_u64("1E")); + + assert_eq!(Ok(1_180_591_620_717_411_303_424), parse_size_u128("1Z")); + assert_eq!(Ok(1_208_925_819_614_629_174_706_176), parse_size_u128("1Y")); + assert_eq!( + Ok(1_237_940_039_285_380_274_899_124_224), + parse_size_u128("1R") + ); + assert_eq!( + Ok(1_267_650_600_228_229_401_496_703_205_376), + parse_size_u128("1Q") + ); + + assert_eq!(Ok(2_000_000_000_000), parse_size_u64("2TB")); + assert_eq!(Ok(2_000_000_000_000_000), parse_size_u64("2PB")); + assert_eq!(Ok(2_000_000_000_000_000_000), parse_size_u64("2EB")); + + assert_eq!(Ok(2_000_000_000_000_000_000_000), parse_size_u128("2ZB")); + assert_eq!( + Ok(2_000_000_000_000_000_000_000_000), + parse_size_u128("2YB") + ); + assert_eq!( + Ok(2_000_000_000_000_000_000_000_000_000), + parse_size_u128("2RB") + ); + assert_eq!( + Ok(2_000_000_000_000_000_000_000_000_000_000), + parse_size_u128("2QB") + ); } #[test] @@ -539,15 +632,15 @@ mod tests { #[test] fn parse_octal_size() { - assert_eq!(Ok(63), parse_size("077")); - assert_eq!(Ok(528), parse_size("01020")); - assert_eq!(Ok(668 * 1024), parse_size("01234K")); + assert_eq!(Ok(63), parse_size_u64("077")); + assert_eq!(Ok(528), parse_size_u64("01020")); + assert_eq!(Ok(668 * 1024), parse_size_u128("01234K")); } #[test] fn parse_hex_size() { - assert_eq!(Ok(10), parse_size("0xA")); - assert_eq!(Ok(94722), parse_size("0x17202")); - assert_eq!(Ok(44251 * 1024), parse_size("0xACDBK")); + assert_eq!(Ok(10), parse_size_u64("0xA")); + assert_eq!(Ok(94722), parse_size_u64("0x17202")); + assert_eq!(Ok(44251 * 1024), parse_size_u128("0xACDBK")); } } diff --git a/tests/by-util/test_head.rs b/tests/by-util/test_head.rs index 65aeca437..f536b26ae 100644 --- a/tests/by-util/test_head.rs +++ b/tests/by-util/test_head.rs @@ -297,11 +297,15 @@ fn test_head_invalid_num() { new_ucmd!() .args(&["-c", "1024R", "emptyfile.txt"]) .fails() - .stderr_is("head: invalid number of bytes: '1024R'\n"); + .stderr_is( + "head: invalid number of bytes: '1024R': Value too large for defined data type\n", + ); new_ucmd!() .args(&["-n", "1024R", "emptyfile.txt"]) .fails() - .stderr_is("head: invalid number of lines: '1024R'\n"); + .stderr_is( + "head: invalid number of lines: '1024R': Value too large for defined data type\n", + ); #[cfg(not(target_pointer_width = "128"))] new_ucmd!() .args(&["-c", "1Y", "emptyfile.txt"]) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 113c0fb87..be3933df3 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -642,10 +642,10 @@ fn test_split_obs_lines_within_combined_with_number() { #[test] fn test_split_invalid_bytes_size() { new_ucmd!() - .args(&["-b", "1024R"]) + .args(&["-b", "1024W"]) .fails() .code_is(1) - .stderr_only("split: invalid number of bytes: '1024R'\n"); + .stderr_only("split: invalid number of bytes: '1024W'\n"); #[cfg(target_pointer_width = "32")] { let sizes = ["1000G", "10T"]; diff --git a/tests/by-util/test_truncate.rs b/tests/by-util/test_truncate.rs index 972b4fc5b..81b87ed2e 100644 --- a/tests/by-util/test_truncate.rs +++ b/tests/by-util/test_truncate.rs @@ -248,7 +248,7 @@ fn test_truncate_bytes_size() { .args(&["--size", "1024R", "file"]) .fails() .code_is(1) - .stderr_only("truncate: Invalid number: '1024R'\n"); + .stderr_only("truncate: Invalid number: '1024R': Value too large for defined data type\n"); #[cfg(not(target_pointer_width = "128"))] new_ucmd!() .args(&["--size", "1Y", "file"]) From 7038657a447bd96b7b323be58e7d386af6a6db0d Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Wed, 4 Oct 2023 21:57:33 -0400 Subject: [PATCH 332/370] implement R and Q prefixes --- tests/by-util/test_stdbuf.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_stdbuf.rs b/tests/by-util/test_stdbuf.rs index e31c532e2..9a67dad9e 100644 --- a/tests/by-util/test_stdbuf.rs +++ b/tests/by-util/test_stdbuf.rs @@ -65,7 +65,7 @@ fn test_stdbuf_invalid_mode_fails() { .args(&[*option, "1024R", "head"]) .fails() .code_is(125) - .stderr_only("stdbuf: invalid mode '1024R'\n"); + .stderr_only("stdbuf: invalid mode '1024R': Value too large for defined data type\n"); #[cfg(not(target_pointer_width = "128"))] new_ucmd!() .args(&[*option, "1Y", "head"]) From 74e01e39877bf171b3a1eba725e913eab92dc1a8 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Thu, 5 Oct 2023 16:11:11 -0400 Subject: [PATCH 333/370] parse_size: more test case coverage --- src/uucore/src/lib/parser/parse_size.rs | 29 +++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/uucore/src/lib/parser/parse_size.rs b/src/uucore/src/lib/parser/parse_size.rs index 83917dd25..337ad396b 100644 --- a/src/uucore/src/lib/parser/parse_size.rs +++ b/src/uucore/src/lib/parser/parse_size.rs @@ -479,7 +479,9 @@ mod tests { #[test] #[cfg(not(target_pointer_width = "128"))] - fn overflow_to_max_x64() { + fn overflow_to_max_u64() { + assert_eq!(Ok(1_099_511_627_776), parse_size_u64_max("1T")); + assert_eq!(Ok(1_125_899_906_842_624), parse_size_u64_max("1P")); assert_eq!(Ok(u64::MAX), parse_size_u64_max("18446744073709551616")); assert_eq!(Ok(u64::MAX), parse_size_u64_max("10000000000000000000000")); assert_eq!(Ok(u64::MAX), parse_size_u64_max("1Y")); @@ -487,6 +489,21 @@ mod tests { assert_eq!(Ok(u64::MAX), parse_size_u64_max("1Q")); } + #[test] + #[cfg(not(target_pointer_width = "128"))] + fn overflow_to_max_u128() { + assert_eq!( + Ok(12_379_400_392_853_802_748_991_242_240), + parse_size_u128_max("10R") + ); + assert_eq!( + Ok(12_676_506_002_282_294_014_967_032_053_760), + parse_size_u128_max("10Q") + ); + assert_eq!(Ok(u128::MAX), parse_size_u128_max("1000000000000R")); + assert_eq!(Ok(u128::MAX), parse_size_u128_max("1000000000Q")); + } + #[test] fn invalid_suffix() { let test_strings = ["5mib", "1eb", "1H"]; @@ -610,7 +627,7 @@ mod tests { parser .with_allow_list(&[ - "b", "k", "K", "m", "M", "MB", "g", "G", "t", "T", "P", "E", "Z", "Y", + "b", "k", "K", "m", "M", "MB", "g", "G", "t", "T", "P", "E", "Z", "Y", "R", "Q", ]) .with_default_unit("K") .with_b_byte_count(true); @@ -620,6 +637,14 @@ mod tests { assert_eq!(Ok(1000 * 1000), parser.parse("1MB")); assert_eq!(Ok(1024 * 1024), parser.parse("1M")); assert_eq!(Ok(1024 * 1024 * 1024), parser.parse("1G")); + assert_eq!( + Ok(1_237_940_039_285_380_274_899_124_224), + parser.parse_u128("1R") + ); + assert_eq!( + Ok(1_267_650_600_228_229_401_496_703_205_376), + parser.parse_u128("1Q") + ); assert_eq!(Ok(1), parser.parse("1b")); assert_eq!(Ok(1024), parser.parse("1024b")); From abc95361a5d3043cca41118e201f4bbbbdf5ce18 Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Thu, 5 Oct 2023 16:23:24 -0400 Subject: [PATCH 334/370] prase_size: comments --- src/uucore/src/lib/parser/parse_size.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/uucore/src/lib/parser/parse_size.rs b/src/uucore/src/lib/parser/parse_size.rs index 337ad396b..0a46ce327 100644 --- a/src/uucore/src/lib/parser/parse_size.rs +++ b/src/uucore/src/lib/parser/parse_size.rs @@ -202,7 +202,7 @@ impl<'parser> Parser<'parser> { /// Same as `parse_u64()`, except returns `u64::MAX` on overflow /// GNU lib/coreutils include similar functionality - /// and GNU test suite checks this behavior for some utils + /// and GNU test suite checks this behavior for some utils (`split` for example) pub fn parse_u64_max(&self, size: &str) -> Result { let result = self.parse_u64(size); match result { @@ -217,9 +217,7 @@ impl<'parser> Parser<'parser> { } } - /// Same as `parse_u128()`, except returns `u128::MAX` on overflow - /// /// GNU lib/coreutils include similar functionality - /// and GNU test suite checks this behavior for some utils + /// Same as `parse_u64_max()`, except for u128, i.e. returns `u128::MAX` on overflow pub fn parse_u128_max(&self, size: &str) -> Result { let result = self.parse_u128(size); match result { From b6a6a4dc6506db94ec7dc4702314c78bff3be0ab Mon Sep 17 00:00:00 2001 From: terade <134976752+terade@users.noreply.github.com.> Date: Tue, 17 Oct 2023 17:26:27 +0200 Subject: [PATCH 335/370] rm: apply suggestion of retrieving metatada in function --- src/uu/rm/src/rm.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 0f4d04598..43a7ec774 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -514,22 +514,18 @@ fn prompt_file(path: &Path, options: &Options) -> bool { prompt_yes!("remove file {}?", path.quote()) }; } - prompt_file_permission_readonly(path, Ok(metadata)) } Err(err) => { if err.kind() != ErrorKind::PermissionDenied { return true; } - prompt_file_permission_readonly(path, fs::metadata(path)) } } + prompt_file_permission_readonly(path) } -fn prompt_file_permission_readonly( - path: &Path, - metadata_or_err: Result, -) -> bool { - match metadata_or_err { +fn prompt_file_permission_readonly(path: &Path) -> bool { + match fs::metadata(path) { Ok(metadata) if !metadata.permissions().readonly() => true, Ok(metadata) if metadata.len() == 0 => prompt_yes!( "remove write-protected regular empty file {}?", From 12765a445e4bde82616d4c36af1fd9a7509b2ac0 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 18 Oct 2023 10:11:13 +0200 Subject: [PATCH 336/370] fuzz: set LC_COLLATE=C for expr --- fuzz/fuzz_targets/fuzz_expr.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fuzz/fuzz_targets/fuzz_expr.rs b/fuzz/fuzz_targets/fuzz_expr.rs index fb7b17309..c2217c48a 100644 --- a/fuzz/fuzz_targets/fuzz_expr.rs +++ b/fuzz/fuzz_targets/fuzz_expr.rs @@ -10,7 +10,7 @@ use uu_expr::uumain; use rand::seq::SliceRandom; use rand::Rng; -use std::ffi::OsString; +use std::{env, ffi::OsString}; mod fuzz_common; use crate::fuzz_common::{generate_and_run_uumain, run_gnu_cmd}; @@ -86,6 +86,11 @@ fuzz_target!(|_data: &[u8]| { let (rust_output, uumain_exit_code) = generate_and_run_uumain(&args, uumain); + // Use C locale to avoid false positives, like in https://github.com/uutils/coreutils/issues/5378, + // because uutils expr doesn't support localization yet + // TODO remove once uutils expr supports localization + env::set_var("LC_COLLATE", "C"); + // Run GNU expr with the provided arguments and compare the output match run_gnu_cmd(CMD_PATH, &args[1..], true) { Ok((gnu_output, gnu_exit_code)) => { From a2defd1a21f66b2e4e5a6462349424f7d995ff3c Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 18 Oct 2023 16:34:35 +0200 Subject: [PATCH 337/370] uucore: remove incorrect comment --- src/uucore/src/lib/features/fs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index 97238b10d..84ed006d9 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -435,6 +435,7 @@ pub fn canonicalize>( } #[cfg(not(unix))] +/// Display the permissions of a file pub fn display_permissions(metadata: &fs::Metadata, display_file_type: bool) -> String { let write = if metadata.permissions().readonly() { '-' @@ -459,7 +460,6 @@ pub fn display_permissions(metadata: &fs::Metadata, display_file_type: bool) -> #[cfg(unix)] /// Display the permissions of a file -/// On non unix like system, just show '----------' pub fn display_permissions(metadata: &fs::Metadata, display_file_type: bool) -> String { let mode: mode_t = metadata.mode() as mode_t; display_permissions_unix(mode, display_file_type) From 1ab8555a94ec128e7f8f9dd172c96e7d375ebce4 Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Wed, 18 Oct 2023 22:50:43 +0800 Subject: [PATCH 338/370] pathchk: check empty path --- src/uu/pathchk/src/pathchk.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index 3510a3327..81c352088 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -193,6 +193,17 @@ fn check_default(path: &[String]) -> bool { ); return false; } + if total_len == 0 { + // Check whether a file name component is in a directory that is not searchable, + // or has some other serious problem. POSIX does not allow "" as a file name, + // but some non-POSIX hosts do (as an alias for "."), + // so allow "" if `symlink_metadata` (corresponds to `lstat`) does. + if fs::symlink_metadata(&joined_path).is_err() { + writeln!(std::io::stderr(), "pathchk: '': No such file or directory",); + return false; + } + } + // components: length for p in path { let component_len = p.len(); From f63f9a06f62340ded772fac93e732af80e534208 Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Wed, 18 Oct 2023 22:50:54 +0800 Subject: [PATCH 339/370] tests/pathchk: test empty path --- tests/by-util/test_pathchk.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/by-util/test_pathchk.rs b/tests/by-util/test_pathchk.rs index f497cfe89..e1f4bc539 100644 --- a/tests/by-util/test_pathchk.rs +++ b/tests/by-util/test_pathchk.rs @@ -19,8 +19,10 @@ fn test_default_mode() { // accept non-portable chars new_ucmd!().args(&["dir#/$file"]).succeeds().no_stdout(); - // accept empty path - new_ucmd!().args(&[""]).succeeds().no_stdout(); + // fail on empty path + new_ucmd!().args(&[""]).fails().no_stdout(); + + new_ucmd!().args(&["", ""]).fails().no_stdout(); // fail on long path new_ucmd!() From 44240915921214c1027a0520487a8af85d3ba67e Mon Sep 17 00:00:00 2001 From: Zhuoxun Yang Date: Thu, 19 Oct 2023 01:29:53 +0800 Subject: [PATCH 340/370] tests/pathchk: check error message --- tests/by-util/test_pathchk.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/by-util/test_pathchk.rs b/tests/by-util/test_pathchk.rs index e1f4bc539..d66ecb9ef 100644 --- a/tests/by-util/test_pathchk.rs +++ b/tests/by-util/test_pathchk.rs @@ -20,9 +20,15 @@ fn test_default_mode() { new_ucmd!().args(&["dir#/$file"]).succeeds().no_stdout(); // fail on empty path - new_ucmd!().args(&[""]).fails().no_stdout(); + new_ucmd!() + .args(&[""]) + .fails() + .stderr_only("pathchk: '': No such file or directory\n"); - new_ucmd!().args(&["", ""]).fails().no_stdout(); + new_ucmd!().args(&["", ""]).fails().stderr_only( + "pathchk: '': No such file or directory\n\ + pathchk: '': No such file or directory\n", + ); // fail on long path new_ucmd!() From 90c2dbb0ccc532d1ba014525d9df02caee26b3bb Mon Sep 17 00:00:00 2001 From: David Matos Date: Thu, 19 Oct 2023 09:50:21 +0200 Subject: [PATCH 341/370] mv: make UpdateMode public --- src/uu/mv/src/mv.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 9888389ae..02c856ce0 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -19,12 +19,12 @@ use std::os::unix; #[cfg(windows)] use std::os::windows; use std::path::{Path, PathBuf}; -pub use uucore::backup_control::BackupMode; use uucore::backup_control::{self, source_is_target_backup}; use uucore::display::Quotable; use uucore::error::{set_exit_code, FromIo, UError, UResult, USimpleError, UUsageError}; use uucore::fs::{are_hardlinks_or_one_way_symlink_to_same_file, are_hardlinks_to_same_file}; -use uucore::update_control::{self, UpdateMode}; +use uucore::update_control; +pub use uucore::{backup_control::BackupMode, update_control::UpdateMode}; use uucore::{format_usage, help_about, help_section, help_usage, prompt_yes, show}; use fs_extra::dir::{ From 383dcde51a7ad501dddbf22dc36f2296532fed90 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 19 Oct 2023 10:08:45 +0200 Subject: [PATCH 342/370] mv: comment why some imports are public --- src/uu/mv/src/mv.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 02c856ce0..7236907da 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -24,6 +24,8 @@ use uucore::display::Quotable; use uucore::error::{set_exit_code, FromIo, UError, UResult, USimpleError, UUsageError}; use uucore::fs::{are_hardlinks_or_one_way_symlink_to_same_file, are_hardlinks_to_same_file}; use uucore::update_control; +// These are exposed for projects (e.g. nushell) that want to create an `Options` value, which +// requires these enums pub use uucore::{backup_control::BackupMode, update_control::UpdateMode}; use uucore::{format_usage, help_about, help_section, help_usage, prompt_yes, show}; From f971a69d69c57eed1fe31807cd069cfbdc923463 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 19 Oct 2023 14:17:34 +0200 Subject: [PATCH 343/370] ls --dired -R: fix the positions (#5341) * move get_offset_from_previous_line into a specific function * dired: improve the -R support * dired: fix the display with subdir * ls --dired -R: fix the positions * ls --dired -R: verify also the SUBDIRED coordinate * ls --dired -R: add a long file name and fix a windows test * dired: always put dired first in the args + minor fixes Co-authored-by: Daniel Hofstetter * ls: add cognitive_complexity to silent a warning --------- Co-authored-by: Daniel Hofstetter --- src/uu/ls/src/dired.rs | 208 +++++++++++++++++++++++++++++++++------ src/uu/ls/src/ls.rs | 41 ++++++-- tests/by-util/test_ls.rs | 102 +++++++++++++++++++ 3 files changed, 314 insertions(+), 37 deletions(-) diff --git a/src/uu/ls/src/dired.rs b/src/uu/ls/src/dired.rs index 8574e750e..74732d37a 100644 --- a/src/uu/ls/src/dired.rs +++ b/src/uu/ls/src/dired.rs @@ -9,14 +9,14 @@ use std::fmt; use std::io::{BufWriter, Stdout, Write}; use uucore::error::UResult; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct BytePosition { pub start: usize, pub end: usize, } /// Represents the output structure for DIRED, containing positions for both DIRED and SUBDIRED. -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Default, PartialEq)] pub struct DiredOutput { pub dired_positions: Vec, pub subdired_positions: Vec, @@ -32,17 +32,21 @@ impl fmt::Display for BytePosition { // When --dired is used, all lines starts with 2 spaces static DIRED_TRAILING_OFFSET: usize = 2; -/// Calculates the byte positions for DIRED -pub fn calculate_dired( - output_display_len: usize, - dfn_len: usize, - dired_positions: &[BytePosition], -) -> (usize, usize) { - let offset_from_previous_line = if let Some(last_position) = dired_positions.last() { +fn get_offset_from_previous_line(dired_positions: &[BytePosition]) -> usize { + if let Some(last_position) = dired_positions.last() { last_position.end + 1 } else { 0 - }; + } +} + +/// Calculates the byte positions for DIRED +pub fn calculate_dired( + dired_positions: &[BytePosition], + output_display_len: usize, + dfn_len: usize, +) -> (usize, usize) { + let offset_from_previous_line = get_offset_from_previous_line(dired_positions); let start = output_display_len + offset_from_previous_line; let end = start + dfn_len; @@ -55,15 +59,18 @@ pub fn indent(out: &mut BufWriter) -> UResult<()> { } pub fn calculate_subdired(dired: &mut DiredOutput, path_len: usize) { - let offset = if dired.subdired_positions.is_empty() { - DIRED_TRAILING_OFFSET + let offset_from_previous_line = get_offset_from_previous_line(&dired.dired_positions); + + let additional_offset = if dired.subdired_positions.is_empty() { + 0 } else { - dired.subdired_positions[dired.subdired_positions.len() - 1].start + DIRED_TRAILING_OFFSET + // if we have several directories: \n\n + 2 }; - dired.subdired_positions.push(BytePosition { - start: offset, - end: path_len + offset, - }); + + let start = offset_from_previous_line + DIRED_TRAILING_OFFSET + additional_offset; + let end = start + path_len; + dired.subdired_positions.push(BytePosition { start, end }); } /// Prints the dired output based on the given configuration and dired structure. @@ -73,10 +80,11 @@ pub fn print_dired_output( out: &mut BufWriter, ) -> UResult<()> { out.flush()?; + if dired.padding == 0 && !dired.dired_positions.is_empty() { + print_positions("//DIRED//", &dired.dired_positions); + } if config.recursive { print_positions("//SUBDIRED//", &dired.subdired_positions); - } else if dired.padding == 0 { - print_positions("//DIRED//", &dired.dired_positions); } println!("//DIRED-OPTIONS// --quoting-style={}", config.quoting_style); Ok(()) @@ -91,17 +99,31 @@ fn print_positions(prefix: &str, positions: &Vec) { println!(); } -pub fn add_total(total_len: usize, dired: &mut DiredOutput) { - // when dealing with " total: xx", it isn't part of the //DIRED// - // so, we just keep the size line to add it to the position of the next file - dired.padding = total_len + DIRED_TRAILING_OFFSET; +pub fn add_total(dired: &mut DiredOutput, total_len: usize) { + if dired.padding == 0 { + let offset_from_previous_line = get_offset_from_previous_line(&dired.dired_positions); + // when dealing with " total: xx", it isn't part of the //DIRED// + // so, we just keep the size line to add it to the position of the next file + dired.padding = total_len + offset_from_previous_line + DIRED_TRAILING_OFFSET; + } else { + // += because if we are in -R, we have " dir:\n total X". So, we need to take the + // previous padding too. + // and we already have the previous position in mind + dired.padding += total_len + DIRED_TRAILING_OFFSET; + } +} + +// when using -R, we have the dirname. we need to add it to the padding +pub fn add_dir_name(dired: &mut DiredOutput, dir_len: usize) { + // 1 for the ":" in " dirname:" + dired.padding += dir_len + DIRED_TRAILING_OFFSET + 1; } /// Calculates byte positions and updates the dired structure. pub fn calculate_and_update_positions( + dired: &mut DiredOutput, output_display_len: usize, dfn_len: usize, - dired: &mut DiredOutput, ) { let offset = dired .dired_positions @@ -111,14 +133,14 @@ pub fn calculate_and_update_positions( }); let start = output_display_len + offset + DIRED_TRAILING_OFFSET; let end = start + dfn_len; - update_positions(start, end, dired); + update_positions(dired, start, end); } /// Updates the dired positions based on the given start and end positions. /// update when it is the first element in the list (to manage "total X") /// insert when it isn't the about total -pub fn update_positions(start: usize, end: usize, dired: &mut DiredOutput) { - // padding can be 0 but as it doesn't matter< +pub fn update_positions(dired: &mut DiredOutput, start: usize, end: usize) { + // padding can be 0 but as it doesn't matter dired.dired_positions.push(BytePosition { start: start + dired.padding, end: end + dired.padding, @@ -136,12 +158,112 @@ mod tests { let output_display = "sample_output".to_string(); let dfn = "sample_file".to_string(); let dired_positions = vec![BytePosition { start: 5, end: 10 }]; - let (start, end) = calculate_dired(output_display.len(), dfn.len(), &dired_positions); + let (start, end) = calculate_dired(&dired_positions, output_display.len(), dfn.len()); assert_eq!(start, 24); assert_eq!(end, 35); } + #[test] + fn test_get_offset_from_previous_line() { + let positions = vec![ + BytePosition { start: 0, end: 3 }, + BytePosition { start: 4, end: 7 }, + BytePosition { start: 8, end: 11 }, + ]; + assert_eq!(get_offset_from_previous_line(&positions), 12); + } + #[test] + fn test_calculate_subdired() { + let mut dired = DiredOutput { + dired_positions: vec![ + BytePosition { start: 0, end: 3 }, + BytePosition { start: 4, end: 7 }, + BytePosition { start: 8, end: 11 }, + ], + subdired_positions: vec![], + padding: 0, + }; + let path_len = 5; + calculate_subdired(&mut dired, path_len); + assert_eq!( + dired.subdired_positions, + vec![BytePosition { start: 14, end: 19 }], + ); + } + + #[test] + fn test_add_dir_name() { + let mut dired = DiredOutput { + dired_positions: vec![ + BytePosition { start: 0, end: 3 }, + BytePosition { start: 4, end: 7 }, + BytePosition { start: 8, end: 11 }, + ], + subdired_positions: vec![], + padding: 0, + }; + let dir_len = 5; + add_dir_name(&mut dired, dir_len); + assert_eq!( + dired, + DiredOutput { + dired_positions: vec![ + BytePosition { start: 0, end: 3 }, + BytePosition { start: 4, end: 7 }, + BytePosition { start: 8, end: 11 }, + ], + subdired_positions: vec![], + // 8 = 1 for the \n + 5 for dir_len + 2 for " " + 1 for : + padding: 8 + } + ); + } + + #[test] + fn test_add_total() { + let mut dired = DiredOutput { + dired_positions: vec![ + BytePosition { start: 0, end: 3 }, + BytePosition { start: 4, end: 7 }, + BytePosition { start: 8, end: 11 }, + ], + subdired_positions: vec![], + padding: 0, + }; + // if we have "total: 2" + let total_len = 8; + add_total(&mut dired, total_len); + // 22 = 8 (len) + 2 (padding) + 11 (previous position) + 1 (\n) + assert_eq!(dired.padding, 22); + } + + #[test] + fn test_add_dir_name_and_total() { + // test when we have + // dirname: + // total 0 + // -rw-r--r-- 1 sylvestre sylvestre 0 Sep 30 09:41 ab + + let mut dired = DiredOutput { + dired_positions: vec![ + BytePosition { start: 0, end: 3 }, + BytePosition { start: 4, end: 7 }, + BytePosition { start: 8, end: 11 }, + ], + subdired_positions: vec![], + padding: 0, + }; + let dir_len = 5; + add_dir_name(&mut dired, dir_len); + // 8 = 2 (" ") + 1 (\n) + 5 + 1 (: of dirname) + assert_eq!(dired.padding, 8); + + let total_len = 8; + add_total(&mut dired, total_len); + assert_eq!(dired.padding, 18); + } + #[test] fn test_dired_update_positions() { let mut dired = DiredOutput { @@ -151,15 +273,41 @@ mod tests { }; // Test with adjust = true - update_positions(15, 20, &mut dired); + update_positions(&mut dired, 15, 20); let last_position = dired.dired_positions.last().unwrap(); assert_eq!(last_position.start, 25); // 15 + 10 (end of the previous position) assert_eq!(last_position.end, 30); // 20 + 10 (end of the previous position) // Test with adjust = false - update_positions(30, 35, &mut dired); + update_positions(&mut dired, 30, 35); let last_position = dired.dired_positions.last().unwrap(); assert_eq!(last_position.start, 30); assert_eq!(last_position.end, 35); } + + #[test] + fn test_calculate_and_update_positions() { + let mut dired = DiredOutput { + dired_positions: vec![ + BytePosition { start: 0, end: 3 }, + BytePosition { start: 4, end: 7 }, + BytePosition { start: 8, end: 11 }, + ], + subdired_positions: vec![], + padding: 5, + }; + let output_display_len = 15; + let dfn_len = 5; + calculate_and_update_positions(&mut dired, output_display_len, dfn_len); + assert_eq!( + dired.dired_positions, + vec![ + BytePosition { start: 0, end: 3 }, + BytePosition { start: 4, end: 7 }, + BytePosition { start: 8, end: 11 }, + BytePosition { start: 32, end: 37 }, + ] + ); + assert_eq!(dired.padding, 0); + } } diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 50fbe0c7c..41d2f59b1 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1856,6 +1856,10 @@ impl PathData { } } +fn show_dir_name(dir: &Path, out: &mut BufWriter) { + write!(out, "{}:", dir.display()).unwrap(); +} + #[allow(clippy::cognitive_complexity)] pub fn list(locs: Vec<&Path>, config: &Config) -> UResult<()> { let mut files = Vec::::new(); @@ -1922,10 +1926,17 @@ pub fn list(locs: Vec<&Path>, config: &Config) -> UResult<()> { } writeln!(out, "{}:", path_data.p_buf.display())?; if config.dired { - dired::calculate_subdired(&mut dired, path_data.display_name.len()); + // First directory displayed + let dir_len = path_data.display_name.len(); + // add the //SUBDIRED// coordinates + dired::calculate_subdired(&mut dired, dir_len); + // Add the padding for the dir name + dired::add_dir_name(&mut dired, dir_len); } } else { - writeln!(out, "\n{}:", path_data.p_buf.display())?; + writeln!(out)?; + show_dir_name(&path_data.p_buf, &mut out); + writeln!(out)?; } } let mut listed_ancestors = HashSet::new(); @@ -2104,7 +2115,7 @@ fn enter_directory( let total = return_total(&entries, config, out)?; write!(out, "{}", total.as_str())?; if config.dired { - dired::add_total(total.len(), dired); + dired::add_total(dired, total.len()); } } @@ -2132,7 +2143,23 @@ fn enter_directory( if listed_ancestors .insert(FileInformation::from_path(&e.p_buf, e.must_dereference)?) { - writeln!(out, "\n{}:", e.p_buf.display())?; + // when listing several directories in recursive mode, we show + // "dirname:" at the beginning of the file list + writeln!(out)?; + if config.dired { + // We already injected the first dir + // Continue with the others + // 2 = \n + \n + dired.padding = 2; + dired::indent(out)?; + let dir_name_size = e.p_buf.to_string_lossy().len(); + dired::calculate_subdired(dired, dir_name_size); + // inject dir name + dired::add_dir_name(dired, dir_name_size); + } + + show_dir_name(&e.p_buf, out); + writeln!(out)?; enter_directory(e, rd, config, out, listed_ancestors, dired)?; listed_ancestors .remove(&FileInformation::from_path(&e.p_buf, e.must_dereference)?); @@ -2547,11 +2574,11 @@ fn display_item_long( let displayed_file = display_file_name(item, config, None, String::new(), out).contents; if config.dired { let (start, end) = dired::calculate_dired( + &dired.dired_positions, output_display.len(), displayed_file.len(), - &dired.dired_positions, ); - dired::update_positions(start, end, dired); + dired::update_positions(dired, start, end); } write!(output_display, "{}{}", displayed_file, config.line_ending).unwrap(); } else { @@ -2639,9 +2666,9 @@ fn display_item_long( if config.dired { dired::calculate_and_update_positions( + dired, output_display.len(), displayed_file.trim().len(), - dired, ); } write!(output_display, "{}{}", displayed_file, config.line_ending).unwrap(); diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 8b0032065..15893b0e2 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -3580,6 +3580,57 @@ fn test_ls_dired_recursive() { .stdout_contains("//DIRED-OPTIONS// --quoting-style"); } +#[test] +fn test_ls_dired_recursive_multiple() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + at.mkdir("d"); + at.mkdir("d/d1"); + at.mkdir("d/d2"); + at.touch("d/d2/a"); + at.touch("d/d2/c2"); + at.touch("d/d1/f1"); + at.touch("d/d1/file-long"); + + let mut cmd = scene.ucmd(); + cmd.arg("--dired").arg("-l").arg("-R").arg("d"); + + let result = cmd.succeeds(); + + let output = result.stdout_str().to_string(); + println!("Output:\n{}", output); + + let dired_line = output + .lines() + .find(|&line| line.starts_with("//DIRED//")) + .unwrap(); + let positions: Vec = dired_line + .split_whitespace() + .skip(1) + .map(|s| s.parse().unwrap()) + .collect(); + println!("Parsed byte positions: {:?}", positions); + assert_eq!(positions.len() % 2, 0); // Ensure there's an even number of positions + + let filenames: Vec = positions + .chunks(2) + .map(|chunk| { + let start_pos = chunk[0]; + let end_pos = chunk[1]; + let filename = String::from_utf8(output.as_bytes()[start_pos..=end_pos].to_vec()) + .unwrap() + .trim() + .to_string(); + println!("Extracted filename: {}", filename); + filename + }) + .collect(); + + println!("Extracted filenames: {:?}", filenames); + assert_eq!(filenames, vec!["d1", "d2", "f1", "file-long", "a", "c2"]); +} + #[test] fn test_ls_dired_simple() { let scene = TestScenario::new(util_name!()); @@ -3679,6 +3730,57 @@ fn test_ls_dired_complex() { assert_eq!(filenames, vec!["a1", "a22", "a333", "a4444", "d"]); } +#[test] +fn test_ls_subdired_complex() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + + at.mkdir("dir1"); + at.mkdir("dir1/d"); + at.mkdir("dir1/c2"); + at.touch("dir1/a1"); + at.touch("dir1/a22"); + at.touch("dir1/a333"); + at.touch("dir1/c2/a4444"); + + let mut cmd = scene.ucmd(); + cmd.arg("--dired").arg("-l").arg("-R").arg("dir1"); + let result = cmd.succeeds(); + + let output = result.stdout_str().to_string(); + println!("Output:\n{}", output); + + let dired_line = output + .lines() + .find(|&line| line.starts_with("//SUBDIRED//")) + .unwrap(); + let positions: Vec = dired_line + .split_whitespace() + .skip(1) + .map(|s| s.parse().unwrap()) + .collect(); + println!("Parsed byte positions: {:?}", positions); + assert_eq!(positions.len() % 2, 0); // Ensure there's an even number of positions + + let dirnames: Vec = positions + .chunks(2) + .map(|chunk| { + let start_pos = chunk[0]; + let end_pos = chunk[1]; + let dirname = + String::from_utf8(output.as_bytes()[start_pos..end_pos].to_vec()).unwrap(); + println!("Extracted dirname: {}", dirname); + dirname + }) + .collect(); + + println!("Extracted dirnames: {:?}", dirnames); + #[cfg(unix)] + assert_eq!(dirnames, vec!["dir1", "dir1/c2", "dir1/d"]); + #[cfg(windows)] + assert_eq!(dirnames, vec!["dir1", "dir1\\c2", "dir1\\d"]); +} + #[ignore = "issue #5396"] #[test] fn test_ls_cf_output_should_be_delimited_by_tab() { From 1562ef52e8d1edec352230dc0b3930b9c2222e8a Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 19 Oct 2023 07:15:05 +0200 Subject: [PATCH 344/370] Bump rustix crates 0.36.15 -> 0.36.16 0.37.23 -> 0.37.26 0.38.8 -> 0.38.20 --- Cargo.lock | 26 +++++++++++++------------- deny.toml | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dfa22ad27..6c6926db9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1223,9 +1223,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" [[package]] name = "lock_api" @@ -1614,7 +1614,7 @@ dependencies = [ "byteorder", "hex", "lazy_static", - "rustix 0.36.15", + "rustix 0.36.16", ] [[package]] @@ -1832,9 +1832,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.15" +version = "0.36.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" +checksum = "6da3636faa25820d8648e0e31c5d519bbb01f72fdf57131f0f5f7da5fed36eab" dependencies = [ "bitflags 1.3.2", "errno", @@ -1846,9 +1846,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.23" +version = "0.37.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" +checksum = "84f3f8f960ed3b5a59055428714943298bf3fa2d4a1d53135084e0544829d995" dependencies = [ "bitflags 1.3.2", "errno", @@ -1860,14 +1860,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.8" +version = "0.38.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" dependencies = [ "bitflags 2.4.0", "errno", "libc", - "linux-raw-sys 0.4.5", + "linux-raw-sys 0.4.10", "windows-sys 0.48.0", ] @@ -2081,7 +2081,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.38.8", + "rustix 0.38.20", "windows-sys 0.48.0", ] @@ -2091,7 +2091,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" dependencies = [ - "rustix 0.37.23", + "rustix 0.37.26", "windows-sys 0.48.0", ] @@ -2101,7 +2101,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.38.8", + "rustix 0.38.20", "windows-sys 0.48.0", ] diff --git a/deny.toml b/deny.toml index b1707d035..fa8f77c01 100644 --- a/deny.toml +++ b/deny.toml @@ -59,12 +59,12 @@ highlight = "all" # spell-checker: disable skip = [ # procfs - { name = "rustix", version = "0.36.15" }, + { name = "rustix", version = "0.36.16" }, # rustix { name = "linux-raw-sys", version = "0.1.4" }, { name = "linux-raw-sys", version = "0.3.8" }, # terminal_size - { name = "rustix", version = "0.37.23" }, + { name = "rustix", version = "0.37.26" }, # various crates { name = "windows-sys", version = "0.45.0" }, # windows-sys From eede467e21d54eeaa0f8147375a4f83d68b1b40d Mon Sep 17 00:00:00 2001 From: Yury Zhytkou <54360928+zhitkoff@users.noreply.github.com> Date: Fri, 20 Oct 2023 02:47:32 -0400 Subject: [PATCH 345/370] `split` : `--filter` and stdin updates (#5418) --- src/uu/split/src/split.rs | 229 +++++++++++++++++++++++++++--------- tests/by-util/test_split.rs | 48 ++++++++ 2 files changed, 220 insertions(+), 57 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index cff8a4a4c..71b6f34dc 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -748,6 +748,12 @@ enum SettingsError { /// Multiple different separator characters MultipleSeparatorCharacters, + /// Using `--filter` with `--number` option sub-strategies that print Kth chunk out of N chunks to stdout + /// K/N + /// l/K/N + /// r/K/N + FilterWithKthChunkNumber, + /// The `--filter` option is not supported on Windows. #[cfg(windows)] NotSupported, @@ -780,6 +786,9 @@ impl fmt::Display for SettingsError { "invalid suffix {}, contains directory separator", s.quote() ), + Self::FilterWithKthChunkNumber => { + write!(f, "--filter does not process a chunk extracted to stdout") + } #[cfg(windows)] Self::NotSupported => write!( f, @@ -850,12 +859,26 @@ impl Settings { filter: matches.get_one::(OPT_FILTER).map(|s| s.to_owned()), elide_empty_files: matches.get_flag(OPT_ELIDE_EMPTY_FILES), }; + #[cfg(windows)] if result.filter.is_some() { // see https://github.com/rust-lang/rust/issues/29494 return Err(SettingsError::NotSupported); } + // Return an error if `--filter` option is used with any of the + // Kth chunk sub-strategies of `--number` option + // As those are writing to stdout of `split` and cannot write to filter command child process + let kth_chunk = matches!( + result.strategy, + Strategy::Number(NumberType::KthBytes(_, _)) + | Strategy::Number(NumberType::KthLines(_, _)) + | Strategy::Number(NumberType::KthRoundRobin(_, _)) + ); + if kth_chunk && result.filter.is_some() { + return Err(SettingsError::FilterWithKthChunkNumber); + } + Ok(result) } @@ -871,6 +894,47 @@ impl Settings { } } +/// When using `--filter` option, writing to child command process stdin +/// could fail with BrokenPipe error +/// It can be safely ignored +fn ignorable_io_error(error: &std::io::Error, settings: &Settings) -> bool { + error.kind() == ErrorKind::BrokenPipe && settings.filter.is_some() +} + +/// Custom wrapper for `write()` method +/// Follows similar approach to GNU implementation +/// If ignorable io error occurs, return number of bytes as if all bytes written +/// Should not be used for Kth chunk number sub-strategies +/// as those do not work with `--filter` option +fn custom_write( + bytes: &[u8], + writer: &mut T, + settings: &Settings, +) -> std::io::Result { + match writer.write(bytes) { + Ok(n) => Ok(n), + Err(e) if ignorable_io_error(&e, settings) => Ok(bytes.len()), + Err(e) => Err(e), + } +} + +/// Custom wrapper for `write_all()` method +/// Similar to [`custom_write`], but returns true or false +/// depending on if `--filter` stdin is still open (no BrokenPipe error) +/// Should not be used for Kth chunk number sub-strategies +/// as those do not work with `--filter` option +fn custom_write_all( + bytes: &[u8], + writer: &mut T, + settings: &Settings, +) -> std::io::Result { + match writer.write_all(bytes) { + Ok(()) => Ok(true), + Err(e) if ignorable_io_error(&e, settings) => Ok(false), + Err(e) => Err(e), + } +} + /// Write a certain number of bytes to one file, then move on to another one. /// /// This struct maintains an underlying writer representing the @@ -935,6 +999,7 @@ impl<'a> ByteChunkWriter<'a> { } impl<'a> Write for ByteChunkWriter<'a> { + /// Implements `--bytes=SIZE` fn write(&mut self, mut buf: &[u8]) -> std::io::Result { // If the length of `buf` exceeds the number of bytes remaining // in the current chunk, we will need to write to multiple @@ -966,9 +1031,9 @@ impl<'a> Write for ByteChunkWriter<'a> { // bytes in `buf`, then write all the bytes in `buf`. Otherwise, // write enough bytes to fill the current chunk, then increment // the chunk number and repeat. - let n = buf.len(); - if (n as u64) < self.num_bytes_remaining_in_current_chunk { - let num_bytes_written = self.inner.write(buf)?; + let buf_len = buf.len(); + if (buf_len as u64) < self.num_bytes_remaining_in_current_chunk { + let num_bytes_written = custom_write(buf, &mut self.inner, self.settings)?; self.num_bytes_remaining_in_current_chunk -= num_bytes_written as u64; return Ok(carryover_bytes_written + num_bytes_written); } else { @@ -978,7 +1043,7 @@ impl<'a> Write for ByteChunkWriter<'a> { // self.num_bytes_remaining_in_current_chunk is lower than // n, which is already usize. let i = self.num_bytes_remaining_in_current_chunk as usize; - let num_bytes_written = self.inner.write(&buf[..i])?; + let num_bytes_written = custom_write(&buf[..i], &mut self.inner, self.settings)?; self.num_bytes_remaining_in_current_chunk -= num_bytes_written as u64; // It's possible that the underlying writer did not @@ -1064,6 +1129,7 @@ impl<'a> LineChunkWriter<'a> { } impl<'a> Write for LineChunkWriter<'a> { + /// Implements `--lines=NUMBER` fn write(&mut self, buf: &[u8]) -> std::io::Result { // If the number of lines in `buf` exceeds the number of lines // remaining in the current chunk, we will need to write to @@ -1092,14 +1158,16 @@ impl<'a> Write for LineChunkWriter<'a> { // Write the line, starting from *after* the previous // separator character and ending *after* the current // separator character. - let n = self.inner.write(&buf[prev..i + 1])?; - total_bytes_written += n; + let num_bytes_written = + custom_write(&buf[prev..i + 1], &mut self.inner, self.settings)?; + total_bytes_written += num_bytes_written; prev = i + 1; self.num_lines_remaining_in_current_chunk -= 1; } - let n = self.inner.write(&buf[prev..buf.len()])?; - total_bytes_written += n; + let num_bytes_written = + custom_write(&buf[prev..buf.len()], &mut self.inner, self.settings)?; + total_bytes_written += num_bytes_written; Ok(total_bytes_written) } @@ -1196,6 +1264,8 @@ impl<'a> Write for LineBytesChunkWriter<'a> { /// |------| |-------| |--------| |---| /// aaaaaaaa a\nbbbb\n cccc\ndd\n ee\n /// ``` + /// + /// Implements `--line-bytes=SIZE` fn write(&mut self, mut buf: &[u8]) -> std::io::Result { // The total number of bytes written during the loop below. // @@ -1248,7 +1318,11 @@ impl<'a> Write for LineBytesChunkWriter<'a> { { self.num_bytes_remaining_in_current_chunk = 0; } else { - let num_bytes_written = self.inner.write(&buf[..end.min(buf.len())])?; + let num_bytes_written = custom_write( + &buf[..end.min(buf.len())], + &mut self.inner, + self.settings, + )?; self.num_bytes_remaining_in_current_chunk -= num_bytes_written; total_bytes_written += num_bytes_written; buf = &buf[num_bytes_written..]; @@ -1261,7 +1335,8 @@ impl<'a> Write for LineBytesChunkWriter<'a> { // continue to the next iteration. (See chunk 1 in the // example comment above.) Some(i) if i < self.num_bytes_remaining_in_current_chunk => { - let num_bytes_written = self.inner.write(&buf[..i + 1])?; + let num_bytes_written = + custom_write(&buf[..i + 1], &mut self.inner, self.settings)?; self.num_bytes_remaining_in_current_chunk -= num_bytes_written; total_bytes_written += num_bytes_written; buf = &buf[num_bytes_written..]; @@ -1279,7 +1354,8 @@ impl<'a> Write for LineBytesChunkWriter<'a> { == self.chunk_size.try_into().unwrap() => { let end = self.num_bytes_remaining_in_current_chunk; - let num_bytes_written = self.inner.write(&buf[..end])?; + let num_bytes_written = + custom_write(&buf[..end], &mut self.inner, self.settings)?; self.num_bytes_remaining_in_current_chunk -= num_bytes_written; total_bytes_written += num_bytes_written; buf = &buf[num_bytes_written..]; @@ -1315,6 +1391,10 @@ impl<'a> Write for LineBytesChunkWriter<'a> { /// /// This function returns an error if there is a problem reading from /// `reader` or writing to one of the output files. +/// +/// Implements `--number=CHUNKS` +/// Where CHUNKS +/// * N fn split_into_n_chunks_by_byte( settings: &Settings, reader: &mut R, @@ -1378,29 +1458,26 @@ where writers.push(writer); } - // 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. - // - // The last writer gets all remaining bytes so that if the number - // of bytes in the input file was not evenly divisible by - // `num_chunks`, we don't leave any bytes behind. - for writer in writers.iter_mut().take(num_chunks - 1) { - io::copy(&mut reader.by_ref().take(chunk_size), writer)?; - } + // Write `chunk_size` bytes from the reader into each writer + // except the last. + // + // The last writer gets all remaining bytes so that if the number + // of bytes in the input file was not evenly divisible by + // `num_chunks`, we don't leave any bytes behind. + for writer in writers.iter_mut().take(num_chunks - 1) { + match io::copy(&mut reader.by_ref().take(chunk_size), writer) { + Ok(_) => continue, + Err(e) if ignorable_io_error(&e, settings) => continue, + Err(e) => return Err(uio_error!(e, "input/output error")), + }; + } - // Write all the remaining bytes to the last chunk. - let i = num_chunks - 1; - let last_chunk_size = num_bytes - (chunk_size * (num_chunks as u64 - 1)); - io::copy(&mut reader.by_ref().take(last_chunk_size), &mut writers[i])?; - - Ok(()) - }; - match result { + // Write all the remaining bytes to the last chunk. + let i = num_chunks - 1; + let last_chunk_size = num_bytes - (chunk_size * (num_chunks as u64 - 1)); + match io::copy(&mut reader.by_ref().take(last_chunk_size), &mut writers[i]) { Ok(_) => Ok(()), - Err(e) if e.kind() == ErrorKind::BrokenPipe => Ok(()), + Err(e) if ignorable_io_error(&e, settings) => Ok(()), Err(e) => Err(uio_error!(e, "input/output error")), } } @@ -1415,6 +1492,10 @@ where /// /// This function returns an error if there is a problem reading from /// `reader` or writing to stdout. +/// +/// Implements `--number=CHUNKS` +/// Where CHUNKS +/// * K/N fn kth_chunks_by_byte( settings: &Settings, reader: &mut R, @@ -1508,6 +1589,10 @@ where /// /// * [`kth_chunk_by_line`], which splits its input in the same way, /// but writes only one specified chunk to stdout. +/// +/// Implements `--number=CHUNKS` +/// Where CHUNKS +/// * l/N fn split_into_n_chunks_by_line( settings: &Settings, reader: &mut R, @@ -1518,7 +1603,9 @@ where { // Get the size of the input file in bytes and compute the number // of bytes per chunk. - let metadata = metadata(&settings.input).unwrap(); + let metadata = metadata(&settings.input).map_err(|_| { + USimpleError::new(1, format!("{}: cannot determine file size", settings.input)) + })?; let num_bytes = metadata.len(); let chunk_size = (num_bytes / num_chunks) as usize; @@ -1550,8 +1637,8 @@ where let maybe_writer = writers.get_mut(i); let writer = maybe_writer.unwrap(); let bytes = line.as_slice(); - writer.write_all(bytes)?; - writer.write_all(&[sep])?; + custom_write_all(bytes, writer, settings)?; + custom_write_all(&[sep], writer, settings)?; // Add one byte for the separator character. let num_bytes = bytes.len() + 1; @@ -1581,6 +1668,10 @@ where /// /// * [`split_into_n_chunks_by_line`], which splits its input in the /// same way, but writes each chunk to its own file. +/// +/// Implements `--number=CHUNKS` +/// Where CHUNKS +/// * l/K/N fn kth_chunk_by_line( settings: &Settings, reader: &mut R, @@ -1592,7 +1683,9 @@ where { // Get the size of the input file in bytes and compute the number // of bytes per chunk. - let metadata = metadata(&settings.input).unwrap(); + let metadata = metadata(&settings.input).map_err(|_| { + USimpleError::new(1, format!("{}: cannot determine file size", settings.input)) + })?; let num_bytes = metadata.len(); let chunk_size = (num_bytes / num_chunks) as usize; @@ -1601,7 +1694,7 @@ where let mut writer = stdout.lock(); let mut num_bytes_remaining_in_current_chunk = chunk_size; - let mut i = 0; + let mut i = 1; let sep = settings.separator; for line_result in reader.split(sep) { let line = line_result?; @@ -1628,11 +1721,32 @@ where Ok(()) } +/// Split a file into a specific number of chunks by line, but +/// assign lines via round-robin +/// +/// This function always creates one output file for each chunk, even +/// if there is an error reading or writing one of the chunks or if +/// the input file is truncated. However, if the `filter` option is +/// being used, then no files are created. +/// +/// # Errors +/// +/// This function returns an error if there is a problem reading from +/// `reader` or writing to one of the output files. +/// +/// # See also +/// +/// * [`split_into_n_chunks_by_line`], which splits its input in the same way, +/// but without round robin distribution. +/// +/// Implements `--number=CHUNKS` +/// Where CHUNKS +/// * r/N fn split_into_n_chunks_by_line_round_robin( settings: &Settings, reader: &mut R, num_chunks: u64, -) -> std::io::Result<()> +) -> UResult<()> where R: BufRead, { @@ -1659,13 +1773,21 @@ where let num_chunks: usize = num_chunks.try_into().unwrap(); let sep = settings.separator; + let mut closed_writers = 0; for (i, line_result) in reader.split(sep).enumerate() { - let line = line_result.unwrap(); let maybe_writer = writers.get_mut(i % num_chunks); let writer = maybe_writer.unwrap(); + let mut line = line_result.unwrap(); + line.push(sep); let bytes = line.as_slice(); - writer.write_all(bytes)?; - writer.write_all(&[sep])?; + let writer_stdin_open = custom_write_all(bytes, writer, settings)?; + if !writer_stdin_open { + closed_writers += 1; + if closed_writers == num_chunks { + // all writers are closed - stop reading + break; + } + } } Ok(()) @@ -1689,6 +1811,10 @@ where /// /// * [`split_into_n_chunks_by_line_round_robin`], which splits its input in the /// same way, but writes each chunk to its own file. +/// +/// Implements `--number=CHUNKS` +/// Where CHUNKS +/// * r/K/N fn kth_chunk_by_line_round_robin( settings: &Settings, reader: &mut R, @@ -1705,6 +1831,10 @@ where let num_chunks: usize = num_chunks.try_into().unwrap(); let chunk_number: usize = chunk_number.try_into().unwrap(); let sep = settings.separator; + // The chunk number is given as a 1-indexed number, but it + // is a little easier to deal with a 0-indexed number + // since `.enumerate()` returns index `i` starting with 0 + let chunk_number = chunk_number - 1; for (i, line_result) in reader.split(sep).enumerate() { let line = line_result?; let bytes = line.as_slice(); @@ -1741,24 +1871,12 @@ fn split(settings: &Settings) -> UResult<()> { split_into_n_chunks_by_line(settings, &mut reader, num_chunks) } Strategy::Number(NumberType::KthLines(chunk_number, num_chunks)) => { - // The chunk number is given as a 1-indexed number, but it - // is a little easier to deal with a 0-indexed number. - let chunk_number = chunk_number - 1; kth_chunk_by_line(settings, &mut reader, chunk_number, num_chunks) } Strategy::Number(NumberType::RoundRobin(num_chunks)) => { - match split_into_n_chunks_by_line_round_robin(settings, &mut reader, num_chunks) { - Ok(_) => Ok(()), - Err(e) => match e.kind() { - ErrorKind::BrokenPipe => Ok(()), - _ => Err(USimpleError::new(1, format!("{e}"))), - }, - } + split_into_n_chunks_by_line_round_robin(settings, &mut reader, num_chunks) } Strategy::Number(NumberType::KthRoundRobin(chunk_number, num_chunks)) => { - // The chunk number is given as a 1-indexed number, but it - // is a little easier to deal with a 0-indexed number. - let chunk_number = chunk_number - 1; kth_chunk_by_line_round_robin(settings, &mut reader, chunk_number, num_chunks) } Strategy::Lines(chunk_size) => { @@ -1775,7 +1893,6 @@ fn split(settings: &Settings) -> UResult<()> { // indicate that. A special error message needs to be // printed in that case. ErrorKind::Other => Err(USimpleError::new(1, format!("{e}"))), - ErrorKind::BrokenPipe => Ok(()), _ => Err(uio_error!(e, "input/output error")), }, } @@ -1794,7 +1911,6 @@ fn split(settings: &Settings) -> UResult<()> { // indicate that. A special error message needs to be // printed in that case. ErrorKind::Other => Err(USimpleError::new(1, format!("{e}"))), - ErrorKind::BrokenPipe => Ok(()), _ => Err(uio_error!(e, "input/output error")), }, } @@ -1813,7 +1929,6 @@ fn split(settings: &Settings) -> UResult<()> { // indicate that. A special error message needs to be // printed in that case. ErrorKind::Other => Err(USimpleError::new(1, format!("{e}"))), - ErrorKind::BrokenPipe => Ok(()), _ => Err(uio_error!(e, "input/output error")), }, } diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index be3933df3..5760be560 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -338,6 +338,36 @@ fn test_filter_broken_pipe() { .succeeds(); } +#[test] +#[cfg(unix)] +fn test_filter_with_kth_chunk() { + let scene = TestScenario::new(util_name!()); + scene + .ucmd() + .args(&["--filter='some'", "--number=1/2"]) + .ignore_stdin_write_error() + .pipe_in("a\n") + .fails() + .no_stdout() + .stderr_contains("--filter does not process a chunk extracted to stdout"); + scene + .ucmd() + .args(&["--filter='some'", "--number=l/1/2"]) + .ignore_stdin_write_error() + .pipe_in("a\n") + .fails() + .no_stdout() + .stderr_contains("--filter does not process a chunk extracted to stdout"); + scene + .ucmd() + .args(&["--filter='some'", "--number=r/1/2"]) + .ignore_stdin_write_error() + .pipe_in("a\n") + .fails() + .no_stdout() + .stderr_contains("--filter does not process a chunk extracted to stdout"); +} + #[test] fn test_split_lines_number() { // Test if stdout/stderr for '--lines' option is correct @@ -699,6 +729,24 @@ fn test_split_stdin_num_kth_chunk() { .stderr_only("split: -: cannot determine file size\n"); } +#[test] +fn test_split_stdin_num_line_chunks() { + new_ucmd!() + .args(&["--number=l/2"]) + .fails() + .code_is(1) + .stderr_only("split: -: cannot determine file size\n"); +} + +#[test] +fn test_split_stdin_num_kth_line_chunk() { + new_ucmd!() + .args(&["--number=l/2/5"]) + .fails() + .code_is(1) + .stderr_only("split: -: cannot determine file size\n"); +} + fn file_read(at: &AtPath, filename: &str) -> String { let mut s = String::new(); at.open(filename).read_to_string(&mut s).unwrap(); From 772892e2e4dbbf22e88e5d4ca86d4560fefbc9c1 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 19 Oct 2023 17:05:29 +0200 Subject: [PATCH 346/370] cp: --rem don't fail if dest is symlink to source --- src/uu/cp/src/cp.rs | 8 ++++++++ tests/by-util/test_cp.rs | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index f9f6d8763..da9918365 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1647,6 +1647,14 @@ fn copy_file( dest.display() ))); } + if paths_refer_to_same_file(source, dest, true) + && matches!( + options.overwrite, + OverwriteMode::Clobber(ClobberMode::RemoveDestination) + ) + { + fs::remove_file(dest)?; + } } if file_or_link_exists(dest) { diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 9894087e8..b3cc3e0c1 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -2827,6 +2827,22 @@ fn test_cp_mode_hardlink_no_dereference() { assert_eq!(at.read_symlink("z"), "slink"); } +#[test] +fn test_remove_destination_with_destination_being_a_symlink_to_source() { + let (at, mut ucmd) = at_and_ucmd!(); + let file = "file"; + let symlink = "symlink"; + + at.touch(file); + at.symlink_file(file, symlink); + + ucmd.args(&["--remove-destination", file, symlink]) + .succeeds(); + assert!(!at.symlink_exists(symlink)); + assert!(at.file_exists(file)); + assert!(at.file_exists(symlink)); +} + #[test] fn test_remove_destination_symbolic_link_loop() { let (at, mut ucmd) = at_and_ucmd!(); From 4472acf909b8d4598aefffb15ef440186698ebb5 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 1 Oct 2023 22:19:48 +0200 Subject: [PATCH 347/370] ls --dired: document the whole thing --- src/uu/ls/src/dired.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/uu/ls/src/dired.rs b/src/uu/ls/src/dired.rs index 74732d37a..c73b11ae3 100644 --- a/src/uu/ls/src/dired.rs +++ b/src/uu/ls/src/dired.rs @@ -4,6 +4,36 @@ // file that was distributed with this source code. // spell-checker:ignore dired subdired +/// `dired` Module Documentation +/// +/// This module handles the --dired output format, representing file and +/// directory listings. +/// +/// Key Mechanisms: +/// 1. **Position Tracking**: +/// - The module tracks byte positions for each file or directory entry. +/// - `BytePosition`: Represents a byte range with start and end positions. +/// - `DiredOutput`: Contains positions for DIRED and SUBDIRED outputs and +/// maintains a padding value. +/// +/// 2. **Padding**: +/// - Padding is used when dealing with directory names or the "total" line. +/// - The module adjusts byte positions by adding padding for these cases. +/// - This ensures correct offset for subsequent files or directories. +/// +/// 3. **Position Calculation**: +/// - Functions like `calculate_dired`, `calculate_subdired`, and +/// `calculate_and_update_positions` compute byte positions based on output +/// length, previous positions, and padding. +/// +/// 4. **Output**: +/// - The module provides functions to print the DIRED output +/// (`print_dired_output`) based on calculated positions and configuration. +/// - Helpers like `print_positions` print positions with specific prefixes. +/// +/// Overall, the module ensures each entry in the DIRED output has the correct +/// byte position, considering additional lines or padding affecting positions. +/// use crate::Config; use std::fmt; use std::io::{BufWriter, Stdout, Write}; From fa265b0520f735bf4cb5e80c01dfa8626901e092 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 22 Oct 2023 10:47:17 +0200 Subject: [PATCH 348/370] rm: adjust fail-2eperm.sh - gnu test --- util/build-gnu.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index e2c675394..697c8c537 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -189,6 +189,8 @@ grep -rlE '/usr/local/bin/\s?/usr/local/bin' init.cfg tests/* | xargs --no-run-i sed -i -e "s|rm: cannot remove 'e/slink'|rm: cannot remove 'e'|g" tests/rm/fail-eacces.sh +sed -i -e "s|rm: cannot remove 'a/b'|rm: cannot remove 'a'|g" tests/rm/fail-2eperm.sh + sed -i -e "s|rm: cannot remove 'a/b/file'|rm: cannot remove 'a'|g" tests/rm/cycle.sh sed -i -e "s|rm: cannot remove directory 'b/a/p'|rm: cannot remove 'b'|g" tests/rm/rm1.sh From e3e0619e28b8a949c86c4ae7002a98d618752f7a Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 22 Oct 2023 17:04:34 +0200 Subject: [PATCH 349/370] doc: mention "-v/--verbose" as extension of du --- docs/src/extensions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/extensions.md b/docs/src/extensions.md index eeb00ff35..79746498f 100644 --- a/docs/src/extensions.md +++ b/docs/src/extensions.md @@ -77,4 +77,5 @@ third way: `--long`. ## `du` -`du` allows `birth` and `creation` as values for the `--time` argument to show the creation time. +`du` allows `birth` and `creation` as values for the `--time` argument to show the creation time. It +also provides a `-v`/`--verbose` flag. From 897af02d9da7a3d80e4b118537bda81c94783451 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 22 Oct 2023 21:43:46 +0200 Subject: [PATCH 350/370] runcon: generate the same error as GNUs tested in tests/runcon/runcon-no-reorder.sh --- src/uu/runcon/src/errors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/runcon/src/errors.rs b/src/uu/runcon/src/errors.rs index 5b6282940..382ab3bed 100644 --- a/src/uu/runcon/src/errors.rs +++ b/src/uu/runcon/src/errors.rs @@ -26,7 +26,7 @@ pub(crate) enum Error { #[error("No command is specified")] MissingCommand, - #[error("SELinux is not enabled")] + #[error("runcon may be used only on a SELinux kernel")] SELinuxNotEnabled, #[error(transparent)] From 43f14e4126414486798566fb3d32e3ee31374bbe Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 22 Oct 2023 22:11:34 +0200 Subject: [PATCH 351/370] pr: skip a test for now for way too long log --- util/build-gnu.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 697c8c537..35e6d5b6b 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -208,6 +208,10 @@ sed -i -e "s|---dis ||g" tests/tail/overlay-headers.sh test -f "${UU_BUILD_DIR}/getlimits" || cp src/getlimits "${UU_BUILD_DIR}" +# pr produces very long log and this command isn't super interesting +# SKIP for now +sed -i -e "s|my \$prog = 'pr';$|my \$prog = 'pr';CuSkip::skip \"\$prog: SKIP for producing too long logs\";|" tests/pr/pr-tests.pl + # When decoding an invalid base32/64 string, gnu writes everything it was able to decode until # it hit the decode error, while we don't write anything if the input is invalid. sed -i "s/\(baddecode.*OUT=>\"\).*\"/\1\"/g" tests/misc/base64.pl From dbfd700502cdd0beac32e7ab3cb9397c9f4d6b99 Mon Sep 17 00:00:00 2001 From: Nathan Houghton Date: Sun, 22 Oct 2023 10:51:15 -0700 Subject: [PATCH 352/370] test: use mtime for -ot and fix direction of comparison - Use the file modification time instead of the creation time (matches GNU coreutils documentation) - Fix direction of comparison (a < b instead of a > b) - Extend test case to cover both the 0 and 1 exit code cases --- src/uu/test/src/test.rs | 2 +- tests/by-util/test_test.rs | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/uu/test/src/test.rs b/src/uu/test/src/test.rs index 7e778f9b5..4f230a590 100644 --- a/src/uu/test/src/test.rs +++ b/src/uu/test/src/test.rs @@ -218,7 +218,7 @@ fn files(a: &OsStr, b: &OsStr, op: &OsStr) -> ParseResult { #[cfg(not(unix))] Some("-ef") => unimplemented!(), Some("-nt") => f_a.modified().unwrap() > f_b.modified().unwrap(), - Some("-ot") => f_a.created().unwrap() > f_b.created().unwrap(), + Some("-ot") => f_a.modified().unwrap() < f_b.modified().unwrap(), _ => return Err(ParseError::UnknownOperator(op.quote().to_string())), }) } diff --git a/tests/by-util/test_test.rs b/tests/by-util/test_test.rs index 2f36a805c..922d854c6 100644 --- a/tests/by-util/test_test.rs +++ b/tests/by-util/test_test.rs @@ -317,7 +317,7 @@ fn test_file_is_itself() { } #[test] -#[cfg(not(any(target_env = "musl", target_os = "android")))] +#[cfg(not(target_os = "android"))] fn test_file_is_newer_than_and_older_than_itself() { // odd but matches GNU new_ucmd!() @@ -364,8 +364,7 @@ fn test_same_device_inode() { } #[test] -#[cfg(not(any(target_env = "musl", target_os = "android")))] -// musl: creation time is not available on this platform currently +#[cfg(not(target_os = "android"))] fn test_newer_file() { let scenario = TestScenario::new(util_name!()); @@ -377,10 +376,21 @@ fn test_newer_file() { .ucmd() .args(&["newer_file", "-nt", "regular_file"]) .succeeds(); + + scenario + .ucmd() + .args(&["regular_file", "-nt", "newer_file"]) + .fails(); + + scenario + .ucmd() + .args(&["regular_file", "-ot", "newer_file"]) + .succeeds(); + scenario .ucmd() .args(&["newer_file", "-ot", "regular_file"]) - .succeeds(); + .fails(); } #[test] From e6dd1045f05569d4cf29877a61af10f1e3e3a737 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 07:26:01 +0000 Subject: [PATCH 353/370] chore(deps): update rust crate bytecount to 0.6.5 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c6926db9..e42d18a79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,9 +205,9 @@ checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] name = "bytecount" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad152d03a2c813c80bb94fedbf3a3f02b28f793e39e7c214c8a0bcc196343de7" +checksum = "d1a12477b7237a01c11a80a51278165f9ba0edd28fa6db00a65ab230320dc58c" [[package]] name = "byteorder" diff --git a/Cargo.toml b/Cargo.toml index 6b412488c..4dd8b2a19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -260,7 +260,7 @@ test = ["uu_test"] bigdecimal = "0.4" binary-heap-plus = "0.5.0" bstr = "1.7" -bytecount = "0.6.4" +bytecount = "0.6.5" byteorder = "1.5.0" chrono = { version = "^0.4.31", default-features = false, features = [ "std", From 937f29b80734c8dceca19f70dcc74a1082c09948 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 22 Oct 2023 21:26:11 +0200 Subject: [PATCH 354/370] ls: update of the GNU test error output --- util/build-gnu.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 35e6d5b6b..0af07266b 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -272,6 +272,10 @@ sed -i -e "s/du: invalid -t argument/du: invalid --threshold argument/" -e "s/du # with ls --dired, in case of error, we have a slightly different error position sed -i -e "s|44 45|48 49|" tests/ls/stat-failed.sh +# small difference in the error message +sed -i -e "/ls: invalid argument 'XX' for 'time style'/,/Try 'ls --help' for more information\./c\ +ls: invalid --time-style argument 'XX'\nPossible values are: [\"full-iso\", \"long-iso\", \"iso\", \"locale\", \"+FORMAT (e.g., +%H:%M) for a 'date'-style format\"]\n\nFor more information try --help" tests/ls/time-style-diag.sh + # disable two kind of tests: # "hostid BEFORE --help" doesn't fail for GNU. we fail. we are probably doing better # "hostid BEFORE --help AFTER " same for this From a3fed79b5ce384bd0c2b9996d1cc8ed1b52f7e45 Mon Sep 17 00:00:00 2001 From: Yury Zhytkou <54360928+zhitkoff@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:47:39 -0400 Subject: [PATCH 355/370] `split`: suffix auto length (#5433) --- src/uu/split/src/filenames.rs | 42 +++++++---- src/uu/split/src/split.rs | 132 +++++++++++++++++++++++++--------- 2 files changed, 127 insertions(+), 47 deletions(-) diff --git a/src/uu/split/src/filenames.rs b/src/uu/split/src/filenames.rs index 08f08e293..e6a9f19b2 100644 --- a/src/uu/split/src/filenames.rs +++ b/src/uu/split/src/filenames.rs @@ -121,9 +121,10 @@ impl<'a> FilenameIterator<'a> { suffix_length: usize, suffix_type: SuffixType, suffix_start: usize, + suffix_auto_widening: bool, ) -> UResult> { let radix = suffix_type.radix(); - let number = if suffix_length == 0 { + let number = if suffix_auto_widening { Number::DynamicWidth(DynamicWidthNumber::new(radix, suffix_start)) } else { Number::FixedWidth( @@ -171,36 +172,42 @@ mod tests { #[test] fn test_filename_iterator_alphabetic_fixed_width() { - let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Alphabetic, 0).unwrap(); + let mut it = + FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Alphabetic, 0, false).unwrap(); assert_eq!(it.next().unwrap(), "chunk_aa.txt"); assert_eq!(it.next().unwrap(), "chunk_ab.txt"); assert_eq!(it.next().unwrap(), "chunk_ac.txt"); - let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Alphabetic, 0).unwrap(); + let mut it = + FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Alphabetic, 0, false).unwrap(); assert_eq!(it.nth(26 * 26 - 1).unwrap(), "chunk_zz.txt"); assert_eq!(it.next(), None); } #[test] fn test_filename_iterator_numeric_fixed_width() { - let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Decimal, 0).unwrap(); + let mut it = + FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Decimal, 0, false).unwrap(); assert_eq!(it.next().unwrap(), "chunk_00.txt"); assert_eq!(it.next().unwrap(), "chunk_01.txt"); assert_eq!(it.next().unwrap(), "chunk_02.txt"); - let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Decimal, 0).unwrap(); + let mut it = + FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Decimal, 0, false).unwrap(); assert_eq!(it.nth(10 * 10 - 1).unwrap(), "chunk_99.txt"); assert_eq!(it.next(), None); } #[test] fn test_filename_iterator_alphabetic_dynamic_width() { - let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Alphabetic, 0).unwrap(); + let mut it = + FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Alphabetic, 0, true).unwrap(); assert_eq!(it.next().unwrap(), "chunk_aa.txt"); assert_eq!(it.next().unwrap(), "chunk_ab.txt"); assert_eq!(it.next().unwrap(), "chunk_ac.txt"); - let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Alphabetic, 0).unwrap(); + let mut it = + FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Alphabetic, 0, true).unwrap(); assert_eq!(it.nth(26 * 25 - 1).unwrap(), "chunk_yz.txt"); assert_eq!(it.next().unwrap(), "chunk_zaaa.txt"); assert_eq!(it.next().unwrap(), "chunk_zaab.txt"); @@ -208,12 +215,14 @@ mod tests { #[test] fn test_filename_iterator_numeric_dynamic_width() { - let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Decimal, 0).unwrap(); + let mut it = + FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Decimal, 0, true).unwrap(); assert_eq!(it.next().unwrap(), "chunk_00.txt"); assert_eq!(it.next().unwrap(), "chunk_01.txt"); assert_eq!(it.next().unwrap(), "chunk_02.txt"); - let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Decimal, 0).unwrap(); + let mut it = + FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Decimal, 0, true).unwrap(); assert_eq!(it.nth(10 * 9 - 1).unwrap(), "chunk_89.txt"); assert_eq!(it.next().unwrap(), "chunk_9000.txt"); assert_eq!(it.next().unwrap(), "chunk_9001.txt"); @@ -221,7 +230,8 @@ mod tests { #[test] fn test_filename_iterator_numeric_suffix_decimal() { - let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Decimal, 5).unwrap(); + let mut it = + FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Decimal, 5, true).unwrap(); assert_eq!(it.next().unwrap(), "chunk_05.txt"); assert_eq!(it.next().unwrap(), "chunk_06.txt"); assert_eq!(it.next().unwrap(), "chunk_07.txt"); @@ -230,7 +240,7 @@ mod tests { #[test] fn test_filename_iterator_numeric_suffix_hex() { let mut it = - FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Hexadecimal, 9).unwrap(); + FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Hexadecimal, 9, true).unwrap(); assert_eq!(it.next().unwrap(), "chunk_09.txt"); assert_eq!(it.next().unwrap(), "chunk_0a.txt"); assert_eq!(it.next().unwrap(), "chunk_0b.txt"); @@ -238,19 +248,21 @@ mod tests { #[test] fn test_filename_iterator_numeric_suffix_err() { - let mut it = FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Decimal, 999).unwrap(); + let mut it = + FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Decimal, 999, false).unwrap(); assert_eq!(it.next().unwrap(), "chunk_999.txt"); assert!(it.next().is_none()); - let it = FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Decimal, 1000); + let it = FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Decimal, 1000, false); assert!(it.is_err()); let mut it = - FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Hexadecimal, 0xfff).unwrap(); + FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Hexadecimal, 0xfff, false) + .unwrap(); assert_eq!(it.next().unwrap(), "chunk_fff.txt"); assert!(it.next().is_none()); - let it = FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Hexadecimal, 0x1000); + let it = FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Hexadecimal, 0x1000, false); assert!(it.is_err()); } } diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 71b6f34dc..fff1ccb65 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -37,7 +37,8 @@ static OPT_NUMERIC_SUFFIXES_SHORT: &str = "-d"; static OPT_HEX_SUFFIXES: &str = "hex-suffixes"; static OPT_HEX_SUFFIXES_SHORT: &str = "-x"; static OPT_SUFFIX_LENGTH: &str = "suffix-length"; -static OPT_DEFAULT_SUFFIX_LENGTH: &str = "0"; +// If no suffix length is specified, default to "2" characters following GNU split behavior +static OPT_DEFAULT_SUFFIX_LENGTH: &str = "2"; static OPT_VERBOSE: &str = "verbose"; static OPT_SEPARATOR: &str = "separator"; //The ---io and ---io-blksize parameters are consumed and ignored. @@ -313,7 +314,6 @@ pub fn uu_app() -> Command { .long(OPT_NUMERIC_SUFFIXES) .alias("numeric") .require_equals(true) - .default_missing_value("0") .num_args(0..=1) .overrides_with_all([ OPT_NUMERIC_SUFFIXES, @@ -340,7 +340,6 @@ pub fn uu_app() -> Command { Arg::new(OPT_HEX_SUFFIXES) .long(OPT_HEX_SUFFIXES) .alias("hex") - .default_missing_value("0") .require_equals(true) .num_args(0..=1) .overrides_with_all([ @@ -359,7 +358,7 @@ pub fn uu_app() -> Command { .allow_hyphen_values(true) .value_name("N") .default_value(OPT_DEFAULT_SUFFIX_LENGTH) - .help("use suffixes of fixed length N. 0 implies dynamic length, starting with 2"), + .help("generate suffixes of length N (default 2)"), ) .arg( Arg::new(OPT_VERBOSE) @@ -669,35 +668,99 @@ impl Strategy { } } -/// Parse the suffix type from the command-line arguments. -fn suffix_type_from(matches: &ArgMatches) -> Result<(SuffixType, usize), SettingsError> { +/// Parse the suffix type, start and length from the command-line arguments. +/// Determine if the output file names suffix is allowed to auto-widen, +/// i.e. go beyond suffix_length, when more output files need to be written into. +/// Suffix auto-widening rules are: +/// - OFF when suffix length N is specified +/// `-a N` or `--suffix-length=N` +/// - OFF when suffix start number N is specified using long option with value +/// `--numeric-suffixes=N` or `--hex-suffixes=N` +/// - Exception to the above: ON with `-n`/`--number` option (N, K/N, l/N, l/K/N, r/N, r/K/N) +/// and suffix start < N number of files +/// - ON when suffix start number is NOT specified +fn suffix_from( + matches: &ArgMatches, + strategy: &Strategy, +) -> Result<(SuffixType, usize, bool, usize), SettingsError> { + let suffix_type: SuffixType; + + // Defaults + let mut suffix_start = 0; + let mut suffix_auto_widening = true; + // Check if the user is specifying one or more than one suffix // Any combination of suffixes is allowed // Since all suffixes are setup with 'overrides_with_all()' against themselves and each other, // last one wins, all others are ignored match ( - matches.get_one::(OPT_NUMERIC_SUFFIXES), - matches.get_one::(OPT_HEX_SUFFIXES), + matches.contains_id(OPT_NUMERIC_SUFFIXES), + matches.contains_id(OPT_HEX_SUFFIXES), matches.get_flag(OPT_NUMERIC_SUFFIXES_SHORT), matches.get_flag(OPT_HEX_SUFFIXES_SHORT), ) { - (Some(v), _, _, _) => { - let suffix_start = v; - let suffix_start = suffix_start - .parse::() - .map_err(|_| SettingsError::SuffixNotParsable(suffix_start.to_string()))?; - Ok((SuffixType::Decimal, suffix_start)) + (true, _, _, _) => { + suffix_type = SuffixType::Decimal; + let suffix_opt = matches.get_one::(OPT_NUMERIC_SUFFIXES); // if option was specified, but without value - this will return None as there is no default value + if suffix_opt.is_some() { + (suffix_start, suffix_auto_widening) = + handle_long_suffix_opt(suffix_opt.unwrap(), strategy, false)?; + } } - (_, Some(v), _, _) => { - let suffix_start = v; - let suffix_start = usize::from_str_radix(suffix_start, 16) - .map_err(|_| SettingsError::SuffixNotParsable(suffix_start.to_string()))?; - Ok((SuffixType::Hexadecimal, suffix_start)) + (_, true, _, _) => { + suffix_type = SuffixType::Hexadecimal; + let suffix_opt = matches.get_one::(OPT_HEX_SUFFIXES); // if option was specified, but without value - this will return None as there is no default value + if suffix_opt.is_some() { + (suffix_start, suffix_auto_widening) = + handle_long_suffix_opt(suffix_opt.unwrap(), strategy, true)?; + } } - (_, _, true, _) => Ok((SuffixType::Decimal, 0)), // short numeric suffix '-d', default start 0 - (_, _, _, true) => Ok((SuffixType::Hexadecimal, 0)), // short hex suffix '-x', default start 0 - _ => Ok((SuffixType::Alphabetic, 0)), // no numeric/hex suffix, using default alphabetic + (_, _, true, _) => suffix_type = SuffixType::Decimal, // short numeric suffix '-d' + (_, _, _, true) => suffix_type = SuffixType::Hexadecimal, // short hex suffix '-x' + _ => suffix_type = SuffixType::Alphabetic, // no numeric/hex suffix, using default alphabetic } + + let suffix_length_str = matches.get_one::(OPT_SUFFIX_LENGTH).unwrap(); // safe to unwrap here as there is default value for this option + let suffix_length: usize = suffix_length_str + .parse() + .map_err(|_| SettingsError::SuffixNotParsable(suffix_length_str.to_string()))?; + + // Override suffix_auto_widening if suffix length value came from command line + // and not from default value + if matches.value_source(OPT_SUFFIX_LENGTH) == Some(ValueSource::CommandLine) { + suffix_auto_widening = false; + } + + Ok(( + suffix_type, + suffix_start, + suffix_auto_widening, + suffix_length, + )) +} + +/// Helper function to [`suffix_from`] function +fn handle_long_suffix_opt( + suffix_opt: &String, + strategy: &Strategy, + is_hex: bool, +) -> Result<(usize, bool), SettingsError> { + let suffix_start = if is_hex { + usize::from_str_radix(suffix_opt, 16) + .map_err(|_| SettingsError::SuffixNotParsable(suffix_opt.to_string()))? + } else { + suffix_opt + .parse::() + .map_err(|_| SettingsError::SuffixNotParsable(suffix_opt.to_string()))? + }; + + let suffix_auto_widening = if let Strategy::Number(ref number_type) = strategy { + let chunks = number_type.num_chunks(); + (suffix_start as u64) < chunks + } else { + false + }; + Ok((suffix_start, suffix_auto_widening)) } /// Parameters that control how a file gets split. @@ -709,6 +772,8 @@ struct Settings { suffix_type: SuffixType, suffix_length: usize, suffix_start: usize, + /// Whether or not suffix length should automatically widen + suffix_auto_widening: bool, additional_suffix: String, input: String, /// When supplied, a shell command to output to instead of xaa, xab … @@ -809,14 +874,12 @@ impl Settings { return Err(SettingsError::SuffixContainsSeparator(additional_suffix)); } let strategy = Strategy::from(matches, obs_lines).map_err(SettingsError::Strategy)?; - let (suffix_type, suffix_start) = suffix_type_from(matches)?; - let suffix_length_str = matches.get_one::(OPT_SUFFIX_LENGTH).unwrap(); - let suffix_length: usize = suffix_length_str - .parse() - .map_err(|_| SettingsError::SuffixNotParsable(suffix_length_str.to_string()))?; + let (suffix_type, suffix_start, suffix_auto_widening, suffix_length) = + suffix_from(matches, &strategy)?; + if let Strategy::Number(ref number_type) = strategy { let chunks = number_type.num_chunks(); - if suffix_length != 0 { + if !suffix_auto_widening { let required_suffix_length = (chunks as f64).log(suffix_type.radix() as f64).ceil() as usize; if suffix_length < required_suffix_length { @@ -845,13 +908,12 @@ impl Settings { }; let result = Self { - suffix_length: suffix_length_str - .parse() - .map_err(|_| SettingsError::SuffixNotParsable(suffix_length_str.to_string()))?, + suffix_length, suffix_type, suffix_start, + suffix_auto_widening, additional_suffix, - verbose: matches.value_source("verbose") == Some(ValueSource::CommandLine), + verbose: matches.value_source(OPT_VERBOSE) == Some(ValueSource::CommandLine), separator, strategy, input: matches.get_one::(ARG_INPUT).unwrap().to_owned(), @@ -979,6 +1041,7 @@ impl<'a> ByteChunkWriter<'a> { settings.suffix_length, settings.suffix_type, settings.suffix_start, + settings.suffix_auto_widening, )?; let filename = filename_iterator .next() @@ -1109,6 +1172,7 @@ impl<'a> LineChunkWriter<'a> { settings.suffix_length, settings.suffix_type, settings.suffix_start, + settings.suffix_auto_widening, )?; let filename = filename_iterator .next() @@ -1222,6 +1286,7 @@ impl<'a> LineBytesChunkWriter<'a> { settings.suffix_length, settings.suffix_type, settings.suffix_start, + settings.suffix_auto_widening, )?; let filename = filename_iterator .next() @@ -1445,6 +1510,7 @@ where settings.suffix_length, settings.suffix_type, settings.suffix_start, + settings.suffix_auto_widening, )?; // Create one writer for each chunk. This will create each @@ -1616,6 +1682,7 @@ where settings.suffix_length, settings.suffix_type, settings.suffix_start, + settings.suffix_auto_widening, )?; // Create one writer for each chunk. This will create each @@ -1757,6 +1824,7 @@ where settings.suffix_length, settings.suffix_type, settings.suffix_start, + settings.suffix_auto_widening, ) .map_err(|e| io::Error::new(ErrorKind::Other, format!("{e}")))?; From c7c8c748d13edaeae6ad4f5ae30aeb3110ef88c0 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 24 Oct 2023 07:29:06 +0200 Subject: [PATCH 356/370] Bump const-random from 0.1.15 to 0.1.16 --- Cargo.lock | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e42d18a79..333cbd186 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -333,23 +333,21 @@ dependencies = [ [[package]] name = "const-random" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368a7a772ead6ce7e1de82bfb04c485f3db8ec744f72925af5735e29a22cc18e" +checksum = "11df32a13d7892ec42d51d3d175faba5211ffe13ed25d4fb348ac9e9ce835593" dependencies = [ "const-random-macro", - "proc-macro-hack", ] [[package]] name = "const-random-macro" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ "getrandom", "once_cell", - "proc-macro-hack", "tiny-keccak", ] @@ -1589,12 +1587,6 @@ dependencies = [ "yansi", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - [[package]] name = "proc-macro2" version = "1.0.63" From d7b7dfeb16742f9855155d9ea413f56b3758c5c6 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 24 Oct 2023 10:07:28 +0200 Subject: [PATCH 357/370] ls: use try_get_matches_from instead of get_matches_from to replace clap's exit code --- src/uu/ls/src/ls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 41d2f59b1..8ecf7982a 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1027,7 +1027,7 @@ impl Config { pub fn uumain(args: impl uucore::Args) -> UResult<()> { let command = uu_app(); - let matches = command.get_matches_from(args); + let matches = command.try_get_matches_from(args)?; let config = Config::from(&matches)?; From 769eb29cd3503d7734776572f7875a864c847c92 Mon Sep 17 00:00:00 2001 From: David Matos Date: Tue, 24 Oct 2023 10:54:23 +0200 Subject: [PATCH 358/370] mv: moving directory itself should fail (#5429) * mv: moving directory itself should fail * mv: Check trailing slash also fails on target containing itself * mv: add "spell-checker:ignore mydir" to test --------- Co-authored-by: Daniel Hofstetter --- src/uu/mv/src/error.rs | 5 +++++ src/uu/mv/src/mv.rs | 22 ++++++++++++++++++++++ tests/by-util/test_mv.rs | 25 +++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/src/uu/mv/src/error.rs b/src/uu/mv/src/error.rs index a6605e232..e891fc2ec 100644 --- a/src/uu/mv/src/error.rs +++ b/src/uu/mv/src/error.rs @@ -12,6 +12,7 @@ pub enum MvError { NoSuchFile(String), SameFile(String, String), SelfSubdirectory(String), + SelfTargetSubdirectory(String, String), DirectoryToNonDirectory(String), NonDirectoryToDirectory(String, String), NotADirectory(String), @@ -29,6 +30,10 @@ impl Display for MvError { f, "cannot move '{s}' to a subdirectory of itself, '{s}/{s}'" ), + Self::SelfTargetSubdirectory(s, t) => write!( + f, + "cannot move '{s}' to a subdirectory of itself, '{t}/{s}'" + ), Self::DirectoryToNonDirectory(t) => { write!(f, "cannot overwrite directory {t} with non-directory") } diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 7236907da..47e0b864d 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -326,6 +326,28 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()> Err(MvError::DirectoryToNonDirectory(target.quote().to_string()).into()) } } else { + // Check that source & target do not contain same subdir/dir when both exist + // mkdir dir1/dir2; mv dir1 dir1/dir2 + let target_contains_itself = target + .as_os_str() + .to_str() + .ok_or("not a valid unicode string") + .and_then(|t| { + source + .as_os_str() + .to_str() + .ok_or("not a valid unicode string") + .map(|s| t.contains(s)) + }) + .unwrap(); + + if target_contains_itself { + return Err(MvError::SelfTargetSubdirectory( + source.display().to_string(), + target.display().to_string(), + ) + .into()); + } move_files_into_dir(&[source.to_path_buf()], target, opts) } } else if target.exists() && source.is_dir() { diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index f7f9622f5..e88667320 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -2,6 +2,8 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. +// +// spell-checker:ignore mydir use crate::common::util::TestScenario; use filetime::FileTime; use std::thread::sleep; @@ -1389,6 +1391,29 @@ fn test_mv_into_self_data() { assert!(at.file_exists(file2)); assert!(!at.file_exists(file1)); } + +#[test] +fn test_mv_directory_into_subdirectory_of_itself_fails() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + let dir1 = "mydir"; + let dir2 = "mydir/mydir_2"; + at.mkdir(dir1); + at.mkdir(dir2); + scene.ucmd().arg(dir1).arg(dir2).fails().stderr_contains( + "mv: cannot move 'mydir' to a subdirectory of itself, 'mydir/mydir_2/mydir'", + ); + + // check that it also errors out with / + scene + .ucmd() + .arg(format!("{}/", dir1)) + .arg(dir2) + .fails() + .stderr_contains( + "mv: cannot move 'mydir/' to a subdirectory of itself, 'mydir/mydir_2/mydir/'", + ); +} // Todo: // $ at.touch a b From fd18d2686f4d0a28dcf95a1db0f419cc82db699e Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 24 Oct 2023 14:48:24 +0200 Subject: [PATCH 359/370] ls: return exit code 2 for -l --dired --zero --- src/uu/ls/src/ls.rs | 18 ++++++++++++------ tests/by-util/test_ls.rs | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 8ecf7982a..db7977412 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -168,7 +168,8 @@ enum LsError { IOError(std::io::Error), IOErrorContext(std::io::Error, PathBuf, bool), BlockSizeParseError(String), - ConflictingArgumentDired(), + ConflictingArgumentDired, + DiredAndZeroAreIncompatible, AlreadyListedError(PathBuf), TimeStyleParseError(String, Vec), } @@ -181,7 +182,8 @@ impl UError for LsError { Self::IOErrorContext(_, _, false) => 1, Self::IOErrorContext(_, _, true) => 2, Self::BlockSizeParseError(_) => 1, - Self::ConflictingArgumentDired() => 1, + Self::ConflictingArgumentDired => 1, + Self::DiredAndZeroAreIncompatible => 2, Self::AlreadyListedError(_) => 2, Self::TimeStyleParseError(_, _) => 1, } @@ -196,10 +198,12 @@ impl Display for LsError { Self::BlockSizeParseError(s) => { write!(f, "invalid --block-size argument {}", s.quote()) } - Self::ConflictingArgumentDired() => { + Self::ConflictingArgumentDired => { write!(f, "--dired requires --format=long") } - + Self::DiredAndZeroAreIncompatible => { + write!(f, "--dired and --zero are incompatible") + } Self::TimeStyleParseError(s, possible_time_styles) => { write!( f, @@ -966,7 +970,10 @@ impl Config { let dired = options.get_flag(options::DIRED); if dired && format != Format::Long { - return Err(Box::new(LsError::ConflictingArgumentDired())); + return Err(Box::new(LsError::ConflictingArgumentDired)); + } + if dired && format == Format::Long && options.get_flag(options::ZERO) { + return Err(Box::new(LsError::DiredAndZeroAreIncompatible)); } let dereference = if options.get_flag(options::dereference::ALL) { @@ -1142,7 +1149,6 @@ pub fn uu_app() -> Command { .arg( Arg::new(options::ZERO) .long(options::ZERO) - .conflicts_with(options::DIRED) .overrides_with(options::ZERO) .help("List entries separated by ASCII NUL characters.") .action(ArgAction::SetTrue), diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 15893b0e2..181c385e7 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -3564,6 +3564,20 @@ fn test_ls_dired_incompatible() { .stderr_contains("--dired requires --format=long"); } +#[test] +fn test_ls_dired_and_zero_are_incompatible() { + let scene = TestScenario::new(util_name!()); + + scene + .ucmd() + .arg("--dired") + .arg("-l") + .arg("--zero") + .fails() + .code_is(2) + .stderr_contains("--dired and --zero are incompatible"); +} + #[test] fn test_ls_dired_recursive() { let scene = TestScenario::new(util_name!()); From 6f84e56e28ebb2c5fb246cba74031a9008503442 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 24 Oct 2023 16:33:04 +0200 Subject: [PATCH 360/370] ls: return exit code 2 for invalid time-style --- src/uu/ls/src/ls.rs | 2 +- tests/by-util/test_ls.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 41d2f59b1..935741959 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -183,7 +183,7 @@ impl UError for LsError { Self::BlockSizeParseError(_) => 1, Self::ConflictingArgumentDired() => 1, Self::AlreadyListedError(_) => 2, - Self::TimeStyleParseError(_, _) => 1, + Self::TimeStyleParseError(_, _) => 2, } } } diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 15893b0e2..18deb1551 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -1737,7 +1737,12 @@ fn test_ls_styles() { .stdout_matches(&re_custom_format); // Also fails due to not having full clap support for time_styles - scene.ucmd().arg("-l").arg("-time-style=invalid").fails(); + scene + .ucmd() + .arg("-l") + .arg("--time-style=invalid") + .fails() + .code_is(2); //Overwrite options tests scene From 3bf1ed419533a9ab66254e509a55af34e8a7ad0f Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 24 Oct 2023 23:56:00 +0200 Subject: [PATCH 361/370] df: Replace the error message by the one generated by clap Failed with: -df: options OPT and --output are mutually exclusive -Try 'df --help' for more information. +error: the argument '--inodes' cannot be used with '--output[=...]' + +Usage: df [OPTION]... [FILE]... --- util/build-gnu.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 0af07266b..7c0691c06 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -269,6 +269,8 @@ sed -i -E "s|^([^#]*2_31.*)$|#\1|g" tests/printf/printf-cov.pl sed -i -e "s/du: invalid -t argument/du: invalid --threshold argument/" -e "s/du: option requires an argument/error: a value is required for '--threshold ' but none was supplied/" -e "/Try 'du --help' for more information./d" tests/du/threshold.sh +awk 'BEGIN {count=0} /compare exp out2/ && count < 6 {sub(/compare exp out2/, "grep -q \"cannot be used with\" out2"); count++} 1' tests/df/df-output.sh > tests/df/df-output.sh.tmp && mv tests/df/df-output.sh.tmp tests/df/df-output.sh + # with ls --dired, in case of error, we have a slightly different error position sed -i -e "s|44 45|48 49|" tests/ls/stat-failed.sh From e508b6e9df39bfdabe02504be53f7a0a3b8b452e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 22:49:28 +0000 Subject: [PATCH 362/370] chore(deps): update rust crate bytecount to 0.6.7 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 333cbd186..1e6aa238d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,9 +205,9 @@ checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] name = "bytecount" -version = "0.6.5" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1a12477b7237a01c11a80a51278165f9ba0edd28fa6db00a65ab230320dc58c" +checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" [[package]] name = "byteorder" diff --git a/Cargo.toml b/Cargo.toml index 4dd8b2a19..a88fe5fc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -260,7 +260,7 @@ test = ["uu_test"] bigdecimal = "0.4" binary-heap-plus = "0.5.0" bstr = "1.7" -bytecount = "0.6.5" +bytecount = "0.6.7" byteorder = "1.5.0" chrono = { version = "^0.4.31", default-features = false, features = [ "std", From db26dabd6eb803694fe51a55d7690cbd26060d2c Mon Sep 17 00:00:00 2001 From: Nathan Houghton Date: Sat, 21 Oct 2023 20:23:28 -0700 Subject: [PATCH 363/370] tests/dd: Do not use the OS provided dd utility on FIFOs On *BSD and macOS, the system provided dd utility opens up the output file for both reading and writing. This means that the open/write to the FIFO does not block, and almost instantly completes. The system dd then exits, leaving nothing left to be read by the time the coreutils-rs dd tries to open/read the FIFO. Avoid this problem by just writing to the FIFO from the test case itself, rather than relying on the system provide dd. --- tests/by-util/test_dd.rs | 72 ++++++++++++---------------------------- 1 file changed, 22 insertions(+), 50 deletions(-) diff --git a/tests/by-util/test_dd.rs b/tests/by-util/test_dd.rs index 8ebf57c1c..f560e3526 100644 --- a/tests/by-util/test_dd.rs +++ b/tests/by-util/test_dd.rs @@ -15,8 +15,6 @@ use regex::Regex; use std::fs::{File, OpenOptions}; use std::io::{BufReader, Read, Write}; use std::path::PathBuf; -#[cfg(all(unix, not(target_os = "macos"), not(target_os = "freebsd")))] -use std::process::{Command, Stdio}; #[cfg(not(windows))] use std::thread::sleep; #[cfg(not(windows))] @@ -1459,74 +1457,48 @@ fn test_sparse() { assert_eq!(at.metadata("infile").len(), at.metadata("outfile").len()); } -// TODO These FIFO tests should work on macos, but some issue is -// causing our implementation of dd to wait indefinitely when it -// shouldn't. - /// Test that a seek on an output FIFO results in a read. #[test] -#[cfg(all(unix, not(target_os = "macos"), not(target_os = "freebsd")))] +#[cfg(unix)] fn test_seek_output_fifo() { let ts = TestScenario::new(util_name!()); let at = &ts.fixtures; at.mkfifo("fifo"); - // TODO When `dd` is a bit more advanced, we could use the uutils - // version of dd here as well. - let child = Command::new("dd") - .current_dir(&at.subdir) - .args([ - "count=1", - "if=/dev/zero", - &format!("of={}", at.plus_as_string("fifo")), - "status=noxfer", - ]) - .stderr(Stdio::piped()) - .spawn() - .expect("failed to execute child process"); - - ts.ucmd() + let mut ucmd = ts.ucmd(); + let child = ucmd .args(&["count=0", "seek=1", "of=fifo", "status=noxfer"]) - .succeeds() - .stderr_only("0+0 records in\n0+0 records out\n"); + .run_no_wait(); - let output = child.wait_with_output().unwrap(); - assert!(output.status.success()); - assert!(output.stdout.is_empty()); - assert_eq!(&output.stderr, b"1+0 records in\n1+0 records out\n"); + std::fs::write(at.plus("fifo"), &vec![0; 512]).unwrap(); + + child + .wait() + .unwrap() + .success() + .stderr_only("0+0 records in\n0+0 records out\n"); } /// Test that a skip on an input FIFO results in a read. #[test] -#[cfg(all(unix, not(target_os = "macos"), not(target_os = "freebsd")))] +#[cfg(unix)] fn test_skip_input_fifo() { let ts = TestScenario::new(util_name!()); let at = &ts.fixtures; at.mkfifo("fifo"); - // TODO When `dd` is a bit more advanced, we could use the uutils - // version of dd here as well. - let child = Command::new("dd") - .current_dir(&at.subdir) - .args([ - "count=1", - "if=/dev/zero", - &format!("of={}", at.plus_as_string("fifo")), - "status=noxfer", - ]) - .stderr(Stdio::piped()) - .spawn() - .expect("failed to execute child process"); - - ts.ucmd() + let mut ucmd = ts.ucmd(); + let child = ucmd .args(&["count=0", "skip=1", "if=fifo", "status=noxfer"]) - .succeeds() - .stderr_only("0+0 records in\n0+0 records out\n"); + .run_no_wait(); - let output = child.wait_with_output().unwrap(); - assert!(output.status.success()); - assert!(output.stdout.is_empty()); - assert_eq!(&output.stderr, b"1+0 records in\n1+0 records out\n"); + std::fs::write(at.plus("fifo"), &vec![0; 512]).unwrap(); + + child + .wait() + .unwrap() + .success() + .stderr_only("0+0 records in\n0+0 records out\n"); } /// Test for reading part of stdin from each of two child processes. From 9df50096c867ba182d4b0c1b2b520ea9dd4c5a86 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 25 Oct 2023 10:15:46 +0200 Subject: [PATCH 364/370] cp: remove "all" from cfg; rename test fn --- tests/by-util/test_cp.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 71c3eafb0..a4922f93f 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -1552,8 +1552,8 @@ fn test_cp_preserve_links_case_7() { } #[test] -#[cfg(all(unix))] -fn test_cp_no_preserve_mode_case() { +#[cfg(unix)] +fn test_cp_no_preserve_mode() { use libc::umask; use uucore::fs as uufs; let (at, mut ucmd) = at_and_ucmd!(); From 086f7b548c525d7945f7edacbf1b3e7cea78c659 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 25 Oct 2023 10:20:01 +0200 Subject: [PATCH 365/370] cp: replace word in comment --- 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 40b485c5c..4240af01f 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -184,7 +184,7 @@ pub struct Attributes { #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Preserve { - // explicit means is the --no-preserve flag is used or not to distinguish out the default value. + // explicit means whether the --no-preserve flag is used or not to distinguish out the default value. // e.g. --no-preserve=mode means mode = No { explicit = true } No { explicit: bool }, Yes { required: bool }, From f8a30d524e1e5bd0c6f80a14293d9ad4ab83b4df Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 25 Oct 2023 10:43:23 +0200 Subject: [PATCH 366/370] cp: rename handling_no_preserve_mode to handle_no_preserve_mode --- src/uu/cp/src/cp.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 4240af01f..0ceef46e3 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1743,7 +1743,7 @@ fn copy_file( let mut permissions = source_metadata.permissions(); #[cfg(unix)] { - let mut mode = handling_no_preserve_mode(options, permissions.mode()); + let mut mode = handle_no_preserve_mode(options, permissions.mode()); // apply umask use uucore::mode::get_umask; @@ -1876,7 +1876,7 @@ fn copy_file( } #[cfg(unix)] -fn handling_no_preserve_mode(options: &Options, org_mode: u32) -> u32 { +fn handle_no_preserve_mode(options: &Options, org_mode: u32) -> u32 { let (is_preserve_mode, is_explicit_no_preserve_mode) = options.preserve_mode(); if !is_preserve_mode { use libc::{ From 32b335a73a11cc9a43fa5075f56cbd76c1fcaab7 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 25 Oct 2023 16:38:01 +0200 Subject: [PATCH 367/370] mv: rename canonized_* -> canonicalized_* --- src/uu/mv/src/mv.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 47e0b864d..5c52fef26 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) sourcepath targetpath nushell +// spell-checker:ignore (ToDO) sourcepath targetpath nushell canonicalized mod error; @@ -405,7 +405,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, opts: &Options) -> return Err(MvError::NotADirectory(target_dir.quote().to_string()).into()); } - let canonized_target_dir = target_dir + let canonicalized_target_dir = target_dir .canonicalize() .unwrap_or_else(|_| target_dir.to_path_buf()); @@ -440,8 +440,8 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, opts: &Options) -> // Check if we have mv dir1 dir2 dir2 // And generate an error if this is the case - if let Ok(canonized_source) = sourcepath.canonicalize() { - if canonized_source == canonized_target_dir { + if let Ok(canonicalized_source) = sourcepath.canonicalize() { + if canonicalized_source == canonicalized_target_dir { // User tried to move directory to itself, warning is shown // and process of moving files is continued. show!(USimpleError::new( @@ -450,7 +450,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, opts: &Options) -> "cannot move '{}' to a subdirectory of itself, '{}/{}'", sourcepath.display(), target_dir.display(), - canonized_target_dir.components().last().map_or_else( + canonicalized_target_dir.components().last().map_or_else( || target_dir.display().to_string(), |dir| { PathBuf::from(dir.as_os_str()).display().to_string() } ) From 391b422ce1ec04922a299bab62339852e7198304 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 23:04:43 +0000 Subject: [PATCH 368/370] chore(deps): update rust crate tempfile to 3.8.1 --- Cargo.lock | 14 +++++++------- Cargo.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e6aa238d..164d6d6b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1852,9 +1852,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.20" +version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ "bitflags 2.4.0", "errno", @@ -2066,14 +2066,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.3.5", - "rustix 0.38.20", + "redox_syscall 0.4.0", + "rustix 0.38.21", "windows-sys 0.48.0", ] @@ -2093,7 +2093,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.38.20", + "rustix 0.38.21", "windows-sys 0.48.0", ] diff --git a/Cargo.toml b/Cargo.toml index a88fe5fc6..afddd4985 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -317,7 +317,7 @@ self_cell = "1.0.1" selinux = "0.4" signal-hook = "0.3.17" smallvec = { version = "1.11", features = ["union"] } -tempfile = "3.8.0" +tempfile = "3.8.1" uutils_term_grid = "0.3" terminal_size = "0.3.0" textwrap = { version = "0.16.0", features = ["terminal_size"] } From 9f5db291450d492dab8229aaac1465b79d4d6f66 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 26 Oct 2023 16:18:48 +0200 Subject: [PATCH 369/370] cp: add test for --attributes-only --- tests/by-util/test_cp.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 4867c17ea..c79367afb 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -3499,3 +3499,33 @@ fn test_cp_dest_no_permissions() { .stderr_contains("invalid_perms.txt") .stderr_contains("denied"); } + +#[test] +#[cfg(all(unix, not(target_os = "freebsd")))] +fn test_cp_attributes_only() { + let (at, mut ucmd) = at_and_ucmd!(); + let a = "file_a"; + let b = "file_b"; + let mode_a = 0o0500; + let mode_b = 0o0777; + + at.write(a, "a"); + at.write(b, "b"); + at.set_mode(a, mode_a); + at.set_mode(b, mode_b); + + let mode_a = at.metadata(a).mode(); + let mode_b = at.metadata(b).mode(); + + // --attributes-only doesn't do anything without other attribute preservation flags + ucmd.arg("--attributes-only") + .arg(a) + .arg(b) + .succeeds() + .no_output(); + + assert_eq!("a", at.read(a)); + assert_eq!("b", at.read(b)); + assert_eq!(mode_a, at.metadata(a).mode()); + assert_eq!(mode_b, at.metadata(b).mode()); +} From 5c100dd088eee3d5f990c651fb95753a8c318ee1 Mon Sep 17 00:00:00 2001 From: Mick van Gelderen Date: Sat, 28 Oct 2023 15:04:51 +0200 Subject: [PATCH 370/370] mv: Fix stderr output mv file into dir and dir into file where both are files (#5464) * Add tests mv file into dir and dir into file where both are files * Fix test_mv_dir_into_file_where_both_are_files * Fix test_mv_file_into_dir_where_both_are_files * Store String in error instead of PathBuf * Implement path_ends_with_terminator for windows * Fix compilation on windows --- src/uu/mv/src/error.rs | 7 +++++++ src/uu/mv/src/mv.rs | 33 +++++++++++++++++++++++++++++++-- tests/by-util/test_mv.rs | 29 +++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/uu/mv/src/error.rs b/src/uu/mv/src/error.rs index e891fc2ec..f989d4e13 100644 --- a/src/uu/mv/src/error.rs +++ b/src/uu/mv/src/error.rs @@ -10,6 +10,7 @@ use uucore::error::UError; #[derive(Debug)] pub enum MvError { NoSuchFile(String), + CannotStatNotADirectory(String), SameFile(String, String), SelfSubdirectory(String), SelfTargetSubdirectory(String, String), @@ -17,6 +18,7 @@ pub enum MvError { NonDirectoryToDirectory(String, String), NotADirectory(String), TargetNotADirectory(String), + FailedToAccessNotADirectory(String), } impl Error for MvError {} @@ -25,6 +27,7 @@ impl Display for MvError { fn fmt(&self, f: &mut Formatter) -> Result { match self { Self::NoSuchFile(s) => write!(f, "cannot stat {s}: No such file or directory"), + Self::CannotStatNotADirectory(s) => write!(f, "cannot stat {s}: Not a directory"), Self::SameFile(s, t) => write!(f, "{s} and {t} are the same file"), Self::SelfSubdirectory(s) => write!( f, @@ -42,6 +45,10 @@ impl Display for MvError { } Self::NotADirectory(t) => write!(f, "target {t}: Not a directory"), Self::TargetNotADirectory(t) => write!(f, "target directory {t}: Not a directory"), + + Self::FailedToAccessNotADirectory(t) => { + write!(f, "failed to access {t}: Not a directory") + } } } } diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 5c52fef26..0ceda8e75 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -103,6 +103,25 @@ static OPT_VERBOSE: &str = "verbose"; static OPT_PROGRESS: &str = "progress"; static ARG_FILES: &str = "files"; +/// Returns true if the passed `path` ends with a path terminator. +#[cfg(unix)] +fn path_ends_with_terminator(path: &Path) -> bool { + use std::os::unix::prelude::OsStrExt; + path.as_os_str() + .as_bytes() + .last() + .map_or(false, |&byte| byte == b'/' || byte == b'\\') +} + +#[cfg(windows)] +fn path_ends_with_terminator(path: &Path) -> bool { + use std::os::windows::prelude::OsStrExt; + path.as_os_str() + .encode_wide() + .last() + .map_or(false, |wide| wide == b'/'.into() || wide == b'\\'.into()) +} + #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let mut app = uu_app(); @@ -299,7 +318,11 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()> .into()); } if source.symlink_metadata().is_err() { - return Err(MvError::NoSuchFile(source.quote().to_string()).into()); + return Err(if path_ends_with_terminator(source) { + MvError::CannotStatNotADirectory(source.quote().to_string()).into() + } else { + MvError::NoSuchFile(source.quote().to_string()).into() + }); } if (source.eq(target) @@ -316,7 +339,13 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()> } } - if target.is_dir() { + let target_is_dir = target.is_dir(); + + if path_ends_with_terminator(target) && !target_is_dir { + return Err(MvError::FailedToAccessNotADirectory(target.quote().to_string()).into()); + } + + if target_is_dir { if opts.no_target_dir { if source.is_dir() { rename(source, target, opts, None).map_err_context(|| { diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index e88667320..c54d24ea9 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -1414,6 +1414,35 @@ fn test_mv_directory_into_subdirectory_of_itself_fails() { "mv: cannot move 'mydir/' to a subdirectory of itself, 'mydir/mydir_2/mydir/'", ); } + +#[test] +fn test_mv_file_into_dir_where_both_are_files() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.touch("a"); + at.touch("b"); + scene + .ucmd() + .arg("a") + .arg("b/") + .fails() + .stderr_contains("mv: failed to access 'b/': Not a directory"); +} + +#[test] +fn test_mv_dir_into_file_where_both_are_files() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + at.touch("a"); + at.touch("b"); + scene + .ucmd() + .arg("a/") + .arg("b") + .fails() + .stderr_contains("mv: cannot stat 'a/': Not a directory"); +} + // Todo: // $ at.touch a b