From fae0065276c8d80d39c66254eecdfe26fb11bcc6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Apr 2022 11:14:49 +0000 Subject: [PATCH 1/8] build(deps): bump remove_dir_all from 0.5.3 to 0.7.0 Bumps [remove_dir_all](https://github.com/XAMPPRocky/remove_dir_all) from 0.5.3 to 0.7.0. - [Release notes](https://github.com/XAMPPRocky/remove_dir_all/releases) - [Changelog](https://github.com/XAMPPRocky/remove_dir_all/blob/master/CHANGELOG.md) - [Commits](https://github.com/XAMPPRocky/remove_dir_all/compare/remove_dir_all@0.5.3...v0.7.0) --- updated-dependencies: - dependency-name: remove_dir_all dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 17 +++++++++++++++-- src/uu/rm/Cargo.toml | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a281523c..e860b01cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1661,6 +1661,19 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "remove_dir_all" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882f368737489ea543bc5c340e6f3d34a28c39980bd9a979e47322b26f60ac40" +dependencies = [ + "libc", + "log", + "num_cpus", + "rayon", + "winapi 0.3.9", +] + [[package]] name = "retain_mut" version = "0.1.2" @@ -1942,7 +1955,7 @@ dependencies = [ "fastrand", "libc", "redox_syscall", - "remove_dir_all", + "remove_dir_all 0.5.3", "winapi 0.3.9", ] @@ -2831,7 +2844,7 @@ name = "uu_rm" version = "0.0.13" dependencies = [ "clap 3.1.8", - "remove_dir_all", + "remove_dir_all 0.7.0", "uucore", "walkdir", "winapi 0.3.9", diff --git a/src/uu/rm/Cargo.toml b/src/uu/rm/Cargo.toml index 630f3a294..77d221e39 100644 --- a/src/uu/rm/Cargo.toml +++ b/src/uu/rm/Cargo.toml @@ -17,7 +17,7 @@ path = "src/rm.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } walkdir = "2.2" -remove_dir_all = "0.5.1" +remove_dir_all = "0.7.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } [target.'cfg(windows)'.dependencies] From 1eb76129664f96fc36c6db1331d1dc9ff88e7bb3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Apr 2022 19:41:07 +0000 Subject: [PATCH 2/8] build(deps): bump crossterm from 0.23.1 to 0.23.2 Bumps [crossterm](https://github.com/crossterm-rs/crossterm) from 0.23.1 to 0.23.2. - [Release notes](https://github.com/crossterm-rs/crossterm/releases) - [Changelog](https://github.com/crossterm-rs/crossterm/blob/master/CHANGELOG.md) - [Commits](https://github.com/crossterm-rs/crossterm/commits) --- updated-dependencies: - dependency-name: crossterm dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d832e547c..222b4df5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -604,9 +604,9 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fd7173631a4e9e2ca8b32ae2fad58aab9843ea5aaf56642661937d87e28a3e" +checksum = "a2102ea4f781910f8a5b98dd061f4c2023f479ce7bb1236330099ceb5a93cf17" dependencies = [ "bitflags", "crossterm_winapi", @@ -862,7 +862,7 @@ checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -1116,14 +1116,15 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.14" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" +checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" dependencies = [ "libc", "log", "miow", "ntapi", + "wasi 0.11.0+wasi-snapshot-preview1", "winapi 0.3.9", ] @@ -1729,9 +1730,9 @@ dependencies = [ [[package]] name = "signal-hook-mio" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29fd5867f1c4f2c5be079aee7a2adf1152ebb04a4bc4d341f504b7dece607ed4" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", "mio", @@ -3088,6 +3089,12 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "which" version = "4.2.2" From 576ec49fa51a8294818dacd81453c4eb9ccece38 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 18 Apr 2022 14:30:20 +0200 Subject: [PATCH 3/8] df: remove trailing spaces in rightmost column --- src/uu/df/src/table.rs | 13 +++++++++++-- tests/by-util/test_df.rs | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/uu/df/src/table.rs b/src/uu/df/src/table.rs index 698da2bdb..a9a8d010a 100644 --- a/src/uu/df/src/table.rs +++ b/src/uu/df/src/table.rs @@ -400,12 +400,21 @@ impl fmt::Display for Table { while let Some(row) = row_iter.next() { let mut col_iter = row.iter().enumerate().peekable(); while let Some((i, elem)) = col_iter.next() { + let is_last_col = col_iter.peek().is_none(); + match self.alignments[i] { - Alignment::Left => write!(f, "{: { + if is_last_col { + // no trailing spaces in last column + write!(f, "{}", elem)?; + } else { + write!(f, "{: write!(f, "{:>width$}", elem, width = self.widths[i])?, } - if col_iter.peek().is_some() { + if !is_last_col { // column separator write!(f, " ")?; } diff --git a/tests/by-util/test_df.rs b/tests/by-util/test_df.rs index 223dc4efc..230430412 100644 --- a/tests/by-util/test_df.rs +++ b/tests/by-util/test_df.rs @@ -349,7 +349,7 @@ fn test_output_selects_columns() { .args(&["--output=source"]) .succeeds() .stdout_move_str(); - assert_eq!(output.lines().next().unwrap().trim_end(), "Filesystem"); + assert_eq!(output.lines().next().unwrap(), "Filesystem"); let output = new_ucmd!() .args(&["--output=source,target"]) @@ -408,7 +408,7 @@ fn test_output_file_all_filesystems() { let mut lines = output.lines(); assert_eq!(lines.next().unwrap(), "File"); for line in lines { - assert_eq!(line, "- "); + assert_eq!(line, "-"); } } @@ -427,7 +427,7 @@ fn test_output_file_specific_files() { .succeeds() .stdout_move_str(); let actual: Vec<&str> = output.lines().collect(); - assert_eq!(actual, vec!["File", "a ", "b ", "c "]); + assert_eq!(actual, vec!["File", "a", "b", "c"]); } #[test] @@ -448,5 +448,5 @@ fn test_nonexistent_file() { .args(&["--output=file", "does-not-exist", "."]) .fails() .stderr_is("df: does-not-exist: No such file or directory\n") - .stdout_is("File\n. \n"); + .stdout_is("File\n.\n"); } From cc4b28780bf03e086b2b634c2e6dd74c4f1622af Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 15 Apr 2022 15:26:17 +0200 Subject: [PATCH 4/8] df: show error if all types are excluded Fixes #3409 --- src/uu/df/src/df.rs | 3 ++- tests/by-util/test_df.rs | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index ce6804770..b4f3457c4 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -287,6 +287,7 @@ fn get_all_filesystems(opt: &Options) -> Vec { mounts .into_iter() .filter_map(|m| Filesystem::new(m, None)) + .filter(|fs| opt.show_all_fs || fs.usage.blocks > 0) .collect() } @@ -362,7 +363,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let filesystems = get_all_filesystems(&opt); if filesystems.is_empty() { - return Err(USimpleError::new(1, "No file systems processed")); + return Err(USimpleError::new(1, "no file systems processed")); } filesystems diff --git a/tests/by-util/test_df.rs b/tests/by-util/test_df.rs index 223dc4efc..ca8296018 100644 --- a/tests/by-util/test_df.rs +++ b/tests/by-util/test_df.rs @@ -1,4 +1,6 @@ // spell-checker:ignore udev pcent iuse itotal iused ipcent +use std::collections::HashSet; + use crate::common::util::*; #[test] @@ -204,6 +206,27 @@ fn test_exclude_type_option() { new_ucmd!().args(&["-x", "ext4", "-x", "ext3"]).succeeds(); } +#[test] +fn test_exclude_all_types() { + let fs_types = new_ucmd!() + .arg("--output=fstype") + .succeeds() + .stdout_move_str(); + let fs_types: HashSet<_> = fs_types.lines().skip(1).collect(); + + let mut args = Vec::new(); + + for fs_type in fs_types { + args.push("-x"); + args.push(fs_type.trim_end()); + } + + new_ucmd!() + .args(&args) + .fails() + .stderr_contains("no file systems processed"); +} + #[test] fn test_include_exclude_same_type() { new_ucmd!() From 9de407b1f0be3ccb7d451eedeae11eaae3fa10fe Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 19 Apr 2022 10:40:10 +0200 Subject: [PATCH 5/8] df: fix "File" column width for unicode filenames Fixes #3425 --- Cargo.lock | 1 + src/uu/df/Cargo.toml | 1 + src/uu/df/src/table.rs | 5 +++-- tests/by-util/test_df.rs | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d832e547c..eda10a194 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2206,6 +2206,7 @@ version = "0.0.13" dependencies = [ "clap 3.1.8", "number_prefix", + "unicode-width", "uucore", ] diff --git a/src/uu/df/Cargo.toml b/src/uu/df/Cargo.toml index c6a1c570b..1020b71bb 100644 --- a/src/uu/df/Cargo.toml +++ b/src/uu/df/Cargo.toml @@ -18,6 +18,7 @@ path = "src/df.rs" clap = { version = "3.1", features = ["wrap_help", "cargo"] } number_prefix = "0.4" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc", "fsext"] } +unicode-width = "0.1.9" [[bin]] name = "df" diff --git a/src/uu/df/src/table.rs b/src/uu/df/src/table.rs index 698da2bdb..6b64ce02c 100644 --- a/src/uu/df/src/table.rs +++ b/src/uu/df/src/table.rs @@ -8,6 +8,7 @@ //! A table ([`Table`]) comprises a header row ([`Header`]) and a //! collection of data rows ([`Row`]), one per filesystem. use number_prefix::NumberPrefix; +use unicode_width::UnicodeWidthStr; use crate::columns::{Alignment, Column}; use crate::filesystem::Filesystem; @@ -362,8 +363,8 @@ impl Table { total += row; for (i, value) in values.iter().enumerate() { - if value.len() > widths[i] { - widths[i] = value.len(); + if UnicodeWidthStr::width(value.as_str()) > widths[i] { + widths[i] = UnicodeWidthStr::width(value.as_str()); } } diff --git a/tests/by-util/test_df.rs b/tests/by-util/test_df.rs index 223dc4efc..f9e826dec 100644 --- a/tests/by-util/test_df.rs +++ b/tests/by-util/test_df.rs @@ -165,6 +165,7 @@ fn test_output_mp_repeat() { assert_eq!(3, output1.len()); assert_eq!(output1[1], output1[2]); } + #[test] fn test_output_conflict_options() { for option in ["-i", "-T", "-P"] { @@ -430,6 +431,20 @@ fn test_output_file_specific_files() { assert_eq!(actual, vec!["File", "a ", "b ", "c "]); } +#[test] +fn test_file_column_width_if_filename_contains_unicode_chars() { + let (at, mut ucmd) = at_and_ucmd!(); + at.touch("äöü.txt"); + + let output = ucmd + .args(&["--output=file,target", "äöü.txt"]) + .succeeds() + .stdout_move_str(); + let actual = output.lines().next().unwrap(); + // expected width: 7 chars (length of äöü.txt) + 1 char (column separator) + assert_eq!(actual, "File Mounted on"); +} + #[test] fn test_output_field_no_more_than_once() { new_ucmd!() From 45b29d287fb057844689884e67e3524be46ee4fc Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 20 Apr 2022 08:37:53 +0200 Subject: [PATCH 6/8] Remove an old comment We have windows stable in the CI: https://github.com/uutils/coreutils/runs/6082164374?check_suite_focus=true And no longer Redox: https://github.com/uutils/coreutils/pull/2550 --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index f6df9fdcf..2dfffa017 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,6 @@ Both can also be generated locally, the instructions for that can be found in th uutils follows Rust's release channels and is tested against stable, beta and nightly. The current oldest supported version of the Rust compiler is `1.56`. -On both Windows and Redox, only the nightly version is tested currently. - ## Building There are currently two methods to build the uutils binaries: either Cargo From 4c5f586e339cfedfe52c9505e7250cc26c0f71e2 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 20 Apr 2022 19:01:57 +0200 Subject: [PATCH 7/8] Allow 0.10.2+wasi-snapshot-preview1 of wasi for getrandom --- deny.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deny.toml b/deny.toml index dea3503de..749a0d85b 100644 --- a/deny.toml +++ b/deny.toml @@ -61,6 +61,8 @@ highlight = "all" # introduces it. # spell-checker: disable skip = [ + # getrandom + { name = "wasi", version="0.10.2+wasi-snapshot-preview1" }, # blake2d_simd { name = "arrayvec", version = "=0.7.2" }, # flimit/unix_socket From ddb87d500ff3cb6f8c957ac9e3906da67d54455f Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 20 Apr 2022 19:10:20 +0200 Subject: [PATCH 8/8] Allow v0.5.3 of remove_all_dir for tempfile --- deny.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deny.toml b/deny.toml index dea3503de..c33f9b4ea 100644 --- a/deny.toml +++ b/deny.toml @@ -76,6 +76,8 @@ skip = [ { name = "cpp_common", version = "=0.4.0" }, # quickcheck { name = "env_logger", version = "=0.8.4" }, + # tempfile + { name = "remove_dir_all", version = "=0.5.3" }, # cpp_* { name = "memchr", version = "=1.0.2" }, { name = "quote", version = "=0.3.15" },