mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Merge pull request #4637 from haciek/du_threshold_err_fix
du: threshold error message fix
This commit is contained in:
commit
089e645e3b
2 changed files with 14 additions and 0 deletions
|
@ -913,6 +913,11 @@ impl FromStr for Threshold {
|
||||||
let size = parse_size(&s[offset..])?;
|
let size = parse_size(&s[offset..])?;
|
||||||
|
|
||||||
if s.starts_with('-') {
|
if s.starts_with('-') {
|
||||||
|
// Threshold of '-0' excludes everything besides 0 sized entries
|
||||||
|
// GNU's du treats '-0' as an invalid argument
|
||||||
|
if size == 0 {
|
||||||
|
return Err(ParseSizeError::ParseFailure(s.to_string()));
|
||||||
|
}
|
||||||
Ok(Self::Upper(size))
|
Ok(Self::Upper(size))
|
||||||
} else {
|
} else {
|
||||||
Ok(Self::Lower(size))
|
Ok(Self::Lower(size))
|
||||||
|
|
|
@ -546,6 +546,15 @@ fn test_du_threshold() {
|
||||||
.stdout_contains("deeper_dir");
|
.stdout_contains("deeper_dir");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_du_invalid_threshold() {
|
||||||
|
let ts = TestScenario::new(util_name!());
|
||||||
|
|
||||||
|
let threshold = "-0";
|
||||||
|
|
||||||
|
ts.ucmd().arg(format!("--threshold={threshold}")).fails();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_du_apparent_size() {
|
fn test_du_apparent_size() {
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue